private void MarketDataUpdate(OrderBookEvent orderBookEvent) { long placeOrderInstructionId = NextInstructionId(); _orderInstructions.Add(placeOrderInstructionId); _session.PlaceLimitOrder(new LimitOrderSpecification(placeOrderInstructionId, _instrumentId, 10m, 10m, TimeInForce.GoodForDay), instructionId => Console.WriteLine("limit order placed with instruction id " + instructionId), FailureCallback("Place order failed for instruction ID " + placeOrderInstructionId)); }
private void MarketDataUpdate(OrderBookEvent onOrderBookEvent) { Console.WriteLine(onOrderBookEvent); // React to price updates from the exchange. HandleBidPrice(onOrderBookEvent.BidPrices); HandleAskPrice(onOrderBookEvent.AskPrices); }
public bool Equals(OrderBookEvent other) { if (object.ReferenceEquals((object)null, (object)other)) { return(false); } if (object.ReferenceEquals((object)this, (object)other)) { return(true); } return(other._instrumentId == this._instrumentId && other._hasValuationBidPrice.Equals(this._hasValuationBidPrice) && (other._hasValuationAskPrice.Equals(this._hasValuationAskPrice) && other._valuationBidPrice == this._valuationBidPrice && (other._valuationAskPrice == this._valuationAskPrice && other._mktClosePrice == this._mktClosePrice) && (other._lastTradedPrice == this._lastTradedPrice && other._dailyHighestTradedPrice == this._dailyHighestTradedPrice && (other._dailyLowestTradedPrice == this._dailyLowestTradedPrice && object.Equals((object)other._mktClosePriceTimestamp, (object)this._mktClosePriceTimestamp))) && (other._timestamp == this._timestamp && OrderBookEvent.EqualPrices(other._bidPrices, this._bidPrices))) && OrderBookEvent.EqualPrices(other._askPrices, this._askPrices)); }
private void MarketDataUpdate(OrderBookEvent orderBookEvent) { long instrumentId = orderBookEvent.InstrumentId; decimal bestBid = GetBestPrice(orderBookEvent.BidPrices); decimal bestAsk = GetBestPrice(orderBookEvent.AskPrices); if (_instrumentInfoById.ContainsKey(instrumentId)) { InstrumentInfo instrument; _instrumentInfoById.TryGetValue(instrumentId, out instrument); instrument.Update(bestBid, bestAsk); } }
public bool Equals(OrderBookEvent other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(other._instrumentId == _instrumentId && other._hasValuationBidPrice.Equals(_hasValuationBidPrice) && other._hasValuationAskPrice.Equals(_hasValuationAskPrice) && other._valuationBidPrice == _valuationBidPrice && other._valuationAskPrice == _valuationAskPrice && other._mktClosePrice == _mktClosePrice && other._lastTradedPrice == _lastTradedPrice && other._dailyHighestTradedPrice == _dailyHighestTradedPrice && other._dailyLowestTradedPrice == _dailyLowestTradedPrice && Equals(other._mktClosePriceTimestamp, _mktClosePriceTimestamp) && other._timestamp == _timestamp && EqualPrices(other._bidPrices, _bidPrices) && EqualPrices(other._askPrices, _askPrices)); }
private void OnSessionMarketDataChanged(OrderBookEvent orderBookEvent) { var time = TimeHelper.GregorianStart.AddMilliseconds(orderBookEvent.Timestamp).ApplyTimeZone(TimeZoneInfo.Utc); var secId = new SecurityId { Native = orderBookEvent.InstrumentId }; var l1Msg = new Level1ChangeMessage { ServerTime = time, SecurityId = secId, }; if (orderBookEvent.HasMarketClosePrice) l1Msg.Add(Level1Fields.ClosePrice, orderBookEvent.MktClosePrice); if (orderBookEvent.HasDailyHighestTradedPrice) l1Msg.Add(Level1Fields.HighPrice, orderBookEvent.DailyHighestTradedPrice); if (orderBookEvent.HasDailyLowestTradedPrice) l1Msg.Add(Level1Fields.LowPrice, orderBookEvent.DailyLowestTradedPrice); if (orderBookEvent.HasLastTradedPrice) { l1Msg.Add(Level1Fields.LastTradePrice, orderBookEvent.LastTradedPrice); } SendOutMessage(l1Msg); SendOutMessage(new QuoteChangeMessage { SecurityId = secId, Bids = orderBookEvent.BidPrices.Select(p => new QuoteChange(Sides.Buy, p.Price, p.Quantity)), Asks = orderBookEvent.AskPrices.Select(p => new QuoteChange(Sides.Sell, p.Price, p.Quantity)), ServerTime = time }); }
public override string ToString() { return(string.Format("OrderBookEvent{{InstrumentId: {0}, ValuationBidPrice: {1}, ValuationAskPrice: {2}, BidPrices: {3}, AskPrices: {4}, MarketClosePrice: {5}, MarketClosePriceTimestamp: {6}, LastTradedPrice: {7}, DailyHighestTradedPrice: {8}, DailyLowestTradedPrice: {9}, Timestamp: {10}}}", (object)this._instrumentId, (object)this._valuationBidPrice, (object)this._valuationAskPrice, (object)OrderBookEvent.FormatPricePoints(this._bidPrices), (object)OrderBookEvent.FormatPricePoints(this._askPrices), (object)this._mktClosePrice, (object)this._mktClosePriceTimestamp, (object)this._lastTradedPrice, (object)this._dailyHighestTradedPrice, (object)this._dailyLowestTradedPrice, (object)this._timestamp)); }
public bool Equals(OrderBookEvent other) { if (ReferenceEquals(null, other)) return false; if (ReferenceEquals(this, other)) return true; return other._instrumentId == _instrumentId && other._hasValuationBidPrice.Equals(_hasValuationBidPrice) && other._hasValuationAskPrice.Equals(_hasValuationAskPrice) && other._valuationBidPrice == _valuationBidPrice && other._valuationAskPrice == _valuationAskPrice && other._mktClosePrice == _mktClosePrice && other._lastTradedPrice == _lastTradedPrice && other._dailyHighestTradedPrice == _dailyHighestTradedPrice && other._dailyLowestTradedPrice == _dailyLowestTradedPrice && Equals(other._mktClosePriceTimestamp, _mktClosePriceTimestamp) && other._timestamp == _timestamp && EqualPrices(other._bidPrices, _bidPrices) && EqualPrices(other._askPrices, _askPrices); }