Hi,

I found an important problem (IMHO) with the latest release candidate related to data download from the Broker. Not sure if the problem is with assetHistory or with the broker Plugin (or maybe it's not a problem at all but my problem or my miss understanding) but I am seeing 1 minute gap each time I download new prices. Also in trade mode. I only test this with the Binance Futures plugin.

Steps to reproduce the problem:

Script: Download.c with following config:

Code
#define VERBOSE	7+DIAG

And also I include Outlier = 0; just in case:
Code
void main()
{
...
Outlier = 0;
...

In the Download panel:

NKNUSDT
2021-2021
M1
Ask/Bid
Broker
-> Click Download

From the .diag file:

Code
!Connecting to  websocket...
!Websocket connected.
printf: 
!§s: 1 2901.173600 ms
BrokerTime: 2021-08-31  16:42:06: 2 7.525700 ms
printf:  at UTC §s
Open NKNUSDT  >Save
Open: Log\Assets.csv wb  >Hist  >File History\NKNUSDT_2021.t6  >Prices
Hist 01-01 00:00 .. 08-31 16:42: 388313
printf: 
§s: §i MB allocated
Ticks:
BrokerHistory NKNUSDT: 
HTTP: https://fapi.binance.com/fapi/v1/klines?symbol=NKNUSDT&interval=1m&startTime=1630427819000&endTime=1630428126000&limit=1500,(null),(null)5
printf: 
!§s §s to §s
printf: 
!=> §s to §s, §i ticks 5
printf: 
Load §s 
printf: §d..
Open: History\NKNUSDT_2021.t6 wb
printf:  §i min
Total: 5 207720 0
Raus
Neural
Login BinanceFutures 1->0
printf: 
Logout..


The script loads 5 bars from the broker and add them to the .t6 file. I can see them with History.c script and also with the ZHistoryEditor.

First problem is that the Broker API call returns 6 bars, and it seems that Zorro is not saving the last one. If you paste the above URL (https://fapi.binance.com/fapi/v1/kl...amp;endTime=1630428126000&limit=1500) where:

startTime is Tue Aug 31 2021 16:36:59
endTime is Tue Aug 31 2021 16:42:06

You can see the 6 prices from Binance:

Code
[[1630427820000,"0.44780","0.44780","0.44600","0.44665","89850",1630427879999,"40155.24761",142,"21596","9652.74538","0"],
[1630427880000,"0.44646","0.44666","0.44454","0.44474","92428",1630427939999,"41153.78206",173,"10736","4787.09330","0"],
[1630427940000,"0.44496","0.44640","0.44496","0.44601","103252",1630427999999,"45995.73933",121,"87631","39028.90056","0"],
[1630428000000,"0.44628","0.44633","0.44580","0.44587","11299",1630428059999,"5039.44539",51,"5783","2579.46923","0"],
[1630428060000,"0.44585","0.44607","0.44574","0.44607","10934",1630428119999,"4875.16577",38,"5078","2264.55739","0"],
[1630428120000,"0.44586","0.44593","0.44570","0.44584","6215",1630428179999,"2770.86145",24,"4605","2053.17810","0"]]


First bar is Tue Aug 31 2021 16:37:00
Last bar is Tue Aug 31 2021 16:42:00

But when I check the .t6 file with the ZHistoryEditor I don't see the last bar and prices finish at 16:41 with this bar from binance:

Code
[1630428060000,"0.44585","0.44607","0.44574","0.44607","10934",1630428119999,"4875.16577",38,"5078","2264.55739","0"],


I repeated the same steps 2 minutes later:

Code
!Connecting to  websocket...
!Websocket connected.
printf: 
!§s: 1 2740.935300 ms
BrokerTime: 2021-08-31  16:44:05: 2 9.992100 ms
printf:  at UTC §s
Open NKNUSDT  >Save
Open: Log\Assets.csv wb  >Hist  >File History\NKNUSDT_2021.t6  >Prices
Hist 01-01 00:00 .. 08-31 16:44: 388315
printf: 
§s: §i MB allocated
Ticks:
BrokerHistory NKNUSDT: 
HTTP: https://fapi.binance.com/fapi/v1/klines?symbol=NKNUSDT&interval=1m&startTime=1630428179000&endTime=1630428245000&limit=1500,(null),(null)1
printf: 
!§s §s to §s
printf: 
!=> §s to §s, §i ticks 1
printf: 
Load §s 
printf: §d..
Open: History\NKNUSDT_2021.t6 wb
printf:  §i min
Total: 1 207725 0
Raus
Neural
Login BinanceFutures 1->0
printf: 
Logout..


Zorro loads and save 1 bar (only the first one), but Binance returns 2 bars:

Code
[[1630428180000,"0.44586","0.44606","0.44575","0.44603","12522",1630428239999,"5583.24085",41,"7296","3253.43500","0"],
[1630428240000,"0.44608","0.44674","0.44590","0.44672","26771",1630428299999,"11943.50777",59,"8209","3663.38510","0"]]


The result is a 1 bar gap between each Download call.

I attach a ZHistoryEditor capture (gaps1.jpg). Please note the gap at 16:42, between both Downloads described above. Bar at 16:42 is missing (from the first download call) and also last 16:44 bar is missing.

If I try to Download again, no matter when, Download will start at 16:45 as Zorro thinks that 16:44 is loaded, but it's not. See capture2.jpg.

I also try to download fresh data with assetHistory and OVERRIDE but with same result. First 1500 bars are loaded from Binance, but only 1499 are saved and if I repeat again new ones start 1 minute after the last saved, with the gap in between.

Last example. Log from Trade mode (_real.log) from other Asset:

Code
...
[3304: Tue 21-08-31 16:01c] 47439.56/47450.00\47410.28/47425.61 -0.01
[3305: Tue 21-08-31 16:02c] 47425.61/47472.37\47361.71/47396.98 -0.01
[3306: Tue 21-08-31 16:03c] 47396.98/47464.10\47396.90/47464.10 -0.01
[3307: Tue 21-08-31 16:05c] 47479.74/47547.73\47479.74/47537.50 -0.01
[3308: Tue 21-08-31 16:06c] 47537.50/47550.00\47494.00/47500.55 -0.01
[3309: Tue 21-08-31 16:07c] 47500.55/47501.84\47432.32/47434.01 -0.01
[3310: Tue 21-08-31 16:08c] 47434.02/47452.39\47385.72/47411.86 -0.01
...

End of lookback period
...


Price at 16:04 is missing. I downloaded prices at 16:04 and then I download again few minutes later.

Finally... I also try to download from the Binance API at the same time that I call the API, just to double-check that Binance had the prices at the download time, and the prices were there and can't figure out why Zorro is not saving the last one.

Attached Files gaps1.jpgcapture2.jpg