gekkowarez / gekkoga

Genetic Algorithm for solving optimization of trading strategies using Gekko
313 stars 104 forks source link

Feature Request - mainObjective #40

Open jimharkins opened 6 years ago

jimharkins commented 6 years ago

If possible please consider adding Sharpe Ratio as a mainObjective.

// profit || score || sharpeRatio

mainObjective: 'sharpeRatio',

Thanks

0xPBIT commented 6 years ago

Relying on the sharpe ratio probably isn't the best idea, at least during this implementation. I get "null" for my sharpe ratio pretty often.

generalectric commented 6 years ago

I believe currently gekkos Sharpe implementation has been reported as flawed so at the moment until that gets addressed and the restructure coming up starting with 0.6 there's not really much to do but wait and see what changes in 0.6 and then fix gekkoga to work again and hopefully a pr for the Sharpe ratio will be in if in fact there is a problem with gekkos Sharpe calculations.

jimharkins commented 6 years ago

Thanks for replying. I was not aware of the Sharpe issue.

Great program! it's running on three different machines of mine right now.

On Wed, Apr 18, 2018 at 12:11 PM generalectric notifications@github.com wrote:

I believe currently gekkos Sharpe implementation has been reported as flawed so at the moment until that gets addressed and the restructure coming up starting with 0.6 there's not really much to do but wait and see what changes in 0.6 and then fix gekkoga to work again and hopefully a pr for the Sharpe ratio will be in if in fact there is a problem with gekkos Sharpe calculations.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gekkowarez/gekkoga/issues/40#issuecomment-382460586, or mute the thread https://github.com/notifications/unsubscribe-auth/AGuVZ-PdRMjykchS25En2LJ6K-V5sRqAks5tp3OmgaJpZM4TVuR0 .

stereohelix commented 6 years ago

Sharpe ratio proper is the risk-free return divided by the expected variance per year. Gekko currently calculates this ratio per trade. It's still a useful measurement, but optimizing it in its current form isn't a meaningful indicator that your strategy is good.

For example, suppose you traded twice for exactly 1% profit in one year. The proper Sharpe ratio would be negative, because you get a lower return than a risk-free bond. But Gekko would report your Sharpe ratio as undefined, because the variance of your two trades is zero, so the inverse gives a divide by zero.

I have some ideas in the works for risk-based optimization and plan on submitting another pr on this for 0.6.

By the way, my name is Jim too.

Cheers!

stereohelix commented 6 years ago

Sharpe is currently fixed in the upcoming gekko 0.6 fork.

I'm running this locally with a configurable objective that weighs profits, sharpe ratio, sortino ratio, and "exposure ratio" -- just the ratio of profits against exposure time. I'll submit a PR as soon as gekkoga works with gekko 0.6.

generalectric commented 6 years ago

@stereohelix that's awesome! I haven't had any time to play with gekko lately. I have been anticipating 0.6 to come out and was aware that it would brake gekkoga, thanks @askmike! I will have to get around to it Sunday hopefully.

stereohelix commented 6 years ago

It's probably not a rush -- there are still several items in 0.6 that need to be resolved before it gets merged to stable.

Just a friendly update here, I'm excited to see what this will do for gekkoga performance.