wisespace-io / binance-rs

Rust Library for the Binance API
Other
665 stars 297 forks source link

Futures API #39

Closed AlexApps99 closed 4 years ago

AlexApps99 commented 4 years ago

From what I can tell, this crate does not support the Binance's Futures API.

Are there any branches/alternate crates that support the API?

Alternatively, are there any plans to add the API to this crate?

Thanks

wisespace-io commented 4 years ago

I am not aware of Binance's Futures implementation in Rust. It could be supported in this crate, as far as I can see from the docs we can reuse most of the data models we have currently.

AlexApps99 commented 4 years ago

I would be willing to help if you need a hand with this

wisespace-io commented 4 years ago

@AlexApps99 You are welcome. I will try to do first draft on weekend so we can start helping with the implementation of the futures api.

wisespace-io commented 4 years ago

@AlexApps99 I created the base implementation, see https://github.com/wisespace-io/binance-rs/tree/master/src/futures

I just implemented the general api, I was able to reuse some structs in Exchange Information data model, but the Symbols struct was different as you can see in futures/model.rs, so I guess it will not be always possible to reuse the models.

AlexApps99 commented 4 years ago

Excellent, I'll get started implementing the market API.

AlexApps99 commented 4 years ago

While looking at src/market.rs, I noticed that some functionality is unimplemented:

/api/v3/trades
/api/v3/historicalTrades
/api/v3/aggTrades

Should I omit the futures version of these functions too?

wisespace-io commented 4 years ago

I think we could include, if you do not mind to implement. Otherwise, I can add later.

AlexApps99 commented 4 years ago

I have created a draft PR (#41) to show my progress and get feedback, hopefully I'll have completed it by the end of this week.

wisespace-io commented 4 years ago

It looks like good, I noticed that you added a comment to get_historical_trades, stating that it may requires API key, however, looking at the docs, It does not seen a signed request.

AlexApps99 commented 4 years ago

The documentation is wrong: http "https://fapi.binance.com/fapi/v1/historicalTrades" symbol=="BTCUSDT"

{
    "code": -2014,
    "msg": "API-key format invalid."
}
AlexApps99 commented 4 years ago

I've done further investigation, and I believe that functionality documented with (MARKET_DATA) are only accessible by API key

wisespace-io commented 4 years ago

I checked the binance implementation of the futures API. You can use for reference.

https://github.com/Binance-docs/Binance_Futures_python/blob/master/binance_f/impl/restapirequestimpl.py#L173

Requires:

request = self.__create_request_by_get_with_apikey("/fapi/v1/historicalTrades", builder)

Dont require:

request = self.__create_request_by_get("/fapi/v1/aggTrades", builder)
request = self.__create_request_by_get("/fapi/v1/klines", builder)
request = self.__create_request_by_get("/fapi/v1/depth", builder)
...

We need to add a new method in client.rs do cover the apikey case

AlexApps99 commented 4 years ago

I haven't been able to find the time to finish my PR, so I hope what I have done is enough for now

AlexApps99 commented 4 years ago

Not all of the Futures API has been implemented yet, so a new issue should be made to track the other parts of the API