python - 参数中的Python binance非法字符
问题描述
我对python真的很陌生,试图调用binance api并在循环中获取多个货币对的klines数据,并存储到CSV。
我想在 Binance 上引入所有货币对的列表,按标记为活动的货币对进行过滤,然后循环遍历每个货币对的一些代码。
当我将列表值传递给 binance 命令时,我得到“在参数 'symbol' 中发现非法字符;合法范围是 '^[A-Z0-9-_.]{1,20}$'。”
print(pairs_list)
给出以下内容:-
['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)
解决方案
推荐阅读
- amazon-web-services - 从无法访问 Internet 的 lambda 访问 ACM
- google-cloud-stackdriver - google-filestore 文件锁定限制 - 如何监控
- php - 使用 Promise 时的 PHP 单元测试
- r - R图未显示正确的数据
- java - 显示异常的 findElement 方法
- html - 固定位置不适用于谷歌地图
- python - 尝试登录 Django 的管理页面时 Python 失败
- python - 如何使用 python pandas 库改变数据
- cypress - 在 beforeEach 中清理数据库状态?
- html - 按钮侧面的反向曲线