Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Small Improvement / bug correction: TBP on boot seems wrong #27

Closed
Camille92 opened this issue Jun 27, 2017 · 17 comments
Closed

Small Improvement / bug correction: TBP on boot seems wrong #27

Camille92 opened this issue Jun 27, 2017 · 17 comments

Comments

@Camille92
Copy link
Contributor

Camille92 commented Jun 27, 2017

Hello Carles,

A very small issue (but that can sometimes have rather big consequences) is that on boot /reboot etc and before K checks mongod to see if ewma are recorded to determine TBP (t+1mn) , it will show medium TBP.

The problem is that if you have permissive trade /seg settings, you can end up selling or buying everything during that 1mn period.

So to fix the issue, would that be possible to check the database if there are EWMA recorded and use them as the starting point on boot instead of waiting 1mn ?

What do you think ?

Best Camille

@Camille92 Camille92 changed the title Small Improvement / bug correction: Small Improvement / bug correction: Getting data from mongod on boot Jun 27, 2017
@ctubio
Copy link
Owner

ctubio commented Jun 27, 2017

Hello Camille,
the app already on boot the first think it does it to get from database and put in use the values of the periods of the ewma sequence (and also other inital data).

I do believe also the app doesnt start (it literally waits for) trading if market data or safeties or tbp is still not loaded.

can you please explain again what consequences are you experimenting? (cos i think i never experiencied that; and we can search for a soluton once we understand the problem :P)

@ctubio
Copy link
Owner

ctubio commented Jun 27, 2017

you meaaaan that the first "tbp recalculated" is wrong? (as seen in the logs on boot?)

@Camille92
Copy link
Contributor Author

Yes I give you an example (I thought I wrote it before but apparently not).

So let's say the market is down, to TBP = 0, then for a reason X or Y K stops and forever restarts it again.

Then during minute 1 tbp will be equal to half the BTC I can buy, so during this minute APR will be on and K will try to buy as much as possible.

Then after the minute is gone, it goes back in place but I already bought in a market going down and chances are the market went even more down so I'm at a lose.

@ctubio
Copy link
Owner

ctubio commented Jun 27, 2017

iSee, i think i noticed too; i will investigate for a fix'¡ 💃

@ctubio
Copy link
Owner

ctubio commented Jun 27, 2017

we are talking only about the first second, no? later after 1 second all is OK right?
thanks for confirm'¡

@Camille92
Copy link
Contributor Author

Nope first minute last time I checked (until tpb is updated)

I would run a test normally but as the market is moving so fast I prefer to wait haha

@ctubio
Copy link
Owner

ctubio commented Jun 27, 2017

aaand this was in GDAX? or Bitfinex? or both? :P

@Camille92
Copy link
Contributor Author

Bitfinex! but both in my memories :)

@Camille92
Copy link
Contributor Author

I'm actually not sure if K keeps correctly TBP after a restart on Bitfi!

@Camille92
Copy link
Contributor Author

Camille92 commented Jun 28, 2017

Hello Carles,

I can confirm you after some tests that TBP is not saved after restart on Bitfinex (even after 1mn).

So when it crashes it goes back to calculating TBP from scratch!

Mongo version 3.4.5
Node version: 7.10

@Camille92
Copy link
Contributor Author

Hello Carles,

I ran some tests this morning, so the problem persists with SqLite -> K doesn't keep track of ewma after a restart :S

@ctubio
Copy link
Owner

ctubio commented Jun 29, 2017

yea have nothing to do with the database, will investigate it soOn''
thanks for the reports'¡

@ctubio ctubio changed the title Small Improvement / bug correction: Getting data from mongod on boot Small Improvement / bug correction: TBP on boot seems wrong Jun 29, 2017
@Camille92
Copy link
Contributor Author

Yep I don't get why it's not working, I mean given the way ewma is calculated, we only need to save 1 value for each ewma and update it each minute.

Then on boot, if there is values registered just use them and if not start from the beginning.

But I guess it's the way it's made!

@ctubio ctubio closed this as completed in 03757b6 Jun 30, 2017
@ctubio
Copy link
Owner

ctubio commented Jun 30, 2017

yea your right, i modified many things but basically not only read the values from the database to make the ewmas sequences to survive a restart, but also the tbp value. before we only store fair values and market data, and revive the ewma sequence; but now we also revive tbp.

i play a bit setting the tbp refresh to 1 second instead of 1 minutes; i think is nicer with 1 second, but since im not yet understanding all the implications, i leave it as it was with 1 minute tbp refresh. (but but but since market data and fair values are collected every second, i dont understand very well why should be 1 minute the tbp refresh; to me should be both the same, at 1 second)

@Camille92
Copy link
Contributor Author

well the thing is that ewma value is updated every minute, so if you refresh tpb every second nothing going to change.

We would easily make everything at the second level but then we need to multiply the ewma by 60 and actualize every second.

But tbh I don't think it's necessary it will more be wasting resources and having inconveniently long ewma like ewma 100mn = ewma 6000seconds.

I don't understand why we save FV and market data it looks unnecessary no?

We could just save ewma( short, medium, long etc) latest and use them on the restart, from those we can get the TBP.

And a minute '2' make the calculation again with updated values. :)

@Camille92
Copy link
Contributor Author

Hey Carles,

I ran some tests on the latest versions, and it turns out that TBP is not kept.

Are you having the same thing?

Test protocol:

Letting a K running for a couple of hours so TBP has a clear position.

Then run "npm restartall" to see if TBP is kept.

@Camille92
Copy link
Contributor Author

Dear Carles,

Would you be super nice and do the test on your machine so I can see if the problem comes from my side (maybe because of the root situation) or if it just that it is not 100% fixed for now!

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants