askmike / gekko

A bitcoin trading bot written in node - https://gekko.wizb.it/
MIT License
10.08k stars 3.93k forks source link

Close, RSI, TALIB indicator don't display real values, depending on when you start the bot #2811

Closed IAMtheIAM closed 5 years ago

IAMtheIAM commented 5 years ago

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

Action taken (what you did) Start bot with the following indicators:

All history IS available according to the bot

The trading method requests 4021 minutes of historic data. Checking availablity..

gekko-mainbot_1 
gekko-mainbot_1  | 
gekko-mainbot_1  |  Usable local data available, trying to match with exchange data..
gekko-mainbot_1  |  Full history locally available. Seeding the trading method with all required historical candles.

Expected result (what you hoped would happen)

Numbers should match those shown on the exchange (Bitfinex, data seen through TradingView.com chart)

candleTimestamp: Mon Jul 01 2019 12:57:00 GMT+0000 (does this mean it got data from the 12:00:00 tick????)

gekko-mainbot_1  |                    closePrice:        $283.00  
gekko-mainbot_1  |                    rsi:           37.76      
gekko-mainbot_1  |                    fastMA:        297.22
gekko-mainbot_1  |                    slowMA:        299.93   

Actual result (unexpected outcome)

Close, RSI, and TALib Moving Averages are completely wrong. The numbers don't match at all on any tick.

Actual exchange numbers (seen on tradingview.com for Mon Jul 01 2019 12:00:00 GMT+0000 for BITFINEX:ETHUSD)

close:           $285.41  
rsi:             37.32      
fastMA:          298.56008
slowMA:          299.81649   

Other information

This problem does not happen so dramatically on a shorter timeframe like 1 minute. The numbers are within a small tolerance of accuracy. But on the 3 hours timeframe, these numbers are way off.

I wonder if the indicators aren't properly warming up, because even though it says full history is available, and I did import the amount of ticks required for the strategy, its possible that the history isn't being properly used to calculate the numbers. However, what worries me is the price is wrong, which is not based on any indicator but direct exchange data.

If not this, then why would my numbers be so far off? Thanks for the help in advance!

IAMtheIAM commented 5 years ago

UPDATE: My initial suspicion about the reasoning was correct. If I start the bot right on the same interval (within a few seconds before the next tick), then the bot numbers correspond exactly to the exchange numbers as viewed on tradingview.com

This means that if the bot is started in between the interval, it will still run at 3 or 4 hours candles, but the data will not match any exchange on the same hour candle due to the start of each candle differing.

I suggest we add a method into gekko config which would instruct the bot to "standby" but not actually start "ticking" the data feed intervals until X specified time in the future. We could say, make sure it starts on any 3 hour interval starting counting from 00:00 UTC. What do you guys think?

IAMtheIAM commented 5 years ago

@askmike

Claudio-F commented 5 years ago

Hey, i have the same problem! Were you able to find the solution?

stale[bot] commented 5 years ago

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.

IAMtheIAM commented 5 years ago

Bot! Don't close the issue. It's still a real problem.

IAMtheIAM commented 5 years ago

@Claudio-F the only solution I found is to schedule the Gekko CLI to start at the next candle tick using the Unix at command. Example: echo "docker-compose up | at 16:00"