From 2.40.5. As you can see, none of the other tmf events were triggered at 1840. Therefore it must be triggered by a normal tick.
All I am saying is that the TMF execution, regardless of event type, should run AFTER tick() tock(), like it was in v.2.35 and many version before.
The manual says "TMF runs at every tick". Therefore you must allow tick() and tock() to completely finish and provided any pre-processing that is related to that tick. In my case, that pre-processing is loading tick specific options chains, before TMF can run so that the TMF can have all the latest prices associated with that new tick.
In my example below, the UL price ($3816.59) is from time 1840 and the options price is from time 1838 (UL=$3815.3). This is wrong.
Thanks.
Code
[1840] INSIDE myTMF[489449]: priceClose(0)=3816.59
TradeIsEntry = 0
TradeIsStop = 0
TradeIsProfit = 0
TradeIsClosed = 0
2021-03-05,Call,20210308,3810.0,3815.3,32.60,32.10,0.529,773, <------ this option data is from the previous tick at time 1838
ContractBid[32.10] ContractAsk[32.60] TradeStopLimit[27.75]
[4895: 1840] tick priceClose[3816.59]
[4895: 1840] TOCK -- [SPX] Loading chain...
[4895: 1840] TOCK priceClose[3816.59] -- [C:\Zorro\History\SPX-Options\\SPX_202103_m1.t8] 600 contracts loaded...
[4895: Fri 21-03-05 18:40] 860 -1912 5/4 3815.25/3816.59\3815.09/3816.59 -0.01SliderLots = 20
Last edited by SBGuy; 08/19/2115:47.
Re: New Zorro version 2.40.5
[Re: jcl]
#483968 08/20/2108:3208/20/2108:32
Yes, when triggered by a price quote the TMF always runs before tick. It must react fast to the new price. Tick has lower priority. Tock is anyway not price triggered.
Re: New Zorro version 2.40.5
[Re: jcl]
#483971 08/20/2115:2308/20/2115:23
So, it looks like I can't convince you to revert things back to 2.35 behavior.
What do you suggest I do as a work around?
My TMF must have a synchronized options chain for the underlyprice/timestamp the TMF is executing. Otherwise the result is just plain wrong.
I moved the contractUpdate() call to inside the TMF and it DID load the correct options chain, but it also caused an infinite loop on the first TMF call.
Last edited by SBGuy; 08/20/2115:28.
Re: New Zorro version 2.40.5
[Re: jcl]
#483978 08/22/2110:0908/22/2110:09
Option chains should in live mode only be loaded once per day and only in the run function. It can take 1 hour to load an option chain. This cannot work with tock or tmf. i have also not heard of someone who had that idea.
If the tmf needs the current price, call contractprice. Infinite loops in tmfs are mostly by opening new trades and producing an infinite recursion.
Re: New Zorro version 2.40.5
[Re: jcl]
#483980 08/22/2114:3008/22/2114:30
As said previously, this problem is for backtest only. There are no problems in live trading because contractPrice gets the most current contract prices from the broker plugin.
As you know in backtest, contractPrice called in TMF only uses price data from whatever historical contract chain was loaded in the most recent contractUpdate.
As you know, contractUpdate only loads the snippet of options chain from the large historical .t8 file, ONLY for the "current time."
My work around for this limitation in the past was to call contractUpdate in tock, when TMF runs after tock. Thereby providing the latest contractPrices to TMF.
In 2.40, you guys changed the execution order from tick, tock, TMF, run to: TMF, tick, tock, run.
As a result, the current time for TMF lags the options chain time for exactly 1 Bar, or 1 tick (if TICKS flag was applicable).
Since options price and UL price are mathematically correlated, it is wrong to have priceClose() and contractPrice() be from 2 different times.
I've been trying to explain this for the past few days, and I can't seem to be get through.
I don't know what the reason was to change the execution order to TMF, tick, tock, run after many years.
I am saying this new execution sequence is fundamentally wrong in backtest. If backtest is flawed, what's the point of live trading?
jcl said this earlier "when triggered by a price quote the TMF always runs before tick. It must react fast to the new price."
v 2.40 reacts fast to the latest UL price ONLY, but not the latest contractPrice.
Change the execution order back to tick, tock, TMF, run, and everything will be fine.... at least for backtest.
Thank you.
Re: New Zorro version 2.40.6
[Re: jcl]
#483985 08/23/2107:2908/23/2107:29
I already tried to explain that the order of function calls was not changed, since previous versions had no particular order. It depended on circumstances. Only from 2.40 on there is a state machine that triggers events in a fixed order. But that does not mean that you should use that order in your script.
If a script only works with a certain order of events, I would normally consider that a bug. I would not accept such a script from a freelancer unless there is a special reason for it. If you need a certain order of function calls, have code in your script that calls these functions in that order. Update the options first and update your trades afterwards. I don't see why you would need some tick or tock for that.
If there is a problem that you cannot solve, post it. If there is really no solution with the current Zorro version, we'll implement one. But I doubt that this will be needed.
Re: New Zorro version 2.40.7
[Re: jcl]
#484021 08/30/2108:1808/30/2108:18
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.
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:
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.
Re: New Zorro version 2.40.7
[Re: jcl]
#484045 09/01/2117:2809/01/2117:28