public Account(string name, IConnection connection, IApiObjectsFactory factory, IExecutionStorageInternal executionStorage, IPositionsStorageInternal positionsesStorageInternal, IOrdersStorageInternal ordersStorageInternal, IIdsDispenser idsDispenser, CancellationTokenSource internalCancelationTokenSource, AccountCurrenciesFields accountCurrenciesFields) { CodeContract.Requires(!string.IsNullOrEmpty(name)); CodeContract.Requires(connection != null); CodeContract.Requires(factory != null); CodeContract.Requires(executionStorage != null); CodeContract.Requires(positionsesStorageInternal != null); CodeContract.Requires(ordersStorageInternal != null); CodeContract.Requires(accountCurrenciesFields != null); CodeContract.Requires(idsDispenser != null); this.AccountName = name; this.AccountId = name; this.factory = factory; this.executionStorage = executionStorage; this.positionsesStorage = positionsesStorageInternal; this.ordersStorage = ordersStorageInternal; this.accountCurrenciesFields = accountCurrenciesFields; this.idsDispenser = idsDispenser; this.internalCancelationTokenSource = internalCancelationTokenSource; this.subscription = connection.Subscribe((AccountValueMessage message) => message.AccountName == this.AccountName, this.OnAccountValueMessage); }
public PositionsStorage(IConnection connection, IApiObjectsFactory objectsFactory, string accountName) { System.Diagnostics.Contracts.Contract.Requires(connection != null); System.Diagnostics.Contracts.Contract.Requires(objectsFactory != null); System.Diagnostics.Contracts.Contract.Requires(!string.IsNullOrEmpty(accountName)); this.objectsFactory = objectsFactory; this.accountName = accountName; this.Subscribe(connection); }
public OrdersStorage(IConnection connection, IApiObjectsFactory objectsFactory, string accountName) { Contract.Requires(connection != null); Contract.Requires(objectsFactory != null); this.objectsFactory = objectsFactory; this.accountName = accountName; this.Subscribe(connection); }
public Order(int id, string account, IConnection connection, IApiObjectsFactory factory, CancellationTokenSource internaCancellationTokenSource) { CodeContract.Requires(connection != null); CodeContract.Requires(factory != null); this.factory = factory; this.internaCancellationTokenSource = internaCancellationTokenSource; this.Id = id; this.Subscribe(connection); this.Account = account; }
public CreateAccountStorageOperation(CancellationToken cancellationToken, IApiObjectsFactory factory, IConnection connection, string[] managedAccountsList) { Contract.Requires(factory != null); Contract.Requires(connection != null); Contract.Requires(managedAccountsList != null && managedAccountsList.Length > 0); SendAutoOpenOrdersRequest(connection); this.CreateAndWaitAccounts(managedAccountsList, factory, connection, cancellationToken); }
public Client(IApiObjectsFactory objectsFactory, IAccountsStorage accountsStorage, Dispatcher dispatcher, IConnection connection, CancellationTokenSource internalCancelationTokenSource) { CodeContract.Requires(objectsFactory != null); CodeContract.Requires(accountsStorage != null); CodeContract.Requires(dispatcher != null); CodeContract.Requires(connection != null); CodeContract.Requires(accountsStorage.Accounts.Count() != 0); this.objectsFactory = objectsFactory; this.accountsStorage = accountsStorage; this.dispatcher = dispatcher; this.internalCancelationTokenSource = internalCancelationTokenSource; this.accountChangedEvent = dispatcher.RegisterEvent(); connection.OnDisconnect += this.ConnectionOnOnDisconnect; }
public CreateAccountOperation(IConnection connection, IApiObjectsFactory factory, string account, CancellationToken cancellationToken) { Contract.Requires(connection != null); Contract.Requires(factory != null); Contract.Requires(!string.IsNullOrEmpty(account)); this.factory = factory; this.account = account; this.cancellationToken = cancellationToken; this.cancellationToken.Register(() => this.taskCompletionSource.TrySetCanceled()); this.positionStorage = this.factory.CreatePositionStorage(account); this.ordersStorage = this.factory.CreateOrdersStorage(account); this.createExecutionsStorage = factory.CreateExecutionStorageOperation(account, cancellationToken); this.Subscribe(connection); this.SendRequest(connection); }
private async void CreateAndWaitAccounts(string[] managedAccountsList, IApiObjectsFactory factory, IConnection connection, CancellationToken cancellationToken) { var tasks = managedAccountsList.Select(account => factory.CreateAccountOperation(account, cancellationToken)) .ToList(); SendAutoOpenOrdersRequest(connection); var accounts = new List<IAccountInternal>(); foreach (var task in tasks) { accounts.Add(await task); } this.taskCompletionSource.SetResult(factory.CreateAccountStorage(accounts)); }
public CreateExecutionsStorageOperation(IConnection connection, IIdsDispenser dispenser, CancellationToken cancellationToken, IApiObjectsFactory factory, string account) { Contract.Requires(connection != null); Contract.Requires(factory != null); Contract.Requires(account != null); this.connection = connection; this.cancellationToken = cancellationToken; this.factory = factory; this.cancellationToken.Register(() => { this.subscriptions.Unsubscribe(); this.taskCompletionSource.TrySetCanceled(); }); this.account = account; this.Subscribe(dispenser); }