Python binance illegal characters in parameter

1.5k views Asked by At

I am really new to python, trying to call the binance api and get klines data for multiple currency pairs in a loop and also store out to CSV.

I want to bring in a list of all pairs on Binance, filter by the ones marked as Active, then loop through some code for each currency pair.

When I pass the list values to the binance command I get "Illegal characters found in parameter 'symbol'; legal range is '^[A-Z0-9-_.]{1,20}$'."

print(pairs_list) gives the following:- ['ETHBTC', 'EOSETH']

#import binance api wrapper
from binance.client import Client
# create the Binance client, no need for api key
client = Client("", "")
#import pandas and the json normalizr
import pandas as pd

#bring in the pairs we want to loop through
df1 = pd.read_csv('BINANCE_ALL_PAIRS.csv')
#filter for the active pairs
df = df1[df1.Active.eq(1)]
#Set up a pairs list to be used to call the api in a loop 
pairs_list = df['symbol'].tolist()
#print(pairs_list)

for x in pairs_list:
    # valid intervals - 1m, 3m, 5m, 15m, 30m, 1h, 2h, 4h, 6h, 8h, 12h, 1d, 3d, 1w, 1M
    # get timestamp of earliest date data is available
    timestamp = client._get_earliest_valid_timestamp(pairs_list, '1d')

    # request historical candle (or klines) data
    bars = client.get_historical_klines(pairs_list, '1d', timestamp, limit=1000)
0

There are 0 answers