예제 #1
0
        public async Task <ServiceResponse> CheckIfBought()
        {
            var result = await _db.GetPendingBuyTransactions(_session.BaseCoin, _session.TargetCoin, _session.Stock);

            if (result.Success)
            {
                foreach (var item in result.Data)
                {
                    var serviceResult = await _service.GetOrder(_session.BaseCoin, _session.TargetCoin, _session.ApiKey, _session.Secret, item.BuyId);

                    if (serviceResult.Success)
                    {
                        if (!serviceResult.Data.IsOpen)
                        {
                            _logger.LogInformation(string.Format("Buy order id {0} finalized. Bought {1}", serviceResult.Data.OrderRefId, serviceResult.Data.Quantity));
                            await _db.TransactionBuyFinalized(item.Id, serviceResult.Data.Quantity);
                        }
                    }
                    return(new ServiceResponse(serviceResult.Status, serviceResult.Message));
                }
            }
            return(new ServiceResponse(result.Status, result.Message));
        }
예제 #2
0
        public async void GetOrder()
        {
            var result = await _service.GetOrder("BTC", "LTC", System.Environment.GetEnvironmentVariable("API_KEY"), System.Environment.GetEnvironmentVariable("SECRET"), "1");

            Assert.Equal(result.Message, "{\"code\":-2013,\"msg\":\"Order does not exist.\"}");
        }