Пример #1
0
        public override async Task <ExecutionReport> GetOrder(string id, Instrument instrument, TimeSpan timeout)
        {
            var filterObj = new { orderID = id };
            var filterArg = JsonConvert.SerializeObject(filterObj);
            var cts       = new CancellationTokenSource(timeout);
            var response  = await _exchangeApi.OrdergetOrdersAsync(filter : filterArg, cancellationToken : cts.Token);

            var res = EnsureCorrectResponse(id, response);

            return(BitMexModelConverter.OrderToTrade(res[0]));
        }
        public override async Task <ExecutionReport> GetOrder(string id, Instrument instrument, TimeSpan timeout)
        {
            if (!long.TryParse(id, out var orderId))
            {
                throw new ApiException("Bitfinex order id can be only integer");
            }
            var cts      = new CancellationTokenSource(timeout);
            var response = await _exchangeApi.GetOrderStatus(orderId, cts.Token);

            if (response is Error error)
            {
                throw new ApiException(error.Message);
            }
            var trade = OrderToTrade((Order)response);

            return(trade);
        }
Пример #3
0
        public static ExecutionReport OrderToTrade(Order order)
        {
            var execTime   = order.TransactTime ?? DateTime.UtcNow;
            var execPrice  = (decimal)(order.AvgPx ?? 0);
            var execVolume = (decimal)(order.CumQty ?? 0);
            var tradeType  = ConvertTradeType(order.Side);
            var status     = ConvertExecutionStatus(order.OrdStatus);
            //  var instr = ConvertSymbolFromBitMexToLykke(order.Symbol, configuration);
            var instr = new Instrument(BitMexExchange.Name, "USDBTC"); //HACK Hard code!

            return(new ExecutionReport(instr, execTime, execPrice, execVolume, tradeType, order.OrderID, status)
            {
                ClientOrderId = order.ClOrdID,
                Message = order.Text,
                Success = true,
                OrderType = ConvertOrderType(order.OrdType),
                ExecType = ExecType.Trade,
                FailureType = OrderStatusUpdateFailureType.None
            });
        }
        private static Instrument GetInstrument()
        {
            var instr = new Instrument(BitMexExchange.Name, "USDBTC"); //HACK Hard code!

            return(instr);
        }