sammchardy / python-binance

Binance Exchange API python implementation for automated trading
https://python-binance.readthedocs.io/en/latest/
MIT License
5.91k stars 2.19k forks source link

How do I pull data for BTCUSD Perpetual #619

Open terenceljz opened 3 years ago

terenceljz commented 3 years ago

I am new to Python, would anyone be kind enough to guide me in pulling data for BTCUSD Perpetual?

The only relevant post I found from the web is: https://stackoverflow.com/questions/63963411/what-are-the-symbols-used-in-binances-dapi-coin-futures-api

However, I do not know how I can proceed. I am using a macOS and PyCharm

oliver-zehentleitner commented 3 years ago

As far as I know, support for those endpoints are not implemented in python-binance or any other lib i know - neither rest nor websocket.

Here are the official docs from binance: https://binance-docs.github.io/apidocs/delivery/en/#change-log

I want to do a websocket implementation of binance coin futures for an other python lib and started this issue: https://github.com/oliver-zehentleitner/unicorn-binance-websocket-api/issues/134

terenceljz commented 3 years ago

@oliver-zehentleitner Hey Oliver, thank you for your respond.

Found a way to get perpetual data (FYI for those who need it). Since I am only interested in Coin-M futures, I changed the endpoint.

binance_api = "API-KEY" binance_secret = "API-SECRET" client = Client(binance_api, binance_secret) client.FUTURES_URL = 'https://dapi.binance.com/dapi'

weltonrodrigo commented 3 years ago

binance_api = "API-KEY" binance_secret = "API-SECRET" client = Client(binance_api, binance_secret) client.FUTURES_URL = 'https://dapi.binance.com/dapi'

The same as above, but for websocket:

client = Client(api_key, api_secret)
bm = BinanceSocketManager(client)
bm.FSTREAM_URL = `'wss://dapi.binance.com/'`

For COIN-M testenet, bm.FSTREAM_URL = 'wss://dstream.binancefuture.com'

oliver-zehentleitner commented 3 years ago

@oliver-zehentleitner Hey Oliver, thank you for your respond.

Found a way to get perpetual data (FYI for those who need it). Since I am only interested in Coin-M futures, I changed the endpoint.

binance_api = "API-KEY" binance_secret = "API-SECRET" client = Client(binance_api, binance_secret) client.FUTURES_URL = 'https://dapi.binance.com/dapi'

This will not generate full support for coin futures... (just 4 info)

UserData stream supports new subscriptions:

Websocket Request for user data:

    <listenKey>@account request for user's account information
    <listenKey>@balance request for user's account balance
    <listenKey>@balance request for user's position information
taparura commented 2 years ago

Hello, I am also interested in getting the BTCUSD futures & perpetual futures historical data (kline - candle) and have been struggling. Is there a python script template to get this data. I am using MacOS. Thanks.