public ETradeApi(ETradeClient client) { if (client == null) { throw new ArgumentNullException("client"); } _client = client; }
protected ETradeModule(string name, ETradeClient client) { _name = name; Client = client; Client.Connection.ConnectionStateChanged += HandleClientState; _wakeupTimer.AutoReset = false; _wakeupTimer.Enabled = false; _wakeupTimer.Elapsed += (sender, args) => _wakeupEvt.Set(); }
public ETradeResponse ExecuteNextPart(ETradeClient client) { IsDone = false; var response = ExecuteNextPartInternal(client.Api); IsDone = GetIsDone() || response.Exception != null; if (response.Exception != null) { client.AddWarningLog("Request '{0}' completed with exception: {1}", GetType().Name, response.Exception); } return(response); }
public ETradeConnection(ETradeClient client) { _client = client; _authorizationAction = DefaultAuthorizationAction; }
public ETradeConnection(ETradeClient client) { _client = client; _authorizationAction = DefaultAuthorizationAction; }
/// <summary> /// Send incoming message. /// </summary> /// <param name="message">Message.</param> protected override void OnSendInMessage(Message message) { switch (message.Type) { case MessageTypes.Reset: { if (_client != null) { try { DisposeClient(); } catch (Exception ex) { SendOutError(ex); } _client = null; } SendOutMessage(new ResetMessage()); break; } case MessageTypes.Connect: { if (_client != null) throw new InvalidOperationException(LocalizedStrings.Str1619); _client = new ETradeClient { ConsumerKey = ConsumerKey, ConsumerSecret = ConsumerSecret, AccessToken = AccessToken, Sandbox = Sandbox, VerificationCode = VerificationCode, }; _client.ConnectionStateChanged += ClientOnConnectionStateChanged; _client.ConnectionError += ClientOnConnectionError; _client.Error += SendOutError; _client.OrderRegisterResult += ClientOnOrderRegisterResult; _client.OrderReRegisterResult += ClientOnOrderRegisterResult; _client.OrderCancelResult += ClientOnOrderCancelResult; _client.AccountsData += ClientOnAccountsData; _client.PositionsData += ClientOnPositionsData; _client.OrdersData += ClientOnOrdersData; _client.ProductLookupResult += ClientOnProductLookupResult; _client.Parent = this; _client.Connect(); break; } case MessageTypes.Disconnect: { if (_client == null) throw new InvalidOperationException(LocalizedStrings.Str1856); DisposeClient(); _client = null; break; } case MessageTypes.SecurityLookup: { var lookupMsg = (SecurityLookupMessage)message; _client.LookupSecurities(lookupMsg.SecurityId.SecurityCode, lookupMsg.TransactionId); break; } case MessageTypes.OrderRegister: { var regMsg = (OrderRegisterMessage)message; _client.RegisterOrder( regMsg.PortfolioName, regMsg.SecurityId.SecurityCode, regMsg.Side, regMsg.Price, regMsg.Volume, regMsg.TransactionId, regMsg.TimeInForce == TimeInForce.MatchOrCancel, regMsg.TillDate, regMsg.OrderType, (ETradeOrderCondition)regMsg.Condition); break; } case MessageTypes.OrderReplace: { var replaceMsg = (OrderReplaceMessage)message; if (replaceMsg.OldOrderId == null) throw new InvalidOperationException(LocalizedStrings.Str2252Params.Put(replaceMsg.OldTransactionId)); SaveOrder(replaceMsg.OldTransactionId, replaceMsg.OldOrderId.Value); _client.ReRegisterOrder( replaceMsg.OldOrderId.Value, replaceMsg.PortfolioName, replaceMsg.Price, replaceMsg.Volume, replaceMsg.TransactionId, replaceMsg.TimeInForce == TimeInForce.MatchOrCancel, replaceMsg.TillDate, replaceMsg.OrderType, (ETradeOrderCondition)replaceMsg.Condition); break; } case MessageTypes.OrderCancel: { var cancelMsg = (OrderCancelMessage)message; if (cancelMsg.OrderId == null) throw new InvalidOperationException(LocalizedStrings.Str2252Params.Put(cancelMsg.OrderTransactionId)); _client.CancelOrder(cancelMsg.TransactionId, cancelMsg.OrderId.Value, cancelMsg.PortfolioName); break; } } }
public ETradeMarketModule(ETradeClient client) : base("market", client) { }
public ETradeOrderModule(ETradeClient client) : base("order", client) { }
public ETradeAccountsModule(ETradeClient client) : base("accounts", client) { }