Ejemplo n.º 1
0
        /// <summary>
        /// Place a buy market order using the full allocation.
        /// </summary>
        /// <param name="pair">TradingPair to consider.</param>
        /// <param name="portion">The portion of funds to use, (0 ... 1).</param>
        /// <returns>ResponseObject with an OrderUpdate.</returns>
        public OrderUpdate ExecutePartialMarketOrderBuy(TradingPair pair, decimal portion)
        {
            Guard.Argument(pair).NotNull();
            Guard.Argument(portion).NotZero().NotNegative().InRange(0, 1);
            var currency = pair.Right;
            var balance  = _allocationManager.GetAvailableFunds(currency);
            var quantity = GetBuyQuantityEstimate(pair, balance.Free) * portion;

            if (quantity == 0.0M)
            {
                throw new OutOfFundsException();
            }

            return(ExecuteMarketOrderBuy(pair, quantity));
        }