Ejemplo n.º 1
0
        private async Task ApplyBidStrategy(Trading activeTrading, TradingTransaction order)
        {
            if (order.OrderStatusId == (int)OrderStatusEnum.Open)
            {
                var result = (await _tradingApi.GetOrder <TradingOrder>(TradingContants.Bids, order.ExchangeOperationId))
                             .Details.Attributes;

                if (result.Status == TradingContants.OpenStatus)
                {
                    var actualBtcPrice = (await _tradingApi.GetBtcPrice <Cryptocurrency>()).Details.Price;

                    if (order.CryptocurrencyPrice.CalculatePercentDiference(actualBtcPrice) >= percentToleranceMargin)
                    {
                        await CancelAndUpdateOrder(activeTrading, OrderStatusEnum.CanceledByPriceChange);
                    }
                }

                if (result.Status == TradingContants.CancelledStatus)
                {
                    await CancelAndUpdateOrder(activeTrading, OrderStatusEnum.ManuallyCanceled);
                }

                if (result.Status == TradingContants.Finished)
                {
                    await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, OrderStatusEnum.Finished);
                    await SetAskOrder(activeTrading);
                }
            }
        }
Ejemplo n.º 2
0
        private async Task ApplyAskStrategy(Trading activeTrading, TradingTransaction order)
        {
            if (order.OrderStatusId == (int)OrderStatusEnum.Open)
            {
                var orderStatus = (await _tradingApi.GetOrder <TradingOrder>(TradingContants.Aks, order.ExchangeOperationId))
                                  .Details.Attributes.Status;

                if (orderStatus != TradingContants.OpenStatus)
                {
                    await _strategyDatabaseAccess.UpdateOrderStatus(activeTrading, orderStatus.BitexStatusToDatabase());
                    await SetAskOrder(activeTrading);
                }
            }
        }