Ethereum: Fetching more data from binance using python loop

Getting more data from binting loop

If you call more than 500 rows of historical data from the banium website, you call you the API continually to the API until you get all the data. ` Can be used as nope. Example code code code code code code code that demonstrates how to do this

`Python

Import banner

Ethereum: Fetching more data from binance using python loop

Start the client and prepare the API credentials

Client = drinks.

API_KEY = 'your_API_KEY',

API_SECRET = 'your_API_SSECRET'

)

Define a function to obtain historical data

DEF Fetch_hisistorical_data (symbol, spacing):

Set timeframe to get

START_TIME = DATETIALE.NO () - TIMEDELTA (DAY = Generation * 30)

Create a list for storage of candles

Candles = []

On the loop until we get all the data

Fact:

Try:

#Appinate historical data

Response = GUMER.GET_KLINES (Symbol, Start_time.timempamp (), spacing)

Add new candles to the list

Responding to that [0]: [0]:

Candles. Papped (candle [1])

If we got all the data, go away from the loop

Len (Response) <= 500:

Breaking

binance.exceptions.conceneception e:

Printing (F "Error Obtaining Data: {e}")

Continue to continue

Return candles

Example use

Symbol = 'btcusdt'

Replace with your desired symbol

Inter-Sisew = '1m'

1-minute gap

CANDLESS = FETCH_HISTORLIORICTRICALLICT_DATA (සංකේතය, පරතරය)

This code:

  • Let us start the banium client and set the API credentials.

  • A function of a symbol and gap (eg, a function for a 1 meter interpretation of 1 meter.

  • In the loop, we get historical data using the specified start time, the gap and symbol.

  • Let us add every new Etaplaka to a list called ‘Caidums’.

  • 500 lines of data (I.E., Len (Response) <500), we went off the loop.

  • Finally, we send back the list of the "list of candles."

Tips and Varies

  • To get more than 1000 lines at a time, you can change the function to use a large interval for a 1 hour gap (eg, '1'.

  • If you want to get data in real-time, you have to use a different approach. One option is to use api key and access token.

  • Be sure to handle errors and exceptions in your product code.

Note: The above code is used by Python 3.x syntax. If you use Python 2.x, you will need to change imports and an error.

Ethereum Bitcoin Core Duplicate

Leave a Comment

Your email address will not be published. Required fields are marked *