public void RegisterOrder(string portfName, string secCode, Sides side, decimal price, decimal volume, long transId, bool allOrNone, DateTimeOffset?expiryDate, OrderTypes type, ETradeOrderCondition cond) { var order = new BusinessEntities.Order { Portfolio = new Portfolio { Name = portfName }, Security = new Security { Code = secCode }, Direction = side, Price = price, Volume = volume, TransactionId = transId, TimeInForce = allOrNone ? TimeInForce.MatchOrCancel : TimeInForce.PutInQueue, ExpiryDate = expiryDate, Type = type, Condition = cond }; _orderModule.ExecuteUserRequest(new ETradeRegisterOrderRequest(order), response => { OrderRegisterResult.SafeInvoke(transId, response.Data, response.Exception); _orderModule.ResetOrderUpdateSettings(portfName, false); }); }
public PlaceEquityOrderResponse2 SendOrderChange(int oldOrderId, BusinessEntities.Order newOrder) { if (_authenticator == null) { throw new ETradeUnauthorizedException(LocalizedStrings.Str3350); } var data = new changeEquityOrderRequest { orderNum = oldOrderId }; FillOrderRequest(data, newOrder); var req = new RestRequest("order/{0}rest/placechangeequityorder.json".Put(_sandboxStr)); var client = CreateClient(); client.Authenticator = _authenticator; req.XmlSerializer.ContentType = _xmlContentType; req.Method = Method.POST; req.RequestFormat = DataFormat.Xml; req.XmlSerializer.RootElement = "placeChangeEquityOrder"; req.RootElement = "placeChangeEquityOrderResponse"; // for response parsing req.AddBody(data, _orderNamespace); var response = ExecuteRequest <placeChangeEquityOrderResponse>(client, req); CheckResponse(response, "SendOrderChange"); return(response.Data.equityOrderResponse); }
public OEC.API.Order GetOecOrder(BusinessEntities.Order order) { if (!_versionOrderSet.ContainsValue(order)) { _connector.AddWarningLog("GetOecOrder({0}): команда не найдена", order.Id); return(null); } return(_versionOrderSet[order].Order); }
private static void FillOrderRequest(OrderRequestBase request, BusinessEntities.Order order) { request.accountId = order.Portfolio.Name.To <long>(); request.clientOrderId = order.TransactionId.To <string>(); request.allOrNone = order.TimeInForce == TimeInForce.MatchOrCancel; request.quantity = (int)order.Volume; if (order.ExpiryDate == null || order.ExpiryDate == DateTimeOffset.MaxValue) { request.orderTerm = "GOOD_UNTIL_CANCEL"; } else if (order.ExpiryDate == DateTimeOffset.Now.Date) { request.orderTerm = "GOOD_FOR_DAY"; } else { throw new InvalidOperationException(LocalizedStrings.Str3354); } switch (order.Type) { case OrderTypes.Conditional: { var cond = (ETradeOrderCondition)order.Condition; switch (cond.StopType) { case ETradeStopTypes.StopLimit: request.priceType = "STOP_LIMIT"; request.limitPrice = (double)order.Price; request.stopPrice = (double)cond.StopPrice; break; case ETradeStopTypes.StopMarket: request.priceType = "STOP"; request.stopPrice = (double)cond.StopPrice; break; } break; } case OrderTypes.Limit: request.limitPrice = (double)order.Price; request.priceType = "LIMIT"; break; case OrderTypes.Market: request.priceType = "MARKET"; break; default: throw new InvalidOperationException(LocalizedStrings.Str1849Params.Put(order.Type)); } }
public void BindOrderToOecOrderVersion(BusinessEntities.Order order, OEC.API.Version ver) { if (ver.ID > 0) { order.Id = ver.ID; } if (_versionOrderSet.ContainsKey(ver)) { if (_versionOrderSet[ver] != order) { _connector.AddWarningLog("Старая версия заявки не была удалена из коллекции."); _versionOrderSet.Remove(ver); _versionOrderSet[ver] = order; } } else { _versionOrderSet[ver] = order; } }
public PlaceEquityOrderResponse2 SendOrder(BusinessEntities.Order order) { if (_authenticator == null) { throw new ETradeUnauthorizedException(LocalizedStrings.Str3350); } var data = new EquityOrderRequest { symbol = order.Security.Code, orderAction = order.Direction == Sides.Buy ? "BUY" : "SELL", marketSession = "REGULAR", routingDestination = "AUTO" }; FillOrderRequest(data, order); var req = new RestRequest("order/{0}rest/placeequityorder.json".Put(_sandboxStr)); var client = CreateClient(); client.Authenticator = _authenticator; req.XmlSerializer.ContentType = _xmlContentType; req.Method = Method.POST; req.RequestFormat = DataFormat.Xml; req.XmlSerializer.RootElement = "PlaceEquityOrder"; req.RootElement = "PlaceEquityOrderResponse"; // for response parsing req.AddBody(data, _orderNamespace); var response = ExecuteRequest <PlaceEquityOrderResponse>(client, req); CheckResponse(response, "SendOrder"); return(response.Data.EquityOrderResponse); }
public static bool IsOrderInFinalState(BusinessEntities.Order order) { return(order.State == OrderStates.Done || order.State == OrderStates.Failed); }
public ETradeReRegisterOrderRequest(int oldOrderId, BusinessEntities.Order newOrder) { _oldOrderId = oldOrderId; _newOrder = newOrder; }
public ETradeRegisterOrderRequest(BusinessEntities.Order order) { _order = order; }