Login Page - Create Account

Support Board


Date/Time: Mon, 20 May 2024 17:32:35 +0000



Post From: backtest with manual looping, sc.GetTradePosition() doesn't update?

[2019-05-19 18:16:57]
uM8137 - Posts: 180
Figured it out.

Sometimes you will get an sc.IsFullRecalculation==1 invocation, and yet
your orders will all result in tons of this in the log:

"Order entry skipped because full recalculation"

Now you may think to yourself: ugh! I can't read any of the log any more. It is
completely spammed by tons of these messages. Since there doesn't seem to be a way
of avoiding them, I know, I will check that flag and
not place any orders if sc.IsFullRecalculation is true.

Now this seems logical, but it would be a mistake. Because there is a very important other time,
when doing a backtest, where the one sc.IsFullRecalculation==1 with sc.StartUpdateIndex==0 pass is
your *only* opportunity to place orders.

If you wait until sc.StartUpdateIndex goes
past the bar where you want to place a simulated order,
you will get the following typical complaint, which really
should mention that specifically your order's index was not between sc.UpdateStartIndex
and sc.ArraySize-1:

"Order entry skipped because invalid bar index specified"

So the root of the problem was the spam that obscures most of the log, which is a total red
herring anyway and should eliminated since it serves only to steer you in the wrong direction.

And, last but very much not least, the devious thing about the
"Order entry skipped because full recalculation" message is that
it will subvert the API and tell you that your order succeeded, but publish that
complaint to the log AND then mess with the API in that you won't see any actual trade position change happen
due to your filled order. However your order will get filled under backtest, so you
just have to ignore it.
Date Time Of Last Edit: 2019-05-19 18:20:57