How do I extract the BarHistory object to use in the PlaceTrade() method from within PostExecute()?
Rename
It's not "object", rather it's "all objects that were available to be traded on that bar".
They're in the list of Participants - here's the signature of the method:
They're in the list of Participants - here's the signature of the method:
CODE:
public override void PostExecute(DateTime dt, List<BarHistory> participants)
@Cone, thanks for the insight. I came up with two approaches that appear to work. I'm posting below in case it's helpful to anyone that wants to place trades in the PreExecute() or PostExecute() method.
CODE:
foreach (IndexKVolHolder i in indexKVolList) { //Method 1 var iBar = participants.Where(b => b.Symbol == i.index).FirstOrDefault(); Transaction t1 = PlaceTrade(iBar, TransactionType.Buy, OrderType.Market); t1.Quantity = 100; //Method 2 foreach(BarHistory ib in participants) { if (ib.Symbol == i.index) { BarHistory myBars = ib; Transaction t2 = PlaceTrade(myBars, TransactionType.Buy, OrderType.Market); t2.Quantity = 200; } } }
Your Response
Post
Edit Post
Login is required