private OrderPartiallyFilled GenerateOrderPartiallyFilledEvent(ExecutionReport message) { var orderId = this.GetOrderId(message); var executionId = new ExecutionId(message.GetField(Tags.ExecID)); var positionIdBroker = new PositionIdBroker(message.GetField(FxcmTags.PosID)); var symbol = this.GetSymbol(message.GetField(Tags.Symbol)); var orderSide = FxcmMessageHelper.GetOrderSide(message.GetField(Tags.Side)); var filledQuantity = Quantity.Create(message.GetDecimal(Tags.CumQty)); var averagePrice = Price.Create(message.GetDecimal(Tags.AvgPx)); var quoteCurrency = this.GetQuoteCurrency(symbol, message.GetField(Tags.Currency)); var leavesQuantity = Quantity.Create(message.GetInt(Tags.LeavesQty)); var executionTime = FxcmMessageHelper.ParseTimestamp(message.GetField(Tags.TransactTime)); return(new OrderPartiallyFilled( this.accountId, orderId, executionId, positionIdBroker, symbol, orderSide, filledQuantity, leavesQuantity, averagePrice, quoteCurrency, executionTime, this.NewGuid(), this.TimeNow())); }
public void OnMessage(MarketDataSnapshotFullRefresh message) { Debug.NotNull(this.dataGateway, nameof(this.dataGateway)); message.GetGroup(1, this.mdBidGroup); message.GetGroup(2, this.mdAskGroup); var tick = new QuoteTick( this.GetSymbol(message.GetField(Tags.Symbol)), Price.Create(this.mdBidGroup.GetDecimal(Tags.MDEntryPx)), Price.Create(this.mdAskGroup.GetDecimal(Tags.MDEntryPx)), Quantity.One(), Quantity.One(), this.tickTimestampProvider()); this.dataGateway?.OnData(tick); }
public void OnMessage(SecurityList message) { Debug.NotNull(this.dataGateway, nameof(this.dataGateway)); var responseId = message.GetField(Tags.SecurityResponseID); var result = FxcmMessageHelper.GetSecurityRequestResult(message.SecurityRequestResult); this.Logger.LogDebug(LogId.Network, $"{Received}{Fix} {nameof(SecurityList)}(ResponseId={responseId}, Result={result})."); var instruments = new List <Instrument>(); var groupCount = int.Parse(message.NoRelatedSym.ToString()); var group = new SecurityList.NoRelatedSymGroup(); for (var i = 1; i <= groupCount; i++) { message.GetGroup(i, group); var symbol = this.GetSymbol(group.GetField(Tags.Symbol)); var securityType = FxcmMessageHelper.GetSecurityType(group.GetField(FxcmTags.ProductID)); var tickPrecision = group.GetInt(FxcmTags.SymPrecision); var tickSize = group.GetDecimal(FxcmTags.SymPointSize) * 0.1m; // Field 9002 returns 'point' size (* 0.1m to get tick size) var roundLot = group.GetInt(Tags.RoundLot); var minStopDistanceEntry = group.GetInt(FxcmTags.CondDistEntryStop); var minLimitDistanceEntry = group.GetInt(FxcmTags.CondDistEntryLimit); var minStopDistance = group.GetInt(FxcmTags.CondDistStop); var minLimitDistance = group.GetInt(FxcmTags.CondDistLimit); var minTradeSize = group.GetInt(FxcmTags.MinQuantity); var maxTradeSize = group.GetInt(FxcmTags.MaxQuantity); var rolloverInterestBuy = group.GetDecimal(FxcmTags.SymInterestBuy); var rolloverInterestSell = group.GetDecimal(FxcmTags.SymInterestSell); if (securityType == SecurityType.Forex) { var forexInstrument = new ForexInstrument( symbol, tickPrecision, 0, minStopDistanceEntry, minLimitDistanceEntry, minStopDistance, minLimitDistance, Price.Create(tickSize, tickPrecision), Quantity.Create(roundLot), Quantity.Create(minTradeSize), Quantity.Create(maxTradeSize), rolloverInterestBuy, rolloverInterestSell, this.TimeNow()); instruments.Add(forexInstrument); } else { var instrument = new Instrument( symbol, group.GetField(Tags.Currency).ToEnum <Nautilus.DomainModel.Enums.Currency>(), securityType, tickPrecision, 0, minStopDistanceEntry, minLimitDistanceEntry, minStopDistance, minLimitDistance, Price.Create(tickSize, tickPrecision), Quantity.Create(roundLot), Quantity.Create(minTradeSize), Quantity.Create(maxTradeSize), rolloverInterestBuy, rolloverInterestSell, this.TimeNow()); instruments.Add(instrument); } } this.dataGateway?.OnData(instruments); }