コード例 #1
0
 public decimal PerformBuy(decimal count = -1)
 {
     count = (count <= 0m ? BuyUnits : count);
     if (CashFlow >= ((decimal)TradeInfo.Trade.Price * count))
     {
         // buy one
         decimal actualBuyPrice = ((decimal)TradeInfo.Trade.Price);
         actualBuyPrice += (actualBuyPrice * OrderPriceDifferentialPercentage);
         if (ProductionMode)
         {
             TradeInfo.ExchangeInfo.API.PlaceOrdersAsync(
                 new ExchangeOrderRequest
             {
                 Amount            = count,
                 IsBuy             = true,
                 Price             = actualBuyPrice,
                 ShouldRoundAmount = false,
                 Symbol            = null //todo TradeInfo.Symbol
             }).Sync();
         }
         else
         {
             actualBuyPrice += (actualBuyPrice * FeePercentage);
             CashFlow       -= actualBuyPrice;
             ItemCount      += count;
             BuyPrices.Add(new KeyValuePair <float, float>(TradeInfo.Trade.Ticks, TradeInfo.Trade.Price));
         }
         Buys++;
         Spend += actualBuyPrice * count;
         UpdateAmounts();
         return(count);
     }
     return(0m);
 }
コード例 #2
0
ファイル: Trader.cs プロジェクト: fenix2222/ExchangeSharp
 public decimal PerformBuy(decimal count = -1)
 {
     count = (count <= 0m ? BuyUnits : count);
     if (CashFlow >= ((decimal)TradeInfo.Trade.Price * count))
     {
         // buy one
         decimal actualBuyPrice = ((decimal)TradeInfo.Trade.Price * count);
         actualBuyPrice += (actualBuyPrice * OrderPriceDifferentialPercentage);
         if (ProductionMode)
         {
             TradeInfo.ExchangeInfo.API.PlaceOrder(TradeInfo.Symbol, count, actualBuyPrice, true);
         }
         else
         {
             actualBuyPrice += (actualBuyPrice * FeePercentage);
             CashFlow       -= actualBuyPrice;
             ItemCount      += count;
             Spend          += actualBuyPrice;
             BuyPrices.Add(new KeyValuePair <float, float>(TradeInfo.Trade.Ticks, TradeInfo.Trade.Price));
         }
         Buys++;
         UpdateAmounts();
         return(count);
     }
     return(0m);
 }
コード例 #3
0
ファイル: Item.cs プロジェクト: Kalavarda/AA
        /// <summary>
        /// Стоимость покупки за основную валюту
        /// </summary>
        public decimal?GetBuyCost(Data data, decimal count = 1)
        {
            if (data.MainCurrency == null)
            {
                return(null);
            }

            var mainCurrencyId = data.MainCurrency.Id;
            var mainPrice      = BuyPrices.FirstOrDefault(p => p.CurrencyId == mainCurrencyId);

            if (mainPrice != null)
            {
                return(mainPrice.Value * count);
            }

            return(null);
        }