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));
        }
        public async void CanPlaceAndCancelAndOrder()
        {
            var buyOrder = NewOrder.Buy(TickerSymbol.XBTUSD, CurrencyCode.XBT, 1, 210);
            var newOrder = await _client.NewOrderAsync(_walletId, buyOrder);

            var order = await _client.GetOrderAsync(_walletId, newOrder.Id);

            await _client.CancelOrderAsync(_walletId, order.Id);

            order = await _client.GetOrderAsync(_walletId, newOrder.Id);

            Assert.AreEqual(OrderStatus.cancelled, order.Status);
        }