Krypto-trading-bot: 💾 💾 Improvement: saving history of price for fast ewma recalculation 💾 💾

Created on 28 Nov 2017  Â·  11Comments  Â·  Source: ctubio/Krypto-trading-bot

Hi Carles and all,

The idea is just to save in the DB the FV every minute during a period of time that we can define in the UI.

The goal is to be able to calculate ewma from there in case we change settings (instead of waiting for a long time).

One example:
So let's say I tell the bot to keep the 2000 past minutes FV and I'm using ewma 200/100.
Then I change my mind and I want to use 1000/500, with the current form, when I change the setting, I have to wait 1000 minutes before the bot is up to date with the correct ewma.

However, if it keeps in the db the FV of the past 2000 minutes, it takes only a few milliseconds for the bot to recalculate the correct ewma from the db. (just need to do the formula 1000 times and 500 times respectively).

I think that's a great plus for everyone that like to try and change their settings from time to time, and of course, if you don't want to use it, just set in the UI 0 and it will not save any data.

What do you think ? 😄

Best,

Camille

genius improvement acknowledged

Most helpful comment

Yes for stdev is it saved each second of the stdev period, but for ewma, we need a relatively long time (and for that reason not at the second level, but at the 1-minute level :) )

All 11 comments

And if a few minutes are missing -> replace the missing minutes by the last value recorded.

So that if you run an update/ reboot for 10 minutes, all your past data are not becoming useless :p

Agree with Camille. Ability to store long periods of ewma will save much time for money making.

just saying, the fairvalue is already saved in the db at https://github.com/ctubio/Krypto-trading-bot/blob/master/src/server/mg.h#L159 each second because https://github.com/ctubio/Krypto-trading-bot/blob/master/src/server/mg.h#L97, ~the recalculation can walk this skipping seconds that does not match the new user defined period~

Yes for stdev is it saved each second of the stdev period, but for ewma, we need a relatively long time (and for that reason not at the second level, but at the 1-minute level :) )

Hi @ctubio
when i see it right, fair value is stored every minute,right? Because in the codlins you posted there is a timer that counts up to 60 every second.
That means we already have the data stored in the DB.
so we just need a routine that recalculates the EWMA´s instead of loading them from the DB on start and on settings change. right?

yea @b-seite as you said stats (and therefore FairValue too) are saved each 60 seconds, that is the execution delay of ewmaUp function

alsoo, all data in the database is loaded on boot, and while running the bot adds data and deletes data to memory and to database at the same time. So at all times the bot and the database have the same information (no need to read data from database while running, ever [the database is supposed to be a golden image in realtime of the memory])

hmm that sound great and makes it quiet easy to realise this improvement.

Should we always recalculate all the ewmas on start? or just on config change? what is jour opinion?

Hey I would say, if from start you have a Ewma value stored already, I
don't see the need to recalculate it.

Le 3 déc. 2017 14:27, "B-Seite" notifications@github.com a écrit :

hmm that sound great and makes it quiet easy to realise this improvement.

Should we always recalculate all the ewmas on start? or just on config
change? what is jour opinion?

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/ctubio/Krypto-trading-bot/issues/439#issuecomment-348768441,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AGizFmU281U7on-aU0Hg9eHwdDXmDT7Zks5s8qHCgaJpZM4Qthx5
.

Okey, hopefully i got it finally.

k collects FairValues every Minute and stores them for one Day ( 1440 values )
it recalculates the four EWMA´s that are calculated every minute with the historical values. If there are values missing, it takes the first available to use it as a dummy.

I also changed the execution point for the first calculation of the live EWMA´s. It was at 60sec. after getting the first book values. Now its immediately... No more uncertain 60sec.

awesome codes b-seite'¡ many thanks for your time'¡ (and thanks Camille for report this'')

nice team work https://www.youtube.com/watch?v=jT-HeoNDr9s

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nonkreon picture nonkreon  Â·  5Comments

Camille92 picture Camille92  Â·  7Comments

werkkrew picture werkkrew  Â·  5Comments

wulabs picture wulabs  Â·  3Comments

Bzzz666 picture Bzzz666  Â·  8Comments