【发布时间】:2021-12-04 21:19:50
【问题描述】:
【问题讨论】:
标签: trading
【问题讨论】:
标签: trading
可能身份验证参数不正确。试试这个oanda's v20 wrapper
import v20
token = 'YOUR API TOKEN'
account_id = 'YOUR ACCOUNT ID'
# using oanda's v20 API wrapper
ctxs=v20.Context(hostname='stream-fxpractice.oanda.com', token=token)
ctxs.set_header(key='Authorization', value=token)
# send the request to the stream endpoint
response=ctxs.pricing.stream(account_id, instruments='EUR_USD,GBP_USD')
# process the incoming stream tick by tick
for typ, data in response.parts():
if typ == "pricing.ClientPrice":
msg="{} ({}) {}/{}".format(
data.instrument,
data.time,
data.bids[0].price,
data.asks[0].price)
print(msg)
break
【讨论】: