protected override async Task <ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrderRequest order) { if (order.IsPostOnly != null) { throw new NotImplementedException("Post Only orders are not supported by this exchange or not implemented in ExchangeSharp. Please submit a PR if you are interested in this feature."); } var roundedAmount = order.RoundAmount(); var amountInt = converterToEight.FromDecimal(roundedAmount); var feeCurrency = (order.ExtraParameters.ContainsKey("fee_currency") ? order.ExtraParameters["fee_currency"] ?? DefaultFeeCurrency : DefaultFeeCurrency) .ToString() .ToUpperInvariant(); var data = new Dictionary <string, object> { { "amount_int", amountInt }, { "type", order.IsBuy ? "bid" : "ask" }, { "fee_currency", feeCurrency }, }; switch (order.OrderType) { case OrderType.Limit: if (order.Price == null) { throw new ArgumentNullException(nameof(order.Price)); } data["price_int"] = converterToFive.FromDecimal(order.Price.Value); break; case OrderType.Market: if (order.Price == null) { throw new ArgumentNullException(nameof(order.Price)); } data["amount_funds_int"] = converterToFive.FromDecimal(roundedAmount * order.Price.Value); break; default: throw new NotSupportedException($"{order.OrderType} is not supported"); } var resultBody = await MakeRequestAsync( $"/{order.MarketSymbol}/money/order/add", payload : data ); var result = JsonConvert.DeserializeObject <BL3POrderAddResponse>(resultBody) .Except(); var orderDetails = await GetOrderDetailsAsync(result.OrderId, marketSymbol : order.MarketSymbol); return(orderDetails); }
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) { var valueLong = converter.FromDecimal((decimal)value); writer.WriteValue(valueLong); }