Ejemplo n.º 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 * 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);
 }
Ejemplo n.º 2
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);
 }