public override async Task <ExecutionReport> AddOrderAndWaitExecution(TradingSignal signal, TranslatedSignalTableEntity translatedSignal, TimeSpan timeout) { var newOrderSingle = new NewOrderSingle { HandlInst = new HandlInst(HandlInst.AUTOMATED_EXECUTION_ORDER_PRIVATE), Symbol = _modelConverter.ConvertLykkeSymbol(signal.Instrument.Name), Side = _modelConverter.ConvertSide(signal.TradeType), OrderQty = new OrderQty(signal.Volume), OrdType = _modelConverter.ConverOrderType(signal.OrderType), TimeInForce = new TimeInForce(TimeInForce.IMMEDIATE_OR_CANCEL), TransactTime = new TransactTime(DateTime.UtcNow), Price = new Price(signal.Price ?? 0m) }; var cts = new CancellationTokenSource(timeout); var report = await _connector.AddOrderAsync(newOrderSingle, cts.Token); var trade = _modelConverter.ConvertExecutionReport(report); try { var handlerTrade = _modelConverter.ConvertExecutionReport(report); handlerTrade.ExecType = ExecType.Trade; await _executionHandler.Handle(handlerTrade); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(AddOrderAndWaitExecution), "Posting order to Jfd", ex); } return(trade); }
private async Task SaveMessageAsync(Message message, FixMessageDirection direction) { try { var entity = new FixMessageTableEntity() { PartitionKey = "icm", // TODO RowKey = (DateTime.MaxValue.Ticks - DateTime.UtcNow.Ticks).ToString(), Type = message.GetType().Name, Message = message.ToString().Replace("\u0001", "^"), Direction = direction }; await _tableStorage.InsertAsync(entity); } catch (Exception ex) { await _log.WriteErrorAsync(nameof(SaveMessageAsync), string.Empty, "Saving fix messages", ex); } }