thank you
Here is market depth method
protected override void OnMarketDepth(MarketDepthEventArgs e)
{
// protect e.Instrument.MarketDepth.Asks and e.Instrument.MarketDepth.Bids against in-flight changes
lock (e.Instrument.SyncMarketDepth)
{
List<LadderRow> rows = (e.MarketDataType == MarketDataType.Ask ? askRows: bidRows);
LadderRow row = new LadderRow { MarketMaker = e.MarketMaker, Price = e.Price, Volume = e.Volume };
if (e.Operation == Operation.Add || (e.Operation == Operation.Update && (rows.Count == 0 || rows.Count <= e.Position)))
{
if (rows.Count <= e.Position)
rows.Add(row);
else
rows.Insert(e.Position, row);
}
else if (e.Operation == Operation.Remove && rows.Count >= e.Position)
{
rows.RemoveAt(e.Position);
}
else if (e.Operation == Operation.Update)
{
if (rows[e.Position] == null)
{
rows[e.Position] = row;
}
else
{
rows[e.Position].MarketMaker = e.MarketMaker;
rows[e.Position].Price = e.Price;
rows[e.Position].Volume = e.Volume;
}
}
}
ClearOutputWindow();
Print(askRows[0].Volume);
// Prints the L2 Ask Book we created. Cycles through the whole List and prints the contained objects.
if (e.MarketDataType == MarketDataType.Ask && e.Operation == Operation.Update){
for (int idx = askRows.Count-1; idx >=0; idx--){
Draw.Text(this, "ask"+idx,(askRows[idx].Price+" - "+askRows[idx].Volume).ToString() , 0, askRows[idx].Price, Brushes.Black);
}
}
// Prints the L2 Bid Book we created. Cycles through the whole List and prints the contained objects.
for (int idx = 0; idx < bidRows.Count; idx++){
//Print("Bid Price=" + bidRows[idx].Price + " Volume=" + bidRows[idx].Volume + " Position=" + idx);
}
}


Comment