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

Improvement: ASP 2.0 #205

Open Camille92 opened 7 years ago

Camille92 commented 7 years ago

Hello everyone, If you don't know what ASP is, please read the post at this link. https://github.com/ctubio/Krypto-trading-bot/issues/59

I know ASP has not yet been implemented in the main code but thanks to the experimental work of @CarlitoGrey and @spudstr I can come to share with you a new, ameliorated version which I believe will be a good way more efficient than the previous one.

1) Conditions to activate ASP:

For ASP LOW the only required condition is to hit a threshold of the difference of ewma long vs ewma short, instance 0 or -0.2. This has the consequence to stop market making in a downtrend market.

For ASP UP it's much more interesting, you need 2 couples of ewma to be activated: first that ewma long < ewma short and a new couple of ewma -> eASP long < eASP short.

I recommend to use way smaller values for eASP long and eASP short than you use for your main TBP ewma.

2) The strength of ASP:

I think it's interesting to use ASP Up not as a nothing or all feature but rather a progressive one. To do so you need to progressively reduce pdiv as much as ewma short is rising above ewma long. The formula that does that can be:

pdiv = (set pdiv) - (set pdiv) (aspvalue / ASP_UP threshold) aspvalue = (ewma short 100 / ewma long) - 100

Of course, if the result is inferior to 0, just need to keep pdiv at 0 (I don't know what happens if the value of pdiv is negative).

So one example using this formula: If the pdiv you set in the web ui is 1 btc, your ASP_Up threshold on the web ui 2 and the difference between the ewma is of 1.5% you get a pdiv of:

pdiv = 1 - 1* (1.5/2) = 0.25

For ASP Low it's just sufficient to lock it under certain conditions, as you don't want to take risks in a downtrend market even if it's going slightly up.

3) Some concrete example:

telechargement 2

You can see here how it would lock pdiv to 0 in the good rising period, while still allowing for market making in the stable period.

4) What's needed to implement it:

In the web ui: 4 new parameters, the ewma short for ASP, the ewma long for ASP, the trigger for ASP up (when pdiv = 0 if all conditions are met) the trigger for ASP low, and maybe a tick box if we want to activate it or not haha.

Loosy translation in code for mg.h copied from the guys:

qpRepo["aspvalue"] = ((mgEwmaS * 100/ mgEwmaL) - 100);

    if aspvalue < ASPLOW || aspvalue > ASPHIGH && eASP Long < eASP Short) )
      {
        mgASPEnabled = true;
        cout << "ASP Enabled" << endl; 
      }
    else 
      {
        mgASPEnabled = false;
        cout << "ASP Disabled" << endl;
      }

This would be to activate or deactivate ASP, I don't know how to do the progressive one but I think you get the idea.

As always don't hesitate to comment and tell me what you think :)

spudstr commented 7 years ago

Easy enough to add.. but the progression you could base off of a stdeviation of fv?

So basically you just need new values: mgASPEwmaS mgASPEwmaL mgASPUp to trigger pDiv calculations/changes? we already have.

asptriggered to see if asp has been triggered.. but it could be triggered on a dUP or down event.

we have aspactive which is the checkbox on the UI to enable/disable it.

Camille92 commented 7 years ago

Yes exactly in your version it just needs the Asp Ewma and the calculation of decreasing pdiv depending on the long term Ewma.

I don't see how the standard deviation of fv would be useful in that case. Maybe you can explain me what's your idea we can talk about it :)

ctubio commented 7 years ago

many many thanks for the up-to-date infos! (and to close the deprecated); lets try to keep the thread technically acceptable (i would like to not have to scroll million comments to know about a given functionality xD)

spudstr commented 7 years ago

@Camille92 i didn't mean stdevFV i just meant on making of some sort of way to create this progressive.. you are talking about progressive