//[Fact] public async void RequestForQuoteTest() { var rfqRequest = new RequestForQuoteRequest("BTCUSD", Side.Buy, 1); var result = await _restClient.RequestForQuoteAsync(rfqRequest); Assert.NotNull(result); Assert.Equal(rfqRequest.Instrument + ".SPOT", result.Instrument); Assert.Equal(rfqRequest.Quantity, result.Quantity); Assert.Equal(rfqRequest.ClientRfqId, result.ClientRfqId); Assert.Equal(rfqRequest.Side, result.Side); Assert.True(result.Price > 0); Assert.NotEmpty(result.Id); Assert.NotEqual(default(DateTime), result.ValidUntil); }
private async Task <ExternalTrade> ExecuteLimitOrderAsync(string assetPairId, decimal volume, decimal?price, Side side) { string instrument = await GetInstrumentAsync(assetPairId); var request = new RequestForQuoteRequest(instrument, side, volume); RequestForQuoteResponse response; Trade trade = await WrapAsync(async() => { _log.InfoWithDetails("Get quote request", request); response = await _client.RequestForQuoteAsync(request); _log.InfoWithDetails("Get quote response", response); if (price.HasValue) { if (side == Side.Sell && price.Value > response.Price) { throw new NotEnoughLiquidityException(); } if (side == Side.Buy && price.Value < response.Price) { throw new NotEnoughLiquidityException(); } } var tradeRequest = new TradeRequest(response); _log.InfoWithDetails("Execute trade request", tradeRequest); Trade tradeResponse = await _client.TradeAsync(tradeRequest); _log.InfoWithDetails("Execute trade response", tradeResponse); return(tradeResponse); }); return(new ExternalTrade { Id = trade.TradeId, LimitOrderId = trade.Order, AssetPairId = trade.Instrument, Type = trade.Side == Side.Sell ? TradeType.Sell : TradeType.Buy, Time = trade.Created, Price = trade.Price, Volume = trade.Quantity, RequestId = trade.RfqId }); }