public Level2Snapshot(DateTime dateTime, byte providerId, int instrumentId, Bid[] bids, Ask[] asks) : base(dateTime) { ProviderId = providerId; InstrumentId = instrumentId; Bids = bids; Asks = asks; }
public void OnBid(Bid bid) { var orders = this.ordersByInstrumentId[bid.InstrumentId]; if (orders == null) return; foreach (var order in orders) { method_8(order, bid, this.framework.DataManager.GetAsk(order.Instrument)); if (AddQueueToOrderText) order.Text = order.double_6.ToString(); } }
public Quote GetQuote(int level) { var bid = new Bid(); var ask = new Ask(); Tick tick; if (Bids.Count < level) { tick = Bids[level]; bid = new Bid(tick.DateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size); } if (Asks.Count < level) { tick = Asks[level]; ask = new Ask(tick.DateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size); } return new Quote(bid, ask); }
internal virtual void vmethod_10(Bid bid) { if (this.IsInstance) { this.OnBid(bid); List<Stop> list = this.idArray_0[bid.instrumentId]; if (list != null) { for (int i = 0; i < list.Count; i++) { Stop stop_ = list[i]; if (stop_.Connected) { stop_.method_6(bid); } } } } }
public Level2(Bid bid, Level2UpdateAction action, int position) : base(bid) { Side = Level2Side.Bid; Action = action; Position = position; }
private bool FillWithBid(Order order, Bid bid) { if (order.Side != OrderSide.Sell) return false; while (true) { switch (order.Type) { case OrderType.Market: case OrderType.Pegged: Fill(order, bid.Price, bid.Size); return true; case OrderType.Stop: if (bid.Price <= order.StopPx) { if (!FillAtStopPrice) { order.Type = OrderType.Market; continue; } Fill(order, order.StopPx, bid.Size); return true; } break; case OrderType.Limit: if (bid.Price >= order.Price) { Fill(order, FillAtLimitPrice ? order.Price : bid.Price, bid.Size); return true; } return false; case OrderType.StopLimit: if (bid.Price <= order.StopPx) { order.Type = OrderType.Limit; continue; } break; } break; } return false; }
private void method_8(Order order_0, Bid bid_0, Ask ask_0) { }
private void HandleSend(Order order) { if (order.Qty == 0.0) { this.ExecOrderRejected(order, "Order amount can not be zero"); return; } var report = new ExecutionReport { DateTime = this.framework.Clock.DateTime, Order = order, OrderId = order.Id, Instrument = order.Instrument, InstrumentId = order.InstrumentId, ExecType = ExecType.ExecNew, OrdStatus = OrderStatus.New, CurrencyId = order.Instrument.CurrencyId, OrdType = order.Type, Side = order.Side, OrdQty = order.Qty, Price = order.Price, StopPx = order.StopPx, TimeInForce = order.TimeInForce, CumQty = 0, LastQty = 0, LeavesQty = order.Qty, LastPx = 0, AvgPx = 0, Text = order.Text }; order.LeavesQty = report.LeavesQty; this.summariesByOrderId[order.Id] = new ReportSummary(report); EmitExecutionReport(report, Queued); if (order.TimeInForce == TimeInForce.AUC) { this.stops.Add(order); if (this.stops.Count == 1) { this.framework.Clock.AddReminder(OnAuction1, this.framework.Clock.DateTime.Date.Add(Auction1)); this.framework.Clock.AddReminder(OnAuction2, this.framework.Clock.DateTime.Date.Add(Auction2)); } return; } int int_ = order.InstrumentId; GetOrdersBy(int_, true).Add(order); if (((order.Type == OrderType.Market || order.Type == OrderType.Pegged) && !FillMarketOnNext) || (order.Type == OrderType.Limit && !FillLimitOnNext) || (order.Type == OrderType.Stop && !FillStopOnNext) || (order.Type == OrderType.StopLimit && !FillStopLimitOnNext)) { if (FillOnQuote) { Ask ask = this.framework.DataManager.GetAsk(int_); if (ask != null && FillWithAsk(order, ask)) { this.ClearOrders(); return; } Bid bid = this.framework.DataManager.GetBid(int_); if (bid != null && this.FillWithBid(order, bid)) { this.ClearOrders(); return; } } if (FillOnTrade) { var trade = this.framework.DataManager.GetTrade(int_); if (trade != null && this.FillWithTrade(order, trade)) { this.ClearOrders(); return; } } if (FillOnBar) { var bar = this.framework.DataManager.GetBar(int_); if (BarFilter.Count != 0 && !BarFilter.Contains(bar.Type, bar.Size)) { return; } if (bar != null && this.FillWithBar(order, bar)) { ClearOrders(); } } } }
public Quote(Bid bid, Ask ask) { Bid = bid; Ask = ask; DateTime = bid.DateTime > ask.DateTime ? bid.DateTime : ask.DateTime; }
public Level2(Bid bid, Level2UpdateAction action, int position): base(bid) { Side = Level2Side.Bid; Action = action; Position = position; }
public override void EmitBid(Bid bid) { EventManager.OnEvent(new Bid(bid){providerId = IsInstance ? (byte)Parent.Id : (byte)Id}); }
public void OnBid(Bid bid) { // Check conditions for send leg orders. if (order.Side == OrderSide.Sell) { switch (order.Type) { case OrderType.Limit: if (bid.Price >= order.Price) SendLegOrders(); break; case OrderType.Stop: if (bid.Price <= order.StopPx) SendLegOrders(); break; } } }
protected override void OnBid(Instrument instrument, Bid bid) { if (instrument.Id == currentFuturesContract.Id) { Bid rootBid = new Bid(bid.DateTime, 0, rootInstrument.Id, bid.Price, bid.Size); // Emit bid to to BuySide strategy. EmitBid(rootBid); } }
private void method_7(List<byte> providers = null) { SortedList<double, Tick> sortedList = new SortedList<double, Tick>(new PriceComparer(PriceSortOrder.Descending)); SortedList<double, Tick> sortedList2 = new SortedList<double, Tick>(new PriceComparer(PriceSortOrder.Ascending)); List<Tuple<DateTime, List<Tick>, List<Tick>>> list; if (providers == null) { list = new List<Tuple<DateTime, List<Tick>, List<Tick>>>(this.GonEpGhAb.Values); } else { list = new List<Tuple<DateTime, List<Tick>, List<Tick>>>(); foreach (byte current in providers) { if (this.GonEpGhAb.ContainsKey((int)current)) { list.Add(this.GonEpGhAb[(int)current]); } } } this.dateTime_0 = default(DateTime); foreach (Tuple<DateTime, List<Tick>, List<Tick>> current2 in list) { if (current2.Item1 > this.dateTime_0) { this.dateTime_0 = current2.Item1; } } List<Tuple<DateTime, List<Tick>, List<Tick>>> list2 = new List<Tuple<DateTime, List<Tick>, List<Tick>>>(); foreach (Tuple<DateTime, List<Tick>, List<Tick>> current3 in list) { if (current3.Item1 + this.Timeout >= this.dateTime_0) { list2.Add(current3); } } foreach (Tuple<DateTime, List<Tick>, List<Tick>> current4 in list2) { foreach (Tick current5 in current4.Item2) { if (!sortedList.ContainsKey(current5.Price)) { Bid bid = new Bid(current5); if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { bid.ProviderId = 0; } sortedList.Add(current5.Price, bid); } else if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { sortedList[current5.Price].Size += current5.Size; } else if (this.Mode == OrderBookAggr.AggregationMode.MaxValue && current5.Size > sortedList[current5.Price].Size) { sortedList[current5.Price] = new Bid(current5); } } foreach (Tick current6 in current4.Item3) { if (!sortedList2.ContainsKey(current6.Price)) { Ask ask = new Ask(current6); if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { ask.ProviderId = 0; } sortedList2.Add(current6.Price, ask); } else if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { sortedList2[current6.Price].Size += current6.Size; } else if (this.Mode == OrderBookAggr.AggregationMode.MaxValue && current6.Size > sortedList2[current6.Price].Size) { sortedList2[current6.Price] = new Ask(current6); } } } this.bids = new List<Tick>(sortedList.Values); this.asks = new List<Tick>(sortedList2.Values); this.bool_0 = true; }
//public Level2Snapshot GetLevel2Snapshot() //{ // lock (this.lck) // { // if (!this.bool_0) // this.method_3(); // var bids = new List<Bid>(); // var asks = new List<Ask>(); // foreach (var tick in this.bids) // if (tick is Bid) // bids.Add(tick as Bid); // foreach (var tick in this.asks) // if (tick is Ask) // asks.Add(tick as Ask); // return new Level2Snapshot(this.dateTime_0, 0, this.instrumentId, bids.ToArray(), asks.ToArray()); // } //} public Quote GetQuote(int level) { lock (this.lck) { if (!this.bool_0) this.method_3(); var bid = new Bid(); var ask = new Ask(); if (this.bids.Count > level) { var tick = this.bids[level]; bid = new Bid(tick.dateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size); } if (this.asks.Count > level) { var tick = this.asks[level]; ask = new Ask(tick.dateTime, tick.ProviderId, tick.InstrumentId, tick.Price, tick.Size); } return new Quote(bid, ask); } }
protected virtual void OnBid(Bid bid) { // noop }
protected virtual void OnBid(Bid bid) { }
public override void EmitBid(Bid bid) { // Emit bid to BuySide strategy. base.EmitBid(bid); System.Collections.Generic.LinkedListNode<OrderProcessor> processorNode = processors.First; // Send bid to order processors. while (processorNode != null) { OrderProcessor processor = processorNode.Value; processor.OnBid(bid); processorNode = processorNode.Next; } }
public virtual void EmitBid(Bid bid) { EventManager.OnEvent(new Bid(bid){providerId = (byte)Id}); }
public void OnBid(Bid bid) { var orders = GetOrdersBy(bid.InstrumentId); if (orders == null) return; if (FillOnQuote) { foreach (var order in orders) FillWithBid(order, bid); ClearOrders(); } }
public Bid(Bid bid) : base(bid) { }
public new virtual void EmitBid(Bid bid) { this.framework.EventManager.OnEvent(new Bid(bid) { ProviderId = (byte)Id }); }
protected override void OnBid(Instrument instrument, Bid bid) { if (instrument == spread) return; if (!isAskBidReady) { isAskBidReady = true; foreach (Leg leg in spread.Legs) { if (leg.Instrument.Ask == null || leg.Instrument.Bid == null) { isAskBidReady = false; return; } } } // double bidPrice = 0; int bidSize = Int32.MaxValue; foreach (Leg leg in spread.Legs) { if (leg.Weight > 0) { bidPrice += leg.Instrument.Bid.Price * leg.Weight; bidSize = Math.Min(bidSize, leg.Instrument.Bid.Size); } else if (leg.Weight < 0) { bidPrice += leg.Instrument.Ask.Price * leg.Weight; bidSize = Math.Min(bidSize, leg.Instrument.Ask.Size); } } // Create new bid for spread instrument. EmitBid(new Bid(bid.DateTime, 0, spread.Id, bidPrice, bidSize)); }
public override void EmitBid(Bid bid) { var providerId = GetProviderId(); this.framework.EventManager.OnEvent(new Bid(bid) { ProviderId = providerId }); }
public Level2Snapshot(DateTime dateTime, DateTime exchangeDateTime, byte providerId, int instrumentId, Bid[] bids, Ask[] asks) : this(dateTime, providerId, instrumentId, bids, asks) { ExchangeDateTime = exchangeDateTime; }
internal void OnBid(Bid bid) { var iId = bid.InstrumentId; var pId = bid.ProviderId + 1; this.latestBid[iId] = bid; this.bidByIIdAndPId[pId] = this.bidByIIdAndPId[pId] ?? new IdArray<Bid>(10240); this.bidByIIdAndPId[pId][iId] = bid; }
internal void OnBid(Bid bid) { if (TraceOnQuote && Side == PositionSide.Long) { this.fillPrice = this.trailPrice = this.currPrice = GetPrice(bid.Price); this.method_1(); } }
internal void OnBid(Bid bid) { if (Strategy?.Status == StrategyStatus.Running) Strategy.EmitBid(bid); }
private void method_7(List <byte> providers = null) { SortedList <double, Tick> sortedList = new SortedList <double, Tick>(new PriceComparer(PriceSortOrder.Descending)); SortedList <double, Tick> sortedList2 = new SortedList <double, Tick>(new PriceComparer(PriceSortOrder.Ascending)); List <Tuple <DateTime, List <Tick>, List <Tick> > > list; if (providers == null) { list = new List <Tuple <DateTime, List <Tick>, List <Tick> > >(this.GonEpGhAb.Values); } else { list = new List <Tuple <DateTime, List <Tick>, List <Tick> > >(); foreach (byte current in providers) { if (this.GonEpGhAb.ContainsKey((int)current)) { list.Add(this.GonEpGhAb[(int)current]); } } } this.dateTime_0 = default(DateTime); foreach (Tuple <DateTime, List <Tick>, List <Tick> > current2 in list) { if (current2.Item1 > this.dateTime_0) { this.dateTime_0 = current2.Item1; } } List <Tuple <DateTime, List <Tick>, List <Tick> > > list2 = new List <Tuple <DateTime, List <Tick>, List <Tick> > >(); foreach (Tuple <DateTime, List <Tick>, List <Tick> > current3 in list) { if (current3.Item1 + this.Timeout >= this.dateTime_0) { list2.Add(current3); } } foreach (Tuple <DateTime, List <Tick>, List <Tick> > current4 in list2) { foreach (Tick current5 in current4.Item2) { if (!sortedList.ContainsKey(current5.Price)) { Bid bid = new Bid(current5); if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { bid.ProviderId = 0; } sortedList.Add(current5.Price, bid); } else if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { sortedList[current5.Price].Size += current5.Size; } else if (this.Mode == OrderBookAggr.AggregationMode.MaxValue && current5.Size > sortedList[current5.Price].Size) { sortedList[current5.Price] = new Bid(current5); } } foreach (Tick current6 in current4.Item3) { if (!sortedList2.ContainsKey(current6.Price)) { Ask ask = new Ask(current6); if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { ask.ProviderId = 0; } sortedList2.Add(current6.Price, ask); } else if (this.Mode == OrderBookAggr.AggregationMode.TotalValue) { sortedList2[current6.Price].Size += current6.Size; } else if (this.Mode == OrderBookAggr.AggregationMode.MaxValue && current6.Size > sortedList2[current6.Price].Size) { sortedList2[current6.Price] = new Ask(current6); } } } this.bids = new List <Tick>(sortedList.Values); this.asks = new List <Tick>(sortedList2.Values); this.bool_0 = true; }