c# binance api открытие ордера
Уже второй день ломаю голову, где-то замылился взгляд. Пытаюсь открыть тестовый ордер на binance. Вот код:
internal class Credentials
{
[JsonProperty("symbol")]
public string Symbol { get; set; }
[JsonProperty("side")]
public string Side { get; set; }
[JsonProperty("type")]
public string Type { get; set; }
[JsonProperty("timeInForce")]
public string TimeInForce { get; set; }
[JsonProperty("quantity")]
public decimal Quantity { get; set; }
[JsonProperty("price")]
public decimal Price { get; set; }
[JsonProperty("recvWindow")]
public int RecvWindow { get; set; }
[JsonProperty("timestamp")]
public string Timestamp { get; set; }
}
//открытие позиции
public async void CreateOrder(string instrument_name, string side, string type, double price, double quantity)
{
string path = "/api/v3/order/test?";
string timeInForce = "GTC";
int recvWindow = 5000;
string time = GetTimestamp();
string sign = GetSign_binance("symbol=" + instrument_name + "&side=" + side + "&type=" + type + "&timeInForce=" + timeInForce + "&quantity=" + Convert.ToDecimal(quantity) + "&price=" + Convert.ToDecimal(price) + "&recvWindow=" + recvWindow + "×tamp=" + time);
string url = API_URL_binance + path + "symbol=" + instrument_name + "&side=" + side + "&type=" + type + "&timeInForce=" + timeInForce + "&quantity=" + Convert.ToDecimal(quantity).ToString().Replace(",", ".") + "&price=" + Convert.ToDecimal(price).ToString().Replace(",", ".") + "&recvWindow=" + recvWindow + "×tamp=" + time + "&signature=" + sign;
string r;
var Payload = new Credentials
{
Symbol = instrument_name,
Side = side,
Type = type,
Quantity = Convert.ToDecimal(quantity),
Price = Convert.ToDecimal(price),
TimeInForce = timeInForce,
RecvWindow = recvWindow,
Timestamp = time
};
var stringPayload = JsonConvert.SerializeObject(Payload);
HttpContent httpContent = new StringContent(stringPayload, Encoding.UTF8, "application/x-www-form-urlencoded");
top.Invoke((ThreadStart)delegate ()
{
top.AppendText(DateTime.Now + " " + stringPayload + "\r\n");
});
System.Diagnostics.Stopwatch sw = new Stopwatch();
using (var response = await client_binance.PostAsync(url, httpContent).ConfigureAwait(false))
r = await response.Content.ReadAsStringAsync().ConfigureAwait(false);
sw.Stop();
top.Invoke((ThreadStart)delegate ()
{
top.AppendText(DateTime.Now + " " + r + "\r\n");
top.AppendText(DateTime.Now + " " + url + " Время запроса: " + sw.ElapsedMilliseconds + "\r\n");
});
}
На выходе получаю ошибку:
{
"code":-1104,
"msg":"Not all sent parameters were read; read '9' parameter(s) but was sent '10'."
}
Соответственно отправляемый json
{
"symbol":"BUSDUSDT",
"side":"BUY",
"type":"LIMIT",
"timeInForce":"GTC",
"quantity":10.1,
"price":0.9994,
"recvWindow":5000,
"timestamp":"1639325197716"
}
И ссылка куда отправляю:
api3.binance.com/api/v3/order/test?symbol=BUSDUSDT&side=BUY&type=LIMIT&timeInForce=GTC&quantity=10.1&price=0.9994&recvWindow=5000×tamp=1639325197716&signature=307dc0dce20835f3a80e40f11406d446d9f20e5edfdf5300229ddd026bef6b8c
Что я делаю не так?