nash-io / openlimits

A Rust high performance cryptocurrency trading API with support for multiple exchanges and language wrappers.
http://openlimits.io
BSD 2-Clause "Simplified" License
280 stars 44 forks source link

Unable to login - Unknown variant #195

Open dh-nunes opened 3 years ago

dh-nunes commented 3 years ago

Trying to login to my regular account gives an error with: error decoding response body: unknown variant `RAW_REQUESTS`, expected `ORDERS` or `REQUEST_WEIGHT` at line 1 column 324

Code used:

let cred: BinanceCredentials;
if SANDBOX {
    cred = BinanceCredentials {
        api_key: TEST_KEY.to_string(),
        api_secret: TEST_SECRET.to_string(),
    };
} else {
    cred = BinanceCredentials {
        api_key: API_KEY.to_string(),
        api_secret: API_SECRET.to_string(),
    };
};
let params = BinanceParameters {
    sandbox: SANDBOX,
    credentials: Some(cred),
};
let client = Binance::new(params.clone()).await?;

When SANDBOX is true I can freely login but when it's false it gives the error above.

dh-nunes commented 3 years ago

Looks like it can be fixed by adding RawRequests to the RateLimitType enum here. I don't think anything is being done with this information (yet) so a quick fix looks possible

notdanilo commented 3 years ago

@GandaG both environments are tested in the PR above, so it should be working. Would you please check it after it's merged?

jhoogstraat commented 2 years ago

I just got the exact same error 0.3.0. Exact same code and error message as above.

mohamedabdelbary commented 2 years ago

hi everyone - any chance that this issue can be re-opened and looked into? I get exactly the same error and with similar code

    let api_key = std::env::var("BINANCE_API_KEY").expect("API key not supplied");
    let api_secret = std::env::var("BINANCE_API_SECRET").expect("API Secret not supplied");
    let creds = BinanceCredentials {
        api_key,
        api_secret,
    };
    let params = BinanceParameters { environment: Environment::Production, credentials: Some(creds) };
    let binance_exchange= Binance::new(params).await?;

running on v0.3.0

notdanilo commented 2 years ago

@mohamedabdelbary I also faced this few days ago. Maybe the API was updated. I will push a fix asap

mohamedabdelbary commented 2 years ago

@notdanilo thank you so much 🙂

mohamedabdelbary commented 2 years ago

hi @notdanilo - any update on this?

notdanilo commented 2 years ago

@mohamedabdelbary I just pushed a fix for it. Can you test it by grabbing the crate from git? I am not sure if I still have the credentials to publish the changes to crates.io, because I am no longer working at nash.

mohamedabdelbary commented 2 years ago

hi @notdanilo . Thanks for this. I'm trying to add the dependency directly from git in my Cargo.toml file. I get an error that looks like it's due to 2 versions of the library being installed.

error[E0308]: mismatched types
  --> trader/src/main.rs:17:51
   |
17 |     let params = BinanceParameters { environment: Environment::Production, credentials: Some(creds) };
   |                                                   ^^^^^^^^^^^^^^^^^^^^^^^ expected enum `openlimits_exchange::exchange::Environment`, found enum `Environment`
   |
   = note: perhaps two different versions of crate `openlimits_exchange` are being used?

error[E0599]: no function or associated item named `new` found for struct `Binance` in the current scope
  --> trader/src/main.rs:18:37

Seems it's more a Rust dependency management issue though than an openlimits issue. I can definitely see two versions of the library being installed

   Compiling openlimits-exchange v0.3.0
   Compiling openlimits-exchange v0.3.1-alpha.0 (https://github.com/nash-io/openlimits?rev=4137b08b#4137b08b)
   Compiling openlimits-binance v0.3.1-alpha.0 (https://github.com/nash-io/openlimits?rev=4137b08b#4137b08b)

I've already tried deleting the target dir and re-running the Cargo install several times and still no luck. The relevant lines in my Cargo.toml file are

openlimits-exchange = { git = "https://github.com/nash-io/openlimits", rev = "4137b08b" }
openlimits-binance = { git = "https://github.com/nash-io/openlimits", rev = "4137b08b" }

Going to try and resolve this, but any pointers would be great, thanks!

mohamedabdelbary commented 2 years ago

Took a further look. It seems that maybe this latest revision requires an earlier version which is incompatible. Can see the following in my Cargo.lock file

[[package]]
name = "openlimits-binance"
version = "0.3.1-alpha.0"
source = "git+https://github.com/nash-io/openlimits?rev=4137b08b#4137b08bb545d5a0475db15d2ea38aff4ec17a00"
dependencies = [
 "async-trait",
 "chrono",
 "futures 0.3.23",
 "hex",
 "hmac",
 "log",
 "openlimits-exchange 0.3.0",
 "reqwest",
 "rust_decimal",
 "serde",
 "serde_json",
 "serde_urlencoded",
 "sha2",
 "thiserror",
 "tokio 1.20.1",
 "tokio-tungstenite",
 "url",
]

Note the dependency of openlimits-binance version 0.3.1-alpha.0 on openlimits-exchange 0.3.0. But I'm also installing openlimits-exchange version 0.3.1-alpha.0 to get the latest changes, so two versions of openlimits-exchange are being installed, and they seem to be incompatible.

Could we maybe remove the dependency of openlimits-binance on openlimits-exchange 0.3.0 in version 0.3.1-alpha.0?