public int PlaceSimpleOrder(SimpleOrder simpleOrder) { try { IBUser user = _userManager.GetUser(simpleOrder.UserName); if (user != null) { IBApi.Contract contract = IBContractSamples.GetContract(simpleOrder); IBApi.Order order = IBOrderSamples.GetOrder(simpleOrder); return(user.PlaceOrder(contract, order, simpleOrder.Fund, simpleOrder.Strategy, simpleOrder.Folder)); } return(-1); } catch (Exception ex) { _Logger.Error(ex); throw ex; } }
public OrderInfo(IBOrder order, Instrument instrument = null, string orderState = null) { // При создании OrderInfo из IBApi.Order у нас нет информации // * о неисполненном объеме заявки. Есть надежда, что этот объем придет через orderState() // * о времени постановки заявки. Тут ничего не поделаешь, проставляем текущую дату/время Account = order.Account; OrderId = order.OrderId; Operation = IBUtils.ParseOrderOperation(order.Action); Price = (decimal)order.LmtPrice; OrderRef = order.OrderRef; Type = IBUtils.ParseOrderType(order.OrderType) ?? OrderType.Limit; PermId = order.PermId; Quantity = order.TotalQuantity; ActiveQuantity = order.TotalQuantity; DateTime = DateTime.Now; Instrument = instrument; State = IBUtils.ParseOrderState(orderState) ?? OrderState.Active; NewOrderTransactionId = Guid.NewGuid(); }
/// <summary> /// Обработать транзакцию <see cref="NewOrderTransaction"/> /// </summary> /// <param name="transaction"> /// Транзакция для обработки /// </param> async void ITransactionVisitor.Visit(NewOrderTransaction transaction) { try { var order = new IBOrder { Account = transaction.Account, ClientId = connector.ClientId, Action = transaction.Operation == OrderOperation.Buy ? "BUY" : "SELL", TotalQuantity = (int)transaction.Quantity, OrderRef = !string.IsNullOrWhiteSpace(transaction.Comment) ? connector.IBOrderRouter.SessionUidInternal + transaction.Comment : connector.IBOrderRouter.SessionUidInternal, Transmit = true }; switch (transaction.Type) { case OrderType.Limit: order.OrderType = "LMT"; order.LmtPrice = (double)transaction.Price; break; case OrderType.Market: order.OrderType = "MKT"; break; default: throw new ArgumentOutOfRangeException("transaction.Type"); } switch (transaction.ExecutionCondition) { case OrderExecutionCondition.PutInQueue: order.Tif = "GTC"; /* Good till cancelled */ break; case OrderExecutionCondition.FillOrKill: order.Tif = "FOC"; /* Fill or cancel */ break; case OrderExecutionCondition.KillBalance: order.Tif = "IOC"; /* Immediate or cancel */ break; default: throw new ArgumentOutOfRangeException("transaction.ExecutionCondition"); } await connector.Adapter.PlaceOrderAsync(transaction, order); } catch (TransactionRejectedException exception) { Reject(transaction, exception.Message); } catch (Exception exception) { _Log.Error() .Print(exception, "Unable to send transaction", LogFields.Transaction(transaction), LogFields.Message(exception.Message)); Reject(transaction, "Transaction execution failed: {0}", exception.Message); } }
public ComSoftDollarTier(IBApi.Order order) { this.order = order; }
public ComSoftDollarTier(IBApi.Order order) { this.data = order.Tier; }