コード例 #1
0
        public async Task <bool> Delete(CoinBuy contract)
        {
            var entity = ContractToEntity(contract);
            var result = await _cbRepo.Delete(entity);

            return(result);
        }
コード例 #2
0
        public async Task <CoinBuy> Update(CoinBuy contract)
        {
            var entity = ContractToEntity(contract);

            entity = await _cbRepo.Update(entity);

            return(EntityToContract(entity));
        }
コード例 #3
0
        /// <summary>
        /// Create a CoinBuy from an ExchangeHub OrderResponse
        /// </summary>
        /// <param name="order">OrderResponse to convert</param>
        /// <returns>new CoinBuy object</returns>
        private CoinBuy ExchangeOrderToCoinBuy(ExchangeOrder order, Exchange exchange, decimal quantity = 0)
        {
            var coinBuy = new CoinBuy(order);

            coinBuy.BTCPrice        = coinBuy.Pair.EndsWith("BTC") ? order.Price : 0;
            coinBuy.QuantityApplied = quantity == 0 ? order.FilledQuantity : quantity;

            return(coinBuy);
        }
コード例 #4
0
        /// <summary>
        /// Create a CoinBuy from an ExchangeHub OrderResponse
        /// </summary>
        /// <param name="orderResponse">OrderResponse to convert</param>
        /// <param name="quantityApplied">Quantity to apply to this order</param>
        /// <returns>new CoinBuy object</returns>
        public CoinBuy GetCoinBuy(ExchangeHub.Contracts.OrderResponse orderResponse, decimal quantityApplied)
        {
            var coinBuy = new CoinBuy
            {
                BTCPrice   = orderResponse.Pair.EndsWith("BTC") ? orderResponse.Price : 0,
                Exchange   = StringToExchange(currentExchange),
                OrderId    = orderResponse.OrderId,
                Pair       = orderResponse.Pair,
                Price      = orderResponse.Price,
                Quantity   = quantityApplied,
                ClosedDate = orderResponse.TransactTime
            };

            return(coinBuy);
        }
コード例 #5
0
        /// <summary>
        /// Create a CoinBuy from an ExchangeHub OrderResponse
        /// </summary>
        /// <param name="orderResponse">OrderResponse to convert</param>
        /// <returns>new CoinBuy object</returns>
        private CoinBuy OrderResponseToCoinBuy(OrderResponse orderResponse, Exchange exchange, decimal quantity = 0)
        {
            var coinBuy = new CoinBuy
            {
                BTCPrice       = orderResponse.Pair.EndsWith("BTC") ? orderResponse.Price : 0,
                Exchange       = exchange,
                OrderId        = orderResponse.OrderId,
                Pair           = orderResponse.Pair,
                Price          = orderResponse.Price,
                FilledQuantity = quantity == 0 ? orderResponse.FilledQuantity : quantity,
                Quantity       = orderResponse.OrderQuantity,
                ClosedDate     = orderResponse.TransactTime
            };

            return(coinBuy);
        }
コード例 #6
0
        /// <summary>
        /// Create a CoinBuy object from a transaction
        /// </summary>
        /// <param name="transaction">NewTransaction object</param>
        /// <returns>CoinBuy object</returns>
        private CoinBuy CreateCoinBuy(NewTransaction transaction)
        {
            var coinBuy = new CoinBuy
            {
                available       = transaction.quantity,
                buyDate         = transaction.date,
                coinSellList    = new List <CoinSell>(),
                fee             = transaction.fee,
                feeSymbol       = transaction.feeSymbol,
                pair            = transaction.pair,
                price           = transaction.price,
                quantity        = transaction.quantity,
                transactionType = transaction.transactionType
            };

            return(coinBuy);
        }
コード例 #7
0
        public void GetCoinBuyTest()
        {
            var orderResponse = testObjs.GetExchangeHubOrders().Where(o => o.Pair.Equals("BTCUSDT")).FirstOrDefault();
            var quantity      = 0.03M;
            var expected      = new CoinBuy
            {
                Exchange   = Cryptobitfolio.Business.Entities.Exchange.Binance,
                OrderId    = orderResponse.OrderId,
                Pair       = orderResponse.Pair,
                Price      = orderResponse.Price,
                Quantity   = quantity,
                ClosedDate = orderResponse.TransactTime
            };

            var coinBuy = exchangeBuilder.GetCoinBuy(orderResponse, quantity);

            Assert.Equal(expected.OrderId, coinBuy.OrderId);
            Assert.Equal(expected.Pair, coinBuy.Pair);
            Assert.Equal(expected.Price, coinBuy.Price);
            Assert.Equal(expected.ClosedDate, coinBuy.ClosedDate);
        }
コード例 #8
0
        private Entities.Portfolio.CoinBuy ContractToEntity(CoinBuy contract)
        {
            var entity = new Entities.Portfolio.CoinBuy
            {
                Id              = contract.CoinBuyId,
                Exchange        = contract.Exchange,
                OrderId         = contract.OrderId,
                Pair            = contract.Pair,
                Price           = contract.Price,
                FilledQuantity  = contract.FilledQuantity,
                Quantity        = contract.Quantity,
                PlaceDate       = contract.PlaceDate,
                BTCPrice        = contract.BTCPrice,
                ClosedDate      = contract.ClosedDate,
                CoinBuyId       = contract.CoinBuyId,
                QuantityApplied = contract.QuantityApplied,
                Side            = contract.Side,
                Status          = contract.Status
            };

            return(entity);
        }
コード例 #9
0
        private CoinBuy EntityToContract(Entities.Portfolio.CoinBuy entity)
        {
            var contract = new CoinBuy
            {
                CoinBuyId       = entity.Id,
                Exchange        = entity.Exchange,
                OrderId         = entity.OrderId,
                Pair            = entity.Pair,
                Price           = entity.Price,
                BTCPrice        = entity.BTCPrice,
                ClosedDate      = entity.ClosedDate,
                ExchangeOrderId = entity.Id,
                FilledQuantity  = entity.FilledQuantity,
                PlaceDate       = entity.PlaceDate,
                Quantity        = entity.Quantity,
                QuantityApplied = entity.QuantityApplied,
                Side            = entity.Side,
                Status          = entity.Status
            };

            return(contract);
        }