JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 425 forks source link

Example about futures? #555

Closed iegestesi closed 3 years ago

iegestesi commented 3 years ago

Is there any example to use the futures side? I just couldn't decode the code. So can you give an example or help?

deadheadblues commented 3 years ago

Check out the issue I raised here that contains an example for raising a futures order and subscribing to trade updates. You have to create an account on the Binance futures testnet site and use the api key and api secret to create an ApiCrendentials object that you use as shown in the example.

Note you won't receive coin-m futures order updates, which is why I raised the issue.

iegestesi commented 3 years ago

I created an account from test address but cannot create api. How do I do that. Also, are futures data, not spot market data, required for transactions? I leave an example below but it gives a symbol error. var klines = client.FuturesUsdt.Market.GetKlines ("ETHUSD", Binance.Net.Enums.KlineInterval.OneMinute, limit: 500);

deadheadblues commented 3 years ago

You don't need to create the api key or api secret as it gets created when you create the account. Go to the futures testnet site, sign in, and click on "API Key" as shown in the below pic. You can then copy/paste the api key and api secret into your code. image

Data is not required to send orders.

Also, the symbols of all usdt futures end in "USDT" so if you want to trade the ETH future, the symbol is ETHUSDT.

iegestesi commented 3 years ago

Ok i got this part. So why can't I see this data in the API that I normally add? In other words, the necessary permissions are given in my API information, but it cannot extract data. Also worked in test net. How do I pull data in real network? After all, I will not always work in a test environment.

deadheadblues commented 3 years ago

To change the environment, you have to supply the URLs that you want to use when creating the BinanceClient and BinanceSocketClient. Check out the issue I mentioned you should check out in my first comment reply to you and you'll see how I use the SetDefaultOptions() function to supply the BaseAddress, BaseAddressUsdtFutures, and BaseAddressCoinFutures URLs for the api I want to use. I can't help you with the actual URLs as I don't have access to the normal binance.com api.