pmorissette / ffn

ffn - a financial function library for Python
pmorissette.github.io/ffn
MIT License
2.03k stars 300 forks source link

Replacing ffn with empyrical and pyfolio #37

Closed JordanPlatts closed 6 years ago

JordanPlatts commented 6 years ago

Maybe we should just use empyrical and pyfolio instead of ffn. @pmorissette @FinQuest What do you guys think?

They seem similar and they have a strong community already. empyrical can replace the generic functions in ffn and pyfolio can replace PerformanceStats. We could still use ffn for calculations that they don't include like calc_mean_var_weights or calc_erc_weights but we wouldn't have to worry about maintaining the portfolio statistics or plots. Over time we could see about contributing any functionality they don't include into their libraries.

I still prefer bt over zipline because it is easier to understand and verify the functionality is correct. Trusting the backtesting tool is essential if you are going to use the results to put money to work.

atisharma commented 6 years ago

I chose bt because of the high readability and elegant code structure. Empyrical seems to share that simplicity.

Pyfoilio seems not to completely cover the functionality of ffn, though, and I having written custom data getters, will I still be able to use them? ffn is also easy to overload / hack.

Pyfolio seems to have some odd choices. For instance, pyfolio/risk.py seems to be entirely equity-specific.

pmorissette commented 6 years ago

I haven't looked at these libraries, so hard to comment right now. That being said, I'm all for not re-inventing the wheel, especially if there is a large community around another library. If the other libraries are more active, then it may just be a question of adding the missing functionality via PRs.

JordanPlatts commented 6 years ago

@atisharma I wouldn't replace anything that messes up your code. In fact, let me try out the libraries some more to understand the what the differences would be. I was just throwing out the idea because the libraries seem to be similar.

FinQuest commented 6 years ago

I think both libraries you suggest are interesting and I like the tear sheet concept from Pyfolio and it would be good to link this to a bt object but then you’d want to ensure empirical was used throughout bt to avoid inconsistent risk calculations.

I don’t know if the portfolio optimisation functionality etc. sits naturally in these libraries so perhaps ffn should use empyrical for the generic functions where relevant?

There seems to be lots of interesting functionality in Quantopian not exposed in Zipline too which I’d be interested in seeing but not necessarily adding.

I very much like the simplicity of bt and challenging to maintain this and evolve the library at the same time. Perhaps experiment in a second branch?

JordanPlatts commented 6 years ago

Totally agree on keeping it consistent and that optimization doesn't really fit in empyrical. I think creating a second branch of bt that uses empyrical calculations is a good idea.

JordanPlatts commented 6 years ago

I just tried to use some tools from empyrical and I gave up after a couple of hours. It just seemed like more work than what it was worth. Instead, I decided to start using more numpy functions like power and replacing pandas std() with numpy std(,ddof=1).

We can revisit this if someone has a different opinion.