Esempio n. 1
0
        public async Task <IEnumerable <Interface.Model.Order> > GetOpenOrdersAsync(Interface.Model.User user, string symbol = null, long recWindow = 0, Action <Exception> exception = default(Action <Exception>), CancellationToken cancellationToken = default(CancellationToken))
        {
            var apiUser = new BinanceApiUser(user.ApiKey, user.ApiSecret);
            var result  = await binanceApi.GetOpenOrdersAsync(apiUser, symbol, recWindow, cancellationToken).ConfigureAwait(false);

            var orders = result.Select(o => NewOrder(user, o)).ToList();

            return(orders);
        }
Esempio n. 2
0
        private async Task <ImmutableList <Order> > InitializeOpenOrders(string symbol)
        {
            using (var user = new BinanceApiUser(_config.Key, _config.Secret))
            {
                var openOrders = await _binanceApi.GetOpenOrdersAsync(user, symbol, 10000000);

                var immutableOrders = openOrders.ToImmutableList();

                _cache.SetOrders(symbol, immutableOrders);

                return(immutableOrders);
            }
        }
        private async Task <ImmutableList <Order> > InitializeOpenOrders(string symbol)
        {
            try
            {
                using (var user = new BinanceApiUser(_config.Key, _config.Secret))
                {
                    var openOrders = await _binanceApi.GetOpenOrdersAsync(user, symbol, 10000000);

                    var immutableOrders = openOrders.ToImmutableList();

                    _cache.SetOrders(symbol, immutableOrders);

                    return(immutableOrders);
                }
            }
            catch (Exception ex)
            {
                _cache.ClearOrders(symbol);

                _log.LogError($"Orders initialization error {ex.Message}");

                return(new List <Order>().ToImmutableList());
            }
        }