Establishment of Data in the Regimen Real Time with Python
In this state, we dissatisfied with how to resist the data in the regional time for the series with the Api Binance, using the Binance-Connector-Python “.
PROVIDERS
- Installed Guard Bookstores:
PIP Install Binance-Connector-Python '
- Set up your cot record API Binance and get the API key
- Download Biblion "Binance-Connector-Python '
Shag 1: Authentification with Bee Binance
Earning the data of the data needed to provide a binance bees, using the bee key. You can make it, make up an objectconferred:
`Python
Import Binance.connector AS BC
Configuration Class:
Binance_api_key = 'Your_binance_api_key'
Binance_api_secret = 'Your_binance_api_secret'
Changeyour_binance_api_keyyour_binance_api_secret 'with a facty key and secre.
** Stro 2
Submit the object "client", which is used for the midst of the bees binance:
Python
Client = BC.Client (API_KEY = config.binance_api_key,
Api_secret = config.binance_api_secret)
Shag 3: Red Data in the Regimen Real Time for Simmali
To resist the data in the regimen of the reality time for the set of symbols, use the "Simvol" parameter in the requested. You can transfer a matrish symbols for the data for several couples:
Python
Pairs = ['btcusdt', 'ethusdt']
Client.symbol (Symbol = 'BTCUSDT')
This is the Vaduta Complex of OTC/USD and ETH/USD.
** Shag 4: Council Date
To make a given data in the regional time for each symbol, use the "Simvol" parameter with "Time", set in 'True'. This is the vocabulary of the dangers:
Python
Client.symbol (Symbol = 'BTCUSDT', Time = True)
This is the faithful shadow, the volume and other market data.
Primer code
Here is a fragment of the sight of the code, which shows how to resist the data in the regime of the real for several symbols, usingbinance -conner-pithon:
`Python
Import Binance.connector AS BC
Realtimatic class:
Def __init __ (Self):
Self.config = config ()
self.client = bc.client (api_key = self.config.binance_api_key,
Api_secret = self.config.binance_api_secret)
Def Get_real_time_data (Self, Symbol = None, Time = False):
If not symbol and time:
Returned {
'Symbol': '',
"Time": Pravda
}
If not Simvol:
Get the Valuerror ("Himming")
Pairs = [Simvol]
For a couple in pairs:
Data = self.Client.symbol (Symbol = PARE)
If Time:
Return {'Data': Data, 'Timestamp': Data ['Timestamp']}}
other:
Return {
Data, {'Data': None}}
If __name__ == '__main__':
Retriever = Realtimetariever ()
For Simvol B ['btcusdt', 'ethusdt']:
Print (retriever.get_real_time_data (symbol = symbol))
This code scraps shows how to resist the data in the reality for several symbols, usingbinance -conTor-pithon. You can add a few symbols, adding them in the list and change the cycle.
conclusion
In this state, we overwhelmed the bases of the data in the regime of the real time API Binance with the “Binance-Connector-Python”. The following is the name of the nominees and the primer, you should be in the state of the afternoon information about the non -collar symbols of Binance every 15 seconds. Do not forget to change the key and secret on the factual values and all the way to follow the methods of relipivity and the ogriconing of the perk for the time with the extraordinary bee.