ctubio / Krypto-trading-bot

Self-hosted crypto trading bot (automated high frequency market making) written in C++
https://127.0.0.1:3000
Other
3.33k stars 819 forks source link

Reforming EWMA LMS with take profit option + minor improvement idea #181

Open Camille92 opened 7 years ago

Camille92 commented 7 years ago

Hello Carles and everyone,

I think the formula I proposed with LMS is definitely not the best (leading to a low rate of adoption). The problem is that two couple of ewma are "fighting" to change TBP which can result in unpredictable behavior and potentially dangerous one in strong market conditions or quick reversal.

I want to propose an update to this mode that will include the take profit idea that @CarlitoGrey developed here: https://github.com/ctubio/Krypto-trading-bot/issues/58

What is needed for this update:

Renaming the ewma and the option To keep long and short and the last one "Take profit" Having a new option called "Take profit", a number (or a % in % option is activated).

The formula would change to be:

If ewma take profit > SMA3 newTargetPosition = ((mgEwmaS 100/ mgEwmaL) - 100) (1 / qpRepo["ewmaSensiblityPercentage"]

If ewma take profit < SMA3 new TargetPosition = ((mgEwmaS 100/ mgEwmaL) - 100) (1 / qpRepo["ewmaSensiblityPercentage"] - Take_profit_calc.

Take profit calc being the number calculated from what's in the web ui translated in the -1 / 1 range of TP. So if the percentage option is activated: Take_profit_calc = (Take profit 2 / 100) - 1 If it's a value in crypto: take_profit_calc = (Take profit 2 / total_Base_position) - 1

The idea if that if you put 10% in your take profit settings, your TBP will be equal to a maximum of 90% of your stack if ewma take profit is under SMA3. If you put 100% your TBP will be equal to 0 even if the Ewma short is way above ewma long.

Lastly, one image to show you how it works in a chart:

telechargement 1

You can see here how using a shorter ewma for your take profit option that you'll get some of your funds out at each step, reducing the risk in case of reversal.

Also when the highest level is reached, you start to sell way before ewma LS are reversing and sell some of your LTC nearly at the top!

I hope you like it and I think it's way better to do it like that than having the current ewma LMS.

Ps: When ASP will be included in the code, it's interesting to link that to this option, so that if someone is using ewma LSTP, ASP will be deactivated when ewma TP < SMA3.

Lastly one small improvement for @ctubio: It's a big annoying for you I think to manually add all the currencies accepted, why not allowing all possible combination of 3 or 4 letters so you don't have to add a coin each time a new one is listed on one exchange?

Best and happy trading,

Camille

ctubio commented 7 years ago

so is like a protection to TBP?

Camille92 commented 7 years ago

It's more like a way of getting some (or all your funds) out after a big rise and before the ewma are crossing.

It's a bit faster and less risky than ewma LS and hopefully you can sell a bit higher as well.

spudstr commented 7 years ago

this doesn't sound very hard to implement...