Giter Club home page Giter Club logo

Comments (6)

pmorissette avatar pmorissette commented on July 22, 2024

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.

sivananth avatar sivananth commented on July 22, 2024

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.

pmorissette avatar pmorissette commented on July 22, 2024

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.

sivananth avatar sivananth commented on July 22, 2024

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.

pmorissette avatar pmorissette commented on July 22, 2024

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.

Stuj79 avatar Stuj79 commented on July 22, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.