valeratrades / discretionary_engine

LaTeX of trading
Apache License 2.0
0 stars 1 forks source link

debug STOP_MARKET orders placement #18

Closed valeratrades closed 3 weeks ago

valeratrades commented 3 weeks ago

Just had stop market's price be set to negative -0.00008. Probably the root cause

valeratrades commented 3 weeks ago

Fixed. But currently quantity is like 10, could that be the culprit?

valeratrades commented 3 weeks ago

Am I hard-setting the quantity?

valeratrades commented 3 weeks ago

... So in this particular case, after fixing the price, the quantity was indeed the root cause. But this is impossible to debug, as currently I'm just printing out

[src/exchange_apis/binance/mod.rs:204:2] &r = Response {
    url: Url {
        scheme: "https",
        cannot_be_a_base: false,
        username: "",
        password: None,
        host: Some(
            Domain(
                "fapi.binance.com",
            ),
        ),
        port: None,
        path: "/fapi/v1/order",
        query: Some(
            "quantity=10&timestamp=1718153016107&side=SELL&type=STOP_MARKET&symbol=ADAUSDT&stopPrice=0.42112&signature=fba9559cfbfbdb3b0bd96939eac80e4f985c722f5d9430cc95be78f01719982a",
        ),
        fragment: None,
    },
    status: 400,
    headers: {
        "date": "Wed, 12 Jun 2024 00:43:37 GMT",
        "content-type": "application/json",
        "content-length": "98",
        "connection": "keep-alive",
        "server": "Tengine",
        "x-mbx-used-weight-1m": "-1",
        "x-mbx-order-count-10s": "1",
        "x-mbx-order-count-1m": "1",
        "x-response-time": "6ms",
        "access-control-allow-origin": "*",
        "access-control-allow-methods": "GET, POST, PUT, DELETE, OPTIONS",
    },
}
thread 'tokio-runtime-worker' panicked at src/exchange_apis/binance/mod.rs:336:97:
called `Result::unwrap()` on an `Err` value: error decoding response body

Caused by:
    missing field `cumQuote` at line 1 column 98
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Error: reqwest::Error { kind: Decode, source: Error("missing field `cumQuote`", line: 1, column: 98) }
Response: "Response { url: Url { scheme: \"https\", cannot_be_a_base: false, username: \"\", password: None, host: Some(Domain(\"fapi.binance.com\")), port: None, path: \"/fapi/v1/order\", query: Some(\"quantity=10&timestamp=1718153016107&side=SELL&type=STOP_MARKET&symbol=ADAUSDT&stopPrice=0.42112&signature=fba9559cfbfbdb3b0bd96939eac80e4f985c722f5d9430cc95be78f01719982a\"), fragment: None }, status: 400, headers: {\"date\": \"Wed, 12 Jun 2024 00:43:37 GMT\", \"content-type\": \"application/json\", \"content-length\": \"98\", \"connection\": \"keep-alive\", \"server\": \"Tengine\", \"x-mbx-used-weight-1m\": \"-1\", \"x-mbx-order-count-10s\": \"1\", \"x-mbx-order-count-1m\": \"1\", \"x-response-time\": \"6ms\", \"access-control-allow-origin\": \"*\", \"access-control-allow-methods\": \"GET, POST, PUT, DELETE, OPTIONS\"} }"
valeratrades commented 3 weeks ago

Fix the error message on posting the orders, then move the rest of the exchange tests into integration