Comments (6)
Hey @sivananth,
Thanks for the kind words. In this case, it does indeed appear that the last month is not there since the last day in the dataset is August 29. Let me look into this because it should be there.
However, here is a way to get what you are looking for:
import ffn
moat = ffn.get('moat')
moat = moat.to_monthly()[:'2014-08']
print moat.tail()
As you can see, you have the august data as well. Also, I am using ffn's "get" function - it downloads the adjusted close from yahoo - easier this way (it uses DataReader).
Cheers,
Phil
from ffn.
Hi @pmorissette , i noticed something else -
indexes=ffn.get('spy').to_monthly()[:'2015-03']
stats=ffn.core.GroupStats(indexes)
stats.stats.loc['three_year']
0.1671192
indexes.tail(37)
....
pow(206.42999/132.43004,1/3.0)-1.0
0.15947688146798633
As you see, the three year return ending Mar 15 doesnt match; it doesnt seem related to the earlier date issue as well; the returns for other horizons (i checked one and 5 yr) seem alright
If i try the same code for 3 year ending April 15, the 3 yr returns are quite close -
indexes=ffn.get('spy').to_monthly()[:'2015-04']
indexes.tail(37)
pow(208.46001/131.54597,1/3.0)-1.0
0.165865369061164
stats=ffn.core.GroupStats(indexes)
stats.stats.loc['three_year']
0.1659879
Am i missing something here?
Regards
Siva
from ffn.
Hey @sivananth,
Thanks for the feedback.
The code is basically looking at the last date (2015-03-31) and subtracting 3 years from it. This leaves us with the date 2012-03-31 - let's call it t0. Once it has that date, it takes a slice of the initial price series from t0 until the end representing the last 3 years of data.
In this case, it appears that 2012-03-31 was not a trading day, so the last day of that month was actually 2012-03-30. Therefore, 2012-03-30 is not included in the filtered price series and the numbers are off since the first day in the slice is 2012-04-30.
This issue is tricky to solve. If we knew we always had monthly data, it would be easy to fix, but this is not the case. The code must remain flexible to support any kind of frequency and as of now, this frequency is unknown.
I'm open to ideas on how to solve this issue. You can look at the code in PerformanceStats._update
for a better idea on how this all works.
Hope this helps,
Phil
from ffn.
Hi @pmorissette
I'm a rookie coder, but one option i usually fall back when the periods are not known in advance is to use pandas resample to daily frequency (or the frequency you require), and then work on the calculation (like trailing returns).
I've a minor request - is it possible to include the max drawdown period also, in addition to max drawdown? MSCI factsheets show the drawdown period for their major indexes (https://www.msci.com/resources/factsheets/index_fact_sheet/msci-world-index.pdf)
Thanks a lot for your contribution!
from ffn.
Hey @sivananth,
You can obtain detailed drawdown information (start date, end date, duration and drawdown) by using the ffn.drawdown_details
function.
A quick example:
spy = ffn.get('spy', start='2000-01-01').spy
# get details
dd = ffn.drawdown_details(spy.to_drawdown_series())
# find details for max drawdown
dd[dd.drawdown == dd.drawdown.max()]
Hope this helps,
Phil
from ffn.
Firstly, many apologies if this is not the correct place for this question, and also want to say how awesome this module is!
I am able to use the GroupStats and PerformanceStats objects and their associated methods, however whenever I try to use anything from the API under the ffn.core area, I just get error messages telling me:
"'module' object has no attribute xyz"
For example I am trying to use the "calc_calmar_ratio" function - I have tried importing ffn, importing ff.core, using "from ffn import" and all sorts but I can not get it to work.
Could you please help me to use the ff.core functions as your module is a life saver!
many thanks.
from ffn.
Related Issues (20)
- What changes when I change TRADING_DAYS_PER_YEAR ? HOT 1
- Is there a forum, slack group, or discord for bt and ffn? HOT 1
- ffn plot on pycharm HOT 1
- TypeError: string indices must be integers HOT 4
- TypeError: string indices must be integers HOT 1
- divide by zero encountered in true_divide
- Cannot fetch data
- Is ffn still working?
- Basic example on fetching data fails with TypeError (Python 3.11 and 3.11.2) both on Macos and Linux Ubuntu 22.04 HOT 1
- How can I correct this error? HOT 2
- Ulcer Index not according to definiton (miscalculation)
- ImportError: cannot import name 'Panel' from 'pandas'
- Add yfinance.pdr_override() to readme example
- yfinance dependency triggers import fail in downstream project
- Code improvement _erc_weights_slsqp > fitness function
- TypeError from ufunc `isinf` in `calc_inv_vol_weights`
- importing ffn is changing matplotlib settings
- in python 11,there are some warnings about ffn HOT 1
- Please give a way to define a custom data source
- Shorts?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ffn.