tay*_*lor 5 python api rest ipython-notebook
我想向oanda发送订单进行交易,我使用ipython notebook编译我的代码,这是我的代码:
import oandapy
trade_expire=datetime.now()+timedelta(days=1)
trade_expire=trade_expire.isoformat("T")+"Z"
oanda=oandapy.API(environment='practice',access_token='XXXX....')
account_id=xxxxxxx
response=oanda.create_order(account_id,instrument='USD_EUR',units=1000,side='buy',/
type='limit',price=1.105,expire=trade_expire)
Run Code Online (Sandbox Code Playgroud)
但错误是?
OandaError: OANDA API returned error code 4 (The access token provided does
not allow this request to be made)
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
我遇到了同样的问题,但是当通过curl 命令发送订单时。
问题与您从哪个帐户使用哪个 API 有关。
我注意到你的 python 中写着“练习”,所以你需要确保你生成的 API 令牌来自你的练习帐户。真实账户和练习账户各自使用自己的 API 令牌,并且您的命令需要匹配。
您还可以查看 python 中的其他位置,它实际上在其中 ping OandA 的服务器。
例如,当使用curl时,真实账户使用
“https://api-fxtrade.oanda.com/v3/accounts/ <账户>/orders”
练习账户使用
“https://api-fxpractice.oanda.com/v3/accounts/ <账户>/orders”
在练习账户中使用真实账户生成的 API 令牌将会产生您所询问的错误。
| 归档时间: |
|
| 查看次数: |
600 次 |
| 最近记录: |