- ago
How do I extract the BarHistory object to use in the PlaceTrade() method from within PostExecute()?
0
72
Solved
2 Replies

Reply

Bookmark

Sort
Cone7
 ( 35.55% )
- ago
#1
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:

CODE:
public override void PostExecute(DateTime dt, List<BarHistory> participants)
0
Best Answer
- ago
#2
@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;                      }                   } }
0

Reply

Bookmark

Sort