Exemplo n.º 1
0
 public IqOptionApiClient(IqAccount account)
 {
     Account = account;
     Client  = new IqOptionWebSocketClient(ws =>
     {
         ws.OpenSecuredSocketAsync(account.Ssid);
     });
 }
Exemplo n.º 2
0
        public async Task AppendUser(IqAccount account, IObservable <InfoData> openedPositionObservable)
        {
            var ct = new CancellationToken();

            //check if not existing
            if (Followers.All(x => x.Account.IqOptionUserName != account.IqOptionUserName))
            {
                var client    = new IqOptionApiClient(account);
                var isConnect = await client.Client.OpenSecuredSocketAsync(account.Ssid);

                if (!isConnect)
                {
                    //if ssid not working -re get ssid
                    var loginResult = await _commandBus.PublishAsync(
                        new IqLoginCommand(IqOptionIdentity.New, account.IqOptionUserName, account.Password), ct);

                    if (!loginResult.IsSuccess)
                    {
                        _logger.LogWarning(new StringBuilder($"Skipped {account.IqOptionUserName} due can't not loggin {loginResult.Message}")
                                           .ToString());
                        client.Dispose();

                        await _commandBus.PublishAsync(new SetActiveAccountcommand(IqOptionIdentity.New, false, account.IqOptionUserId), ct);

                        return;
                    }

                    await _commandBus.PublishAsync(
                        new StoreSsidCommand(IqOptionIdentity.New, account.IqOptionUserName, loginResult.Ssid), ct);
                }

                client.SubScribeForTraderStream(openedPositionObservable);


                Followers.Add(client);


                _logger.LogInformation(new StringBuilder($"Add {account.IqOptionUserName},")
                                       .AppendLine($"Now trading-followers account = {Followers.Count} Account(s).").ToString());
            }
        }
Exemplo n.º 3
0
 public IqOptionApiClient([NotNull] IqAccount account)
 {
     Account = account;
     Client  = new IqOptionWebSocketClient();
 }