askmike / gekko

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

1m talib breaking candle start #751

Closed thegamecat closed 7 years ago

thegamecat commented 7 years ago

This is what a non talib output of the variable candle looks like: { [Number: 1493917260000] _i: 1493917260000, _f: undefined, _l: undefined, _strict: undefined, _isUTC: false,

start: { [Number: 1493917320000] _i: 1493917320000, _f: undefined, _l: undefined, _strict: undefined, _isUTC: false, _pf:

Note the second candle Number and _i is 60 seconds after the first. IE this is correct.

However, with a talib indicator you get:

start: { [Number: 1493342100000] _i: 1493342100000, _f: undefined, _l: undefined, _strict: undefined, _isUTC: false, _pf:

start: { [Number: 1493342100000] _i: 1493342100000, _f: undefined, _l: undefined, _strict: undefined, _isUTC: false, _pf:

Note, Number and _i are identical, there is no sequence. This only happens with talib strategies.

Now, the interesting thing is, if I check the candle variable in tradingAdvisor it is correct. So something is altering that Number and _i to be incorrect, but I can't find where.

Any chance this could be fixed, would really help.

askmike commented 7 years ago

The _i are internal properties of the moment object. You shouldn't use and call these at all. You should only use public methods found in the docs.

Do you have a problem with the dates coming out of the moment object in any way? Eg. the format method, the unix method or the toDate method?

thegamecat commented 7 years ago

But that cannot be the issue. In all other candle sizes the time / date are correct. It only fails in 1 minute.

Indeed I tracked the candle start params through the trading advisor and they are all correct. Yet between that and the emit, when backtesting, 1m candle date times become broken.

To illustrate how bizarre this behaviour is I have just edited the basetradingmethod.js to write out the readable datetime and the timestamp into new candleprop variables and guess what, now I have the right date time.

this.candleProps.timestamp.push(candle.start.Number);
this.candleProps.readtimestamp.push(candle.start._d);

Ok so not even that works. For some reason all values on 1m candle get broken into something like:

1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029900000 1495029960000

Just so odd.

thegamecat commented 7 years ago

Further oddness. This is in baseTradingMethod.js:

console.log(this.candleProps.stimestamp[this.candleProps.stimestamp.length-1]);

This returns correctly.

This is in my talib strategy:

console.log(this.candleProps.stimestamp[this.candleProps.stimestamp.length-1]);

This does not return correctly.

What is happening to these values.....

askmike commented 7 years ago

Can you post example code of a strategy that does not work as expected?

Also post what version of gekko you are using (the commit hash) please!

thegamecat commented 7 years ago

Any version of gekko from when I started playing with, circa last 5 months I guess. But to be clear I've just done a fresh install to demonstrate the problem, from the master not dev branch.

Put this line in the check function of the gekko default talib-macd strategy:

console.log(this.candle.start._i +" - "+ this.candle.start._d);

So it reads as:

method.check = function(candle) { console.log(this.candle.start._i +" - "+ this.candle.start._d); var price = candle.close;

Use the UI, set talib-macd to 1m candles and default everything and watch the console. This is what I see as an example:

1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493906100000 - Thu May 04 2017 14:55:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493909100000 - Thu May 04 2017 15:45:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493912100000 - Thu May 04 2017 16:35:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493915100000 - Thu May 04 2017 17:25:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST) 1493917560000 - Thu May 04 2017 18:06:00 GMT+0100 (DST)

Note: this happens in any talib related strategy. If I make candles anything other than 1m (in the example below I'm running a 1h candle) this is an example of what i see in the console:

1493625960000 - Mon May 01 2017 09:06:00 GMT+0100 (DST) 1493629560000 - Mon May 01 2017 10:06:00 GMT+0100 (DST) 1493633160000 - Mon May 01 2017 11:06:00 GMT+0100 (DST) 1493636760000 - Mon May 01 2017 12:06:00 GMT+0100 (DST) 1493640360000 - Mon May 01 2017 13:06:00 GMT+0100 (DST) 1493643960000 - Mon May 01 2017 14:06:00 GMT+0100 (DST) 1493647560000 - Mon May 01 2017 15:06:00 GMT+0100 (DST) 1493651160000 - Mon May 01 2017 16:06:00 GMT+0100 (DST) 1493654760000 - Mon May 01 2017 17:06:00 GMT+0100 (DST) 1493658360000 - Mon May 01 2017 18:06:00 GMT+0100 (DST) 1493661960000 - Mon May 01 2017 19:06:00 GMT+0100 (DST) 1493665560000 - Mon May 01 2017 20:06:00 GMT+0100 (DST) 1493669160000 - Mon May 01 2017 21:06:00 GMT+0100 (DST) 1493672760000 - Mon May 01 2017 22:06:00 GMT+0100 (DST) 1493676360000 - Mon May 01 2017 23:06:00 GMT+0100 (DST) 1493679960000 - Tue May 02 2017 00:06:00 GMT+0100 (DST) 1493683560000 - Tue May 02 2017 01:06:00 GMT+0100 (DST) 1493687160000 - Tue May 02 2017 02:06:00 GMT+0100 (DST) 1493690760000 - Tue May 02 2017 03:06:00 GMT+0100 (DST) 1493694360000 - Tue May 02 2017 04:06:00 GMT+0100 (DST) 1493697960000 - Tue May 02 2017 05:06:00 GMT+0100 (DST) 1493701560000 - Tue May 02 2017 06:06:00 GMT+0100 (DST) 1493705160000 - Tue May 02 2017 07:06:00 GMT+0100 (DST) 1493708760000 - Tue May 02 2017 08:06:00 GMT+0100 (DST) 1493712360000 - Tue May 02 2017 09:06:00 GMT+0100 (DST) 1493715960000 - Tue May 02 2017 10:06:00 GMT+0100 (DST) 1493719560000 - Tue May 02 2017 11:06:00 GMT+0100 (DST) 1493723160000 - Tue May 02 2017 12:06:00 GMT+0100 (DST) 1493726760000 - Tue May 02 2017 13:06:00 GMT+0100 (DST) 1493730360000 - Tue May 02 2017 14:06:00 GMT+0100 (DST) 1493733960000 - Tue May 02 2017 15:06:00 GMT+0100 (DST) 1493737560000 - Tue May 02 2017 16:06:00 GMT+0100 (DST) 1493741160000 - Tue May 02 2017 17:06:00 GMT+0100 (DST) 1493744760000 - Tue May 02 2017 18:06:00 GMT+0100 (DST) 1493748360000 - Tue May 02 2017 19:06:00 GMT+0100 (DST) 1493751960000 - Tue May 02 2017 20:06:00 GMT+0100 (DST) 1493755560000 - Tue May 02 2017 21:06:00 GMT+0100 (DST) 1493759160000 - Tue May 02 2017 22:06:00 GMT+0100 (DST) 1493762760000 - Tue May 02 2017 23:06:00 GMT+0100 (DST) 1493766360000 - Wed May 03 2017 00:06:00 GMT+0100 (DST) 1493769960000 - Wed May 03 2017 01:06:00 GMT+0100 (DST) 1493773560000 - Wed May 03 2017 02:06:00 GMT+0100 (DST) 1493777160000 - Wed May 03 2017 03:06:00 GMT+0100 (DST) 1493780760000 - Wed May 03 2017 04:06:00 GMT+0100 (DST) 1493784360000 - Wed May 03 2017 05:06:00 GMT+0100 (DST) 1493787960000 - Wed May 03 2017 06:06:00 GMT+0100 (DST) 1493791560000 - Wed May 03 2017 07:06:00 GMT+0100 (DST) 1493795160000 - Wed May 03 2017 08:06:00 GMT+0100 (DST) 1493798760000 - Wed May 03 2017 09:06:00 GMT+0100 (DST) 1493802360000 - Wed May 03 2017 10:06:00 GMT+0100 (DST) 1493805960000 - Wed May 03 2017 11:06:00 GMT+0100 (DST) 1493809560000 - Wed May 03 2017 12:06:00 GMT+0100 (DST) 1493813160000 - Wed May 03 2017 13:06:00 GMT+0100 (DST) 1493816760000 - Wed May 03 2017 14:06:00 GMT+0100 (DST) 1493820360000 - Wed May 03 2017 15:06:00 GMT+0100 (DST) 1493823960000 - Wed May 03 2017 16:06:00 GMT+0100 (DST) 1493827560000 - Wed May 03 2017 17:06:00 GMT+0100 (DST) 1493831160000 - Wed May 03 2017 18:06:00 GMT+0100 (DST) 1493834760000 - Wed May 03 2017 19:06:00 GMT+0100 (DST) 1493838360000 - Wed May 03 2017 20:06:00 GMT+0100 (DST) 1493841960000 - Wed May 03 2017 21:06:00 GMT+0100 (DST) 1493845560000 - Wed May 03 2017 22:06:00 GMT+0100 (DST) 1493849160000 - Wed May 03 2017 23:06:00 GMT+0100 (DST) 1493852760000 - Thu May 04 2017 00:06:00 GMT+0100 (DST) 1493856360000 - Thu May 04 2017 01:06:00 GMT+0100 (DST) 1493859960000 - Thu May 04 2017 02:06:00 GMT+0100 (DST) 1493863560000 - Thu May 04 2017 03:06:00 GMT+0100 (DST) 1493867160000 - Thu May 04 2017 04:06:00 GMT+0100 (DST) 1493870760000 - Thu May 04 2017 05:06:00 GMT+0100 (DST) 1493874360000 - Thu May 04 2017 06:06:00 GMT+0100 (DST) 1493877960000 - Thu May 04 2017 07:06:00 GMT+0100 (DST) 1493881560000 - Thu May 04 2017 08:06:00 GMT+0100 (DST) 1493885160000 - Thu May 04 2017 09:06:00 GMT+0100 (DST) 1493888760000 - Thu May 04 2017 10:06:00 GMT+0100 (DST) 1493892360000 - Thu May 04 2017 11:06:00 GMT+0100 (DST) 1493895960000 - Thu May 04 2017 12:06:00 GMT+0100 (DST) 1493899560000 - Thu May 04 2017 13:06:00 GMT+0100 (DST) 1493903160000 - Thu May 04 2017 14:06:00 GMT+0100 (DST) 1493906760000 - Thu May 04 2017 15:06:00 GMT+0100 (DST) 1493910360000 - Thu May 04 2017 16:06:00 GMT+0100 (DST) 1493913960000 - Thu May 04 2017 17:06:00 GMT+0100 (DST)

This is on OSX and Bash on windows and Ubuntu 16.04.

As mentioned previously, my goal is the timestamp for each candle as it's stored in the db.

askmike commented 7 years ago

The code that stores candles in a DB is very different code flow, but as I said before:

Do you have a problem with the dates coming out of the moment object in any way? Eg. the format method, the unix method or the toDate method?

If you want the unix timestamp of a moment object, use date.unix() - if you want to format, use date.format(). Internal moment properties (everything that starts with a _) can not be relied upon.

I still don't understand what problem you are having?

As mentioned previously, my goal is the timestamp for each candle as it's stored in the db.

If this is the thing you want to do, why are running talib strategies? Just disable the tradingAdvisor so Gekko doesn't even run this code.

thegamecat commented 7 years ago

I'm completely confused...

1) A strategy receives candles to do something with.

2) As I apply my strategy logic to each candle / tick / whatever I want to know the candle time, which is obviously what should be in _i _d.

3) This works perfectly except when using 1m candles and a talib strategy.

If you follow the instructions I've posted above you'll see the issue.

Now, if _i and _d cannot be relied upon what you're actually saying is there is candle data which is simply wrong. Which then spawns another couple of questions:

1) How do I get the candle timestamp inside the strategy?

2) What else can't be relied upon?

askmike commented 7 years ago

As I apply my strategy logic to each candle / tick / whatever I want to know the candle time, which is obviously what should be in _i _d.

You cannot rely on _i and _d to represent anything! These are internal properties of a moment object, that together with other internal properties represent a moment in time. If you want to know the timestamp you should not use _i or _d but candle.start.unix() instead!

thegamecat commented 7 years ago

this.candle.start.unix() is broken and does not increment on 1m

1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493558100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100 1493561100

However, if I put: console.log(candle.start.unix());

Into the method.update = function(candle) { it works, I'll test using this rather than check!

Thanks for your patience :P

askmike commented 7 years ago

great, so I guess this is solved!

thegamecat commented 7 years ago

Yep! Thanks