请求中的变量在 while 循环期间不会更新
我初始化了一个日期变量和一个现在变量。 当日期比现在小时,代码会循环。
import ccxt
import datetime
exchange = ccxt.binance({ 'enableRateLimit': True })
date = 1502928000
now = int(round(datetime.datetime.timestamp(now)))
while date <= now:
ohlcv = exchange.fetch_ohlcv('BTC/USDT', '1d', date, 1)
print(ohlcv)
date += 86400
print(date)
在循环结束时,我将日期更新为一天,这是有效的,因为我打印了日期并确认日期已更改。
但是,请求中的日期保持相同的值。响应始终是:
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
...
如何更新请求中的日期变量?
谢谢
I initialize a date variable and a now variable.
While date is smaller than now the code loops.
import ccxt
import datetime
exchange = ccxt.binance({ 'enableRateLimit': True })
date = 1502928000
now = int(round(datetime.datetime.timestamp(now)))
while date <= now:
ohlcv = exchange.fetch_ohlcv('BTC/USDT', '1d', date, 1)
print(ohlcv)
date += 86400
print(date)
At then end of the loop I update the date with one day, this works because I print the date and confirm the date changed.
But, the date within the request stays the same value. The response is always:
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
[[1502928000000, 4261.48, 4485.39, 4200.74, 4285.08, 795.150377]]
...
How do I update the date variable within the request?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论