backtesting-strategies
backtesting-strategies copied to clipboard
Order book delayed by one day?
After implementing Luxor, I notice that the order book closes orders one day later than the date called for by mktdata, and getTxns shows the order filled on the next day at the next day's price.
Order.Qty Order.Price Order.Type Order.Side Order.Threshold Order.Status Order.StatusTime Prefer Order.Set Txn.Fees Rule Time.In.Force
2008-02-26 00:00:00 "100" "105.78775" "market" "long" NA "closed" "2008-02-27 00:00:00" "" NA "0" "EnterLONG" ""
2008-03-06 00:00:00 "all" "100.206276" "market" "long" NA "closed" "2008-03-07 00:00:00" "" NA "0" "Exit2SHORT" ""
getTxns(Portfolio = portfolio.st,
-
Symbol = symbol.st[1],
-
Dates = dates.st) Txn.Qty Txn.Price Txn.Fees Txn.Value Txn.Avg.Cost Net.Txn.Realized.PL
2008-01-06 0 0.00000 0 0.000 0.00000 0.0000 2008-02-27 100 105.68068 0 10568.068 105.68068 0.0000
My code does set the time zone to UTC:
Sys.setenv(TZ="UTC") # Set time zone to UTC
It seems the results will not be accurate if quantstrat delays transactions by a day, compared to what is indicated in mktdata.
Probably a rookie mistake, but please help.
I imagine what's happening is that by the time the closing price is established, it's too late to trade, and the trade is executed at the closing price for the next day. It might be more realistic to trade at the opening price for the next day. I'll see if I can make that work.