wisespace-io / binance-rs

Rust Library for the Binance API
Other
640 stars 290 forks source link

Implement open_interest_statistics #140

Closed siegfried closed 2 years ago

siegfried commented 2 years ago

I'm stuck in creating open interest statistics API. A strange error happened. Could you help me take a look how to fix this? Thanks. @wisespace-io

running 1 test
test tests::open_interest_statistics ... FAILED

failures:

---- tests::open_interest_statistics stdout ----
thread 'tests::open_interest_statistics' panicked at 'called `Result::unwrap()` on an `Err` value: Error(ReqError(reqwest::Error { kind: Decode, source: Error("invalid type: integer `1638455400000`, expected a string", line: 1, column: 126) }), State { next_error: None, backtrace: InternalBacktrace })', tests/futures_market_test.rs:22:100
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

failures:
    tests::open_interest_statistics

test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.55s

error: test failed, to rerun pass '--test futures_market_test'
wisespace-io commented 2 years ago

@siegfried there are some mistakes, but also Binance documentation does not match the data returned.

match market.open_interest_statistics("BTCUSDT", "5m", 10, None, None) {
    Ok(answer) => println!("Open interest: {:?}", answer),
    Err(e) => println!("Error: {}", e),
}

Add to examples/binance_futures_endpoint.rs and you will see that timestamp is an integer, not a string.

siegfried commented 2 years ago

Updated and it passed the test. Thanks for your help. Please review. @wisespace-io

siegfried commented 2 years ago

I removed the extra field to pass the check.

error: field is never read: `extra`
94
  --> src/errors.rs:11:5
95
   |
96
11 |     extra: HashMap<String, Value>,
97
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98
   |
99
   = note: `-D dead-code` implied by `-D warnings`
wisespace-io commented 2 years ago

@siegfried thank you for the fixes and the new feature.