Ejemplo n.º 1
0
        public Task <ShortOrder> PlaceOrder(
            string instrument,
            PlaceOrderCommand request,
            CancellationToken ct = default(CancellationToken))
        {
            return(EpochNonce.Lock(_credentials.ApiKey, async nonce =>
            {
                var cmd = new PlaceOrderRequest(_credentials, nonce)
                {
                    Amount = request.Amount,
                    OrderType = request.OrderType,
                    Price = request.Price
                };

                var(symbol1, symbol2) =
                    CexIoInstrument.FromInstrument(CexIoInstrument.FromLykkeInstrument(instrument, _currencyMapping));

                using (var response = await _client.PostAsJsonAsync($"place_order/{symbol1}/{symbol2}", cmd, ct))
                {
                    response.EnsureSuccessStatusCode();

                    var token = await response.Content.ReadAsAsync <JToken>(ct);

                    EnsureSuccessContent(token);

                    return token.ToObject <ShortOrder>();
                }
            }));
        }
Ejemplo n.º 2
0
        public async Task <OrderBookSnapshot> GetOrderBook(
            string instrument,
            CancellationToken ct = default(CancellationToken))
        {
            var(symbol1, symbol2) = CexIoInstrument.FromInstrument(instrument);

            using (var r = await _client.GetAsync($"order_book/{symbol1}/{symbol2}", ct))
            {
                return(await r.Content.ReadAsAsync <OrderBookSnapshot>(ct));
            }
        }