Turn the list to location control Python
As a trader of cryptocurrencies, it is very important to obtain accurate and organized information in order to make information -based decisions. In this article, we look at how to convert Binance Foucers API price list of pandas that can be used to manage drive.
Prerequisites:
- Install
binance_f
library using PIP:PIP install binance_f
- Set Binance API License Information
- Bring the necessary libraries and set the API key
Code:
`Python
From binance_F import click, order book
Set Application Subscription Access Information and Customer Notifications
API_KEY = 'YOUR_API_KEY'
API_SECRET = 'Your_API_SECRET'
Request_client = RequestClient (API_KEY = API_KEY, API_SECRET = API_SECRET)
Def Convert_TO_DF (Prices):
"" ""
Turn the price list to pandas.
Parameters:
Prices (List): List of Convertible Prices
Return:
PD.Dataframe: Converted DATAFRAME
"" ""
Order_book = Request_client.get_orderbook ('BTCUSDT')
Create a dictionary to save price and volume data
Data = {
'Price': [],
'Volume': []
}
Entrance
If entry.price> record.Volume:
Information ['Price']. Appendix (record.Price)
Data ['Volume']. Appendix (Record.Volume)
df = pd.dataframe (data)
Return to DF
For use
Prices = [100.0, 120.0, 110.0, 130.0, 115.0]
BTC-SUSD examples
DF = Convert_to_df (prices)
Print (DF)
Explanation:
- First we produce the necessary libraries and set up the application subscription access information.
- We create “RequestClient” with the API key and mystery.
- “Convert_to_DF ()” The action takes into account the rate price list and uses binance fuzers to apply for order books for the entry at all costs.
- We connect the price and volume information to each entry with the dictionary (“data”).
- We create a panda data frame from the dictionary and return it.
- In the instrument section we show how “Convert_TO_DF () is the price list.
Tips and Variations:
- You can edit the
Convert_TO_DF ()
different types of price information (eg candle board).
- If you need to process additional information (eg trend analysis), you may want to consider using a more modern library, such as Pandaas-Dataaser.
- To optimize performance, a large amount of data for API processing requires a cache or a queue -based approach.
By following this article and adjusting it to your specific needs, you can effectively transform the price list to Panda’s data frame Python.