Testnet API
MichalLebeda opened this issue · comments
Hi, would like to include testnet API there. It is only necessary to create client with https://testnet.binance.vision instead of https://api.binance.com. As I'm new to Rust, what would be the ideal implementation? Should I make parameter to new(...)
function or create new trait function for example new_testnet(...)
?
@MichalLebeda See how Futures API (FAPI) is implemented in https://github.com/wisespace-io/binance-rs/blob/master/src/api.rs
Is testnet different from the current one supported in this crate? We have some test endpoints, see
https://github.com/wisespace-io/binance-rs/blob/master/src/account.rs#L19
@wisespace-io
Testnet has the same endpoints as the normal api. It even contains test endpoints. It is only necessary to use another address (and different credentials but that's user's responsibility).
Anyway I have found out that testnet is rather strange as it seems to be a completely isolated market so any backtesting/real behavior is impossible to test
@wisespace-io I'd also like this feature. There's info at https://testnet.binance.vision:
replacing the URLs of the endpoints with the following values:
Spot API URL | Spot Test Network URL |
---|---|
https://api.binance.com/api | https://testnet.binance.vision/api |
wss://stream.binance.com:9443/ws | wss://testnet.binance.vision/ws |
wss://stream.binance.com:9443/stream | wss://testnet.binance.vision/stream |
I can make a PR but would like to have your view on how to implement this: what about creating a optional enum argument in connect
to choose between main and test?
@dorak88783 It depends on how it will be used. I recently noticed that Binance has introduced API clusters .. see
https://github.com/binance/binance-spot-api-docs/blob/master/rest-api.md#general-api-information
I thought to create a build with default values and we could set these APIs, something like I do in my yubico API,
We could overwrite these settings:
let config = Config::default()
.set_binance_api("https://testnet.binance.vision/api")
.set_binance_ws("wss://testnet.binance.vision/ws");
Or just use the default
let config = Config::default();
It is a builder pattern https://github.com/wisespace-io/yubico-rs/blob/master/src/config.rs#L55
If you are not comfortable with that, I can implement it when I have some time soon. Otherwise feel free to submit a PR.
I thought about something like web_socket.set_binance_api("https://testnet.binance.vision/api").connect()
but that would need modification in many places.
I think your way is nicer, I'll give it a shot. I only don't know yet how to skip all of this when using the default settings, so maybe it should be a web_socket.use_config(config).connect()
or web_socket.connect_with_config(config)
.
Nice project!
I too was looking for a way to run on net.binance.vision and the builder pattern would have my preference as well.
Should be fixed in #75.