Example #1
0
        private async Task <List <GridBotWithExchangeInfo> > GetGridBotsByScope(BotScope scope, Guid xCommasAccount, int[] accountIds)
        {
            var bots = new List <GridBot>();
            int take = 10;
            int skip = 0;

            int loopCount = 0;

            while (true)
            {
                var response = await _3CommasClients[xCommasAccount].Item2.GetGridBotsAsync(accountIds: accountIds, limit: take, offset: skip, botState: scope);
                if (!response.IsSuccess)
                {
                    throw new Exception($"Problem with 3Commas connection (Account: '{_3CommasClients[xCommasAccount].Item1}'): " + response.Error);
                }
                if (response.Data.Length == 0)
                {
                    break;
                }

                if (loopCount == 100)
                {
                    _logger.LogError($"Could not load bots. Last Response:  Success: {response.IsSuccess}  Raw Data: {response.RawData}  Error: {response.Error}  Data Count: {response.Data?.Length}");
                    break;
                }

                bots.AddRange(response.Data);
                skip += take;

                loopCount++;
            }

            return(bots.Select(bot => new GridBotWithExchangeInfo(xCommasAccount, _3CommasClients[xCommasAccount].Item1, bot)).ToList());
        }
Example #2
0
        public async Task <XCommasResponse <Bot[]> > GetBotsAsync(int limit = 50, int?offset = null, int?accountId = null, int?botId = null, BotScope botScope = BotScope.Enabled, Strategy strategy = Strategy.Long)
        {
            var path = $"{BaseAddress}/ver1/bots?limit={limit}&offset={offset}&account_id={accountId}&bot_id={botId}&scope={botScope.GetEnumMemberAttrValue()}&strategy={strategy.GetEnumMemberAttrValue()}";

            using (var request = XCommasRequest.Get(path).Sign(this))
            {
                return(await this.GetResponse <Bot[]>(request).ConfigureAwait(false));
            }
        }
Example #3
0
 public XCommasResponse <Bot[]> GetBots(int limit = 50, int?offset = null, int?accountId = null, int?botId = null, BotScope botScope = BotScope.Enabled, Strategy strategy = Strategy.Long) => this.GetBotsAsync(limit, offset, accountId, botId, botScope, strategy).Result;
        private async Task <List <Bot> > GetBotsByStrategyAndScope(Strategy strategy, BotScope scope)
        {
            var bots = new List <Bot>();
            int take = 100;
            int skip = 0;

            while (true)
            {
                var result = await _xCommasClient.GetBotsAsync(limit : take, offset : skip, strategy : strategy, botScope : scope);

                if (!result.IsSuccess)
                {
                    throw new Exception("3Commas Connection Issue: " + result.Error);
                }
                if (result.Data.Length == 0)
                {
                    break;
                }

                bots.AddRange(result.Data);
                skip += take;
            }

            return(bots);
        }
Example #5
0
        public async Task <XCommasResponse <GridBot[]> > GetGridBotsAsync(int limit = 10, int?offset = null, int[] accountIds = null, string accountTypes = null, BotScope botState = BotScope.Enabled, string sortBy = "bot_id", string sortDirection = "asc")
        {
            var path = $"{BaseAddress}/ver1/grid_bots?limit={limit}&offset={offset}&state={botState.GetEnumMemberAttrValue()}&sort_by={sortBy}&sort_direction={sortDirection}";

            using (var request = XCommasRequest.Get(path).Sign(this))
            {
                return(await this.GetResponse <GridBot[]>(request).ConfigureAwait(false));
            }
        }
Example #6
0
 public XCommasResponse <GridBot[]> GetGridBots(int limit = 10, int?offset = null, int[] accountIds = null, string accountTypes = null, BotScope botState = BotScope.Enabled, string sortBy = "bot_id", string sortDirection = "asc") => this.GetGridBotsAsync(limit, offset, accountIds, accountTypes, botState, sortBy, sortDirection).Result;
 public async Task <XCommasResponse <Bot[]> > GetBotsAsync(int limit, int offset, Strategy strategy, BotScope botScope)
 {
     return(await _3CommasClient.GetBotsAsync(limit, offset, strategy : strategy, botScope : botScope));
 }