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.37k stars 823 forks source link

Saving TBP doesn't work -> Bitfinex (and other small bugs) #51

Closed Camille92 closed 7 years ago

Camille92 commented 7 years ago

Hi Carles,

After numerous testing, it seems that TBP is not saved (or maybe saved but not used) when using K on Bitfinex.

Here is how you can do a test -> if I run "npm restartall", the tbp will go back to its default position of half-half. Can you replicate that?

And now for small bugs: _ cleaning K memory doesn't seem to work :/ It also doesn't work with the "original" modes and seems to sometimes mess up with stability. Maybe it can be a good idea to just clean the orders at the bottom of the list (closed or not) if the number of lines > Kmemory). Tell me what you think!

_ There is no explanation on why K is not trading if "MaxSize" is on.

teddytomas commented 7 years ago

Hi, I was going to raise a new issue, but this may be best place. On bitfinex I am seeing orders placed far from the price I expect. EG my fair value mid is 2299. I have a with of 2. I have tried with mid, inverse join, inverse top, top, ping pong. All of them place a bid order at 2285.4. There are no logs I can give, but it seems like something is getting cached/stuck for the bid price.

It does not happen when you first switch it on, but after a few hours it consistently starts to happen. I have to restart to get it to respect the width correctly.

Its as if its got stuck in a ping pong mode maybe ? (although I dont fully understand ping pong)

lejacobroy commented 7 years ago

I have about the same problem as @applet: i’m trading EOS/USD on Bitfinex and it seems to get stuck after a few hours, trying to trade at a old FV even when the market has shifted.

Strangely, I tried trading on ETH/USD and it’s ben working like a charm.

ctubio commented 7 years ago

i can try to replicate the TBP issue on Bitfinex laterz, about the other topics im sorry i either dont care or dont have time (remember im rewriting everything, so ima not gonna invest time fixing code that is going to be rewrited soon) :dancer:

Camille92 commented 7 years ago

No probs, keeping tbp is the most important to resist to strong movements imho!

teddytomas commented 7 years ago

Hi Carles, thats totally fine with me :-) I was reporting in case you wanted to do something about it. I can create my own branch from your hard work - thank you so much for sharing in the first place !

Didnt realize you had pulled the trigger on a complete re-write. Good luck with it.

cheers

On 11 July 2017 at 14:13, Carles Tubio notifications@github.com wrote:

i can try to replicate the TBP issue on Bitfinex laterz, about the other topics im sorry i either dont care or dont have time (remember im rewriting everything, so ima not fix code that is going to be rewrited soon) 💃

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ctubio/Krypto-trading-bot/issues/51#issuecomment-314438955, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUyxH-9zaHB4WiW9fb77guF8OP6eiWKks5sM3TkgaJpZM4OUCI_ .

Camille92 commented 7 years ago

@applett @lejacobroy just a few reasons that come to my mind: (yep some of them are dumb)

Did you check that no protection is on? Did you try to put web UI delay to 0? _ Did you check if the computer you're using K on has enough resources (free -m to check ram and top to check CPU usage).

teddytomas commented 7 years ago

Hi Camille,

_ Did you check that no protection is on? I've tried most of the settings on and off. apr is off, bw is off, sop is off. Specifically which one pls ?

_ Did you try to put web UI delay to 0? yes, 0,1,3,5,10. It continually places the same order even after you cancel it at any refresh rate. Sometimes it is not placing any order for periods of time too... which I'd probably need logs to diagnose.

_ Did you check if the computer you're using K on has enough resources (free -m to check ram and top to check CPU usage). yes. The system is mostly idle with 2 instances of K running.

top - 14:17:01 up 10 days, 21:18, 1 user, load average: 0.51, 0.50, 0.47 Tasks: 130 total, 2 running, 128 sleeping, 0 stopped, 0 zombie %Cpu(s): 23.3 us, 3.3 sy, 0.0 ni, 72.8 id, 0.5 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 4045212 total, 1549860 free, 336244 used, 2159108 buff/cache KiB Swap: 0 total, 0 free, 0 used. 3382600 avail

is it always exactly as expected for you ? I'm trying with the simplest of settings so that I can more easily spot any wierdness

On 11 July 2017 at 14:47, Camille92 notifications@github.com wrote:

@applett https://github.com/applett @lejacobroy https://github.com/lejacobroy just a few reasons that come to my mind: (yep some of them are dumb)

Did you check that no protection is on? Did you try to put web UI delay to 0? _ Did you check if the computer you're using K on has enough resources (free -m to check ram and top to check CPU usage).

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ctubio/Krypto-trading-bot/issues/51#issuecomment-314448819, or mute the thread https://github.com/notifications/unsubscribe-auth/ABUyxD_zzskdoYiDtU5yq3CEr1mTXAapks5sM3z5gaJpZM4OUCI_ .

Camille92 commented 7 years ago

_ Did you check that no protection is on? I've tried most of the settings on and off. apr is off, bw is off, sop is off. Specifically which one pls ?

Specifically ewma, stdev, bw? and BB, maybe apr.

_ Did you try to put web UI delay to 0? yes, 0,1,3,5,10. It continually places the same order even after you cancel it at any refresh rate. Sometimes it is not placing any order for periods of time too... which I'd probably need logs to diagnose.

Maybe it's hitting your trade per second limit?

_ Did you check if the computer you're using K on has enough resources (free -m to check ram and top to check CPU usage). yes. The system is mostly idle with 2 instances of K running.

top - 14:17:01 up 10 days, 21:18, 1 user, load average: 0.51, 0.50, 0.47 Tasks: 130 total, 2 running, 128 sleeping, 0 stopped, 0 zombie %Cpu(s): 23.3 us, 3.3 sy, 0.0 ni, 72.8 id, 0.5 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 4045212 total, 1549860 free, 336244 used, 2159108 buff/cache KiB Swap: 0 total, 0 free, 0 used. 3382600 avail

Looks good!

ctubio commented 7 years ago

i think the issue is the first calculations (from the db seems to come nice but later its firstly wrong calculated):

K.linux.57
DB /data/db/K.2.0.82.db loaded OK
UI ready over HTTPS on external port 9333
17:29:04.293 broker Exchange details { exchange: 'OkCoin',
  pair: 'BTC/USD',
  minTick: 0.01,
  minSize: 0.01,
  makeFee: 0.001,
  takeFee: 0.002,
  hasSelfTradePrevention: false }
17:29:04.303 tbp Loaded from DB: { data: 0.04810368333819702, time: 2017-07-11T16:24:52.708Z }
1 UI currently connected, last connection was from ::ffff:
17:29:05.274 active Changed quoting mode to true
17:29:05.302 stdev Unable to compute value
17:29:05.529 okcoin Successfully connected to login
17:29:05.529 okcoin Successfully connected to addChannel: ok_sub_spotusd_btc_depth_20
17:29:05.532 okcoin Successfully connected to addChannel: ok_sub_spotusd_btc_trades
17:29:18.400 main Event loop delay 300ms
17:29:34.552 tbp recalculated 0.029167005228610505

(first is 0.04810368333819702 but soon later is recalculated as 0.029167005228610505)

do you see the same in Bitfinex? (note i was 1h offline from okcoin)

ctubio commented 7 years ago

sorry the tbp log on boot is displayed since ^this last commit

Camille92 commented 7 years ago

Hey thanks for that Carles, so now I have more details, K saves correctly TBP but does not use it.

12:10:40.621 tbp Loaded from DB: { data: 0.7223539248401182, time: 2017-07-12T12:07:52.736Z }
12:10:40.757 active Changed quoting mode to true
12:10:40.758 bitfinex Bitfinex info: { event: 'info', version: 2 }
12:10:40.855 bitfinex Successfully connected to trades
12:10:40.886 bitfinex Authentication status: OK
12:10:41.558 bitfinex Successfully connected to book
12:10:56.801 tbp recalculated 0.3276820222678648
12:10:56.807 tbp recalculated 0.34842914524390245
12:11:27.056 tbp recalculated 0.3218448016872032
12:11:40.627 tbp recalculated 0.3232108357062052
12:11:41.506 tbp recalculated 0.32775432081114186

I don't understand it! Are ewmas saved as well ? What not using it? It seems to be the same problem in your previous post

ctubio commented 7 years ago

moar info at https://github.com/ctubio/Krypto-trading-bot/issues/70

ctubio commented 7 years ago

looks good to me now, many thanks for the suggestions, let me know if you miss anything :dancer:

i left commented the detailed log at https://github.com/ctubio/Krypto-trading-bot/blob/master/src/server/position-management.ts#L98

Camille92 commented 7 years ago

Thankkkss I'm going to run the big update :)

Now we can ride waves without fear ! :)