public DepthInfo(MarketMakerStats mms, MarketDepth md, int level) { this.mms = mms; this.md = md; this.level = level; }
public void Update(MarketMakerStats mms, MarketDepth md) { int keyindex; int level; double price = md.Price; LimitBookEntry lbe; int HiChanged = 0; int LoChanged = 0; lock (entries) { level = OneUnified.SmartQuant.Convert.DoublePriceToIntStock(md.Price); DepthInfo di = new DepthInfo(mms, md, level); // obtain level at which depth is used if (entries.ContainsKey(level)) { keyindex = entries.IndexOfKey(level); lbe = entries.Values[keyindex]; } else { lbe = new LimitBookEntry(level, md.Price); entries.Add(level, lbe); keyindex = entries.IndexOfKey(level); } // update the level, and signal change event //lbe.Update(mms, md); di.Object = base.Add(md.DateTime, di); lbe.Update(di); if (null != PriceBookRowChanged) { PriceBookRowChanged(this, level, lbe.Price, lbe.Size); } // used for indicating inside quote changed (is this useful due to problems with expiration?) if (0 == keyindex) { LoChanged++; } if (entries.Count - 1 == keyindex) { HiChanged++; } // if level has no active depth markers, remove it if (0 == lbe.Size) { entries.RemoveAt(keyindex); if (0 == keyindex) { LoChanged++; } if (entries.Count == keyindex) // matches without the '-1' with the removal { HiChanged++; } } // signal event that inside quote has changed (again, not sure if this will actually work properly, // as we are using quotes to clear this stuff out. if (entries.Count > 0) { if (0 < HiChanged) { // highest changed so indicate as such, other code will determine if it is a new inside or not int ix = entries.Count - 1; if (null != PriceBookHiEdgeChanged) { PriceBookHiEdgeChanged(this, ix, entries.Keys[ix], entries.Values[ix].Price); } } if (0 < LoChanged) { // lowest changed so indicate as such, other code will determine if it is a new inside or not if (null != PriceBookLoEdgeChanged) { PriceBookLoEdgeChanged(this, 0, entries.Keys[0], entries.Values[0].Price); } } } ; } }