Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

EMA Calculation incorrect using Warm-up data #1206

Closed
Guceri opened this issue Oct 13, 2017 · 5 comments
Closed

EMA Calculation incorrect using Warm-up data #1206

Guceri opened this issue Oct 13, 2017 · 5 comments
Labels

Comments

@Guceri
Copy link

Guceri commented Oct 13, 2017

Note: for support questions, please join our Discord server

  • I'm submitting a ...
    [x] bug report
    [ ] feature request
    [ ] question about the decisions made in the repository

  • Action taken (what you did)
    I run gekko using command line so that it can stitch together historical data so that I can use EMA's for my strategy

  • Expected result (what you hoped would happen)
    I log the EMA value to the console so that I can track the result of the EMA on each candle.
    I currently export the SQLITE database into a CSV and run the same strategy on the Tradestation platform as a quality control check. I check to see that the console value matches the one in Tradestation.

  • Actual result (unexpected outcome)
    The value of the EMA's when gekko starts are incorrect. I am not sure why, but they do not match with what Tradestation shows (the database is the same and the EMA calcs are the same). I currently run 2 EMA's (a short and a long).

Both the long and the short EMA eventually become correct and in sync with what they should be, but this is dependent on getting data while in live mode. For example, a 10 candle EMA will be accurate once gekko has been running live for 10 candles..... but it should be correct from the moment gekko starts using the command line, no? It should be able to pull historical data and give an accurate value.

Given that the values do eventually become accurate, I believe the bug has to do with calculating values with data that is both historical (in the database) and new data that comes in while gekko is running live.

  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc)
@Guceri
Copy link
Author

Guceri commented Oct 13, 2017

I realize there is another bug report similar to this issue that I am having. I think the bug report is different, but possibly the root underlying cause is the same? I am not sure. I didn't quite understand the issue that was submitted, so I posted my own. This might be a duplicate issue.

@askmike
Copy link
Owner

askmike commented Oct 18, 2017

What do you mean with inaccurate? Could you provide logs or numbers (including the dataset & EMA parameters to reproduce)?

@Guceri
Copy link
Author

Guceri commented Oct 18, 2017

Let me go through the issue in chronological order to show the issue. Please let me know if there is any confusion.

Setup:
Exchange: GDAX
Product: BTC
Candle Size : 5 Min
EMA 1 Length: 13
EMA 2 Length: 125

Scenerio:
I have been running my strategy for at least 12 hours so far (it was on overnight).
Picture #1: This is a screenshot of my console of the data that is printed on each new candle. Please notice a couple things. First, the time stamp is 11:10:19. Second, 'myEMA' is the 125 candle EMA and 'tradeEMA' is the 13 candle EMA

Picture #2: This is a picture of the data that was exported from SQLITE and into Tradestation (3rd party software). Please note the time stamp of 11:10. There are TWO EMA outputs on the screen for 11:10 which are 5327.62 and 5207.99. These values are calculated in Tradestation (not Gekko). The only thing I pulled from Gekko was the data.

Observation. If you compare Picture #1 and Picture #2 you will see that the 11:10 time stamp show identical values (there is a small rounding error for the 125 min candle, but that is not a big deal). At this point, everything looks good and the quality control check shows that the data calculations are accurate.

Picture #3:
I stopped Gekko and restarted it.

Picture #4:
Once Gekko was initialized and the update function in the strategy fired, I was able to get a console print of the new values at 11:25:08. Please note the values of 'myEMA' (5320.06) and 'tradeEMA' (5209.07).

Picture #5:
I pulled the data from the gekko database again and imported it into Tradestation, please look at the 11:25 time stamp for the 2 EMA's. You will see 5322.14 and 5209.07. The data is the same (you can look at the 11:10 time stamp and it is the previous values from picture 2).

In this real time example, the error in calculation of the 125 candle EMA is 5322.14 vs 5320.06. This is actually smaller then I have seen before and I believe it has to do with the fact that I stopped gekko and started it within a few seconds (see picture #3). This is not the case in real life when I may stop it for 5 or 10 minutes while I make updates.....the difference in the EMA value can be 10-20 points sometimes.

Hopefully this helps in some way. Let me know if you need me to test anything or provide extra info. Thanks again for all the hard work with this. It's a great program.

1
2
3
4
5

@Guceri
Copy link
Author

Guceri commented Oct 24, 2017

Anyone have any thoughts on why this may be happening? I think the issue could potential be effecting the true values of all the TA indicators that are being used.

@stale
Copy link

stale bot commented Oct 24, 2018

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. If you feel this is very a important issue please reach out the maintainer of this project directly via e-mail: gekko at mvr dot me.

@stale stale bot added the wontfix label Oct 24, 2018
@stale stale bot closed this as completed Oct 31, 2018
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants