Binance Add Limit Order C#

Viewed 41

I'm trying to add a limit order through binance api and i keep getting BADREQUEST on return. I have for the life of me no idea when went wrong with my request.

Here is a snippit of my code....

Things i know for sure are correct is calculating the signature and making the async post. RestWrap is just a wrapper around RestClient/RestSharp

private async Task<string> PlaceOrder(string symbol, MMSide side, MMOrderType type, MMTimeInForce tif, double qty, double price)
{
    RestWrap rs = new RestWrap(REST_URL);

    var headers = new Dictionary<string, string>()
    {
        { "X-MBX-APIKEY", api_key },
    };

    var parameters = new Dictionary<string, string>()
    {
        { "symbol", symbol },
        { "side", side.ToString() },
        { "type", type.ToString() },
        { "timeInForce", tif.ToString() },
        { "quantity", qty.ToString() },
        { "price", price.ToString() },
        //{ "recvWindow", "5000" },
        { "timestamp", DateTime.UtcNow.ToEpochTimeMilliSec().ToString() },
    };

    var signature = CommonUtil.GetHMACInHex(api_secret, parameters.ToQueryString());
    parameters.Add("signature", signature);

    var bytes = await rs.AsyncPost("/api/v3/order", headers, parameters);

    return Encoding.UTF8.GetString(bytes);
}

public async override Task<string> PlaceLimitOrder(string symbol, MMSide side, double qty, double price)
{
    return await PlaceOrder(symbol, side, MMOrderType.LIMIT, MMTimeInForce.GTC, qty, price);
}
0 Answers
Related