Exemple #1
0
        public OrderNew SubmitLimitOrder(string pair, OrderSide side, decimal price, decimal qty)
        {
            if (!EnableLiveOrders)
            {
                cout("\nITBIT::SubmitLimitOrder=> '{0}' {1} {2} {3}\n", pair, side, price, qty);
                return(null);
            }
            //var ts = TickerSymbol.XBTEUR;    // XBTSGD, XBTUSD
            //var curcode = CurrencyCode.EUR; // SGD, USD, XBT
            TickerSymbol tickerSymbol;
            CurrencyCode currencyCode;

            if (!GetTickerSymbol(pair, out tickerSymbol, out currencyCode))
            {
                ErrorMessage("ItBit::SubmitLimitOrder=> Cannot convert '{0}' to Enums TickerSymbol and CurrencyCode", pair);
                return(null);
            }
            NewOrder order;

            if (side == OrderSide.Buy)
            {
                order = NewOrder.Buy(tickerSymbol, currencyCode, qty, price);
            }
            else
            {
                order = NewOrder.Sell(tickerSymbol, currencyCode, qty, price);
            }
            Guid wid = Guid.Empty;
            //var res = m_api.NewOrderAsync(wid, order).Result;
            var res = AsyncHelpers.RunSync <Order>(() => m_api.NewOrderAsync(wid, order));

            return(new OrderNew(pair, res));
        }