I try to answer myself. It seems first one is trade status, possible values are ['Created', 'Open', 'Closed']. Latter one is order status, possible values are ['Created', 'Submitted', 'Accepted', 'Partial', 'Completed', 'Canceled', 'Expired', 'Margin', 'Rejected'].
Latest posts made by Aris L
-
RE: TradeHistory status 1, but event.order.status is 4
-
should pnlcomm be negative for newly opened trade?
Both pnl and pnlcomm are 0 for newly opened trade in
notify_trade
. However, should pnlcomm be 0, since it's net profit, and should include commission? -
TradeHistory status 1, but event.order.status is 4
In a test, TradeHistory's status.status shows value of 1, but event.order.status has value of 4.
What's the difference of the two status value?Hope the question is not too vague.
-
What is the recommended way to retrieve underlying orders for a trade?
In strategy, we have
notify_trade
to be called when a trade is happened (opening/updating/closing). Based on the reference of this trade, what is the recommended way to get the underlying orders for this trade? -
RE: Multiple asset with missing data
That's why a multi-asset version of quickstart would be very helpful for starters to clarify things, as it would touch upon things that single-asset wouldn't.
So you mean backtrader's multiple asset assume all assets have the same length (therefore, no survivorship bias present). It doesn't support the multiple assets with different length.
-
RE: Multiple asset with missing data
Indeed, I'm still following through quick start and exploring from there. Will read document links at further steps.
Though prenext is probably a good idea to put in the start, as it's natural concept if multi datafeed is considered. Or even better, it'll be great to have a multi-asset version of quickstart by itself.
-
RE: Multiple asset with missing data
@backtrader said in Multiple asset with missing data:
This statement is simply wrong.
From the above example, first 'next' call for A is on 2018-12-05, even though A has data 2018-11-30. From method calls perspective, A's 'next' calls gets truncated.
I don't mean by actual data, actual data can't be truncated, because it still gets called in 'prenext'.
-
RE: Multiple asset with missing data
Initially I thought 'next' for stock A should get called with all the days, but instead it gets truncated by the lesser stock B.
-
RE: Multiple asset with missing data
@backtrader said in Multiple asset with missing data:
No.
Thanks, seems working for me now. Turns out prenext gets called, and next doesn't. That means the logic should probably be put in both prenext and next.
For information, I tried
stock A: 2018-11-30 to 2018-12-10.
stock B: 2018-12-05 to 2018-12-10.The result is:
prenext. A 2018-11-30
prenext. B 2018-11-30
prenext. A 2018-12-03
prenext. B 2018-12-03
prenext. A 2018-12-04
prenext. B 2018-12-04
next. A 2018-12-05
next. B 2018-12-05
next. A 2018-12-06
next. B 2018-12-06
next. A 2018-12-07
next. B 2018-12-07
next. A 2018-12-10
next. B 2018-12-10The strategy code is:
class LogStrategy(bt.Strategy): def prenext(self): for data in self.datas: curr_date = self.datas[0].datetime.date().strftime('%Y-%m-%d') logger.info(f'prenext. {data.AssetId[0]:.0f}, {curr_date}') def next(self): for data in self.datas: curr_date = self.datas[0].datetime.date().strftime('%Y-%m-%d') logger.info(f'next. {data.AssetId[0]:.0f}, {curr_date}')
-
Multiple asset with missing data
I'm trying to load multiple assets, however only last day's data is coming out. I assume when there're missing data in one asset on a day, the system will skip that day for all assets. It's quite likely on a particular day that some stock is not trading, so collectively a large number of days are being skipped.
Would it make sense to change this behavior? I guess if the asset doesn't trade on one day, it's fine to skip for that asset, but other assets with data should still run.