Python 向oanda发送订单
我想向oanda发送订单以进行交易,我使用ipython笔记本编译我的代码,这是我的代码:Python 向oanda发送订单,python,rest,api,ipython-notebook,Python,Rest,Api,Ipython Notebook,我想向oanda发送订单以进行交易,我使用ipython笔记本编译我的代码,这是我的代码: 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=oa
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)
但错误在于:
OandaError: OANDA API returned error code 4 (The access token provided does
not allow this request to be made)
如何解决这个问题?我也遇到了同样的问题,但是当通过curl命令发送订单时 问题与您从哪个帐户使用哪个API有关 我注意到您的python中写着“practice”,因此您需要确保生成的API令牌来自您的practice帐户。Live帐户和practice帐户都使用自己的API令牌,您的命令需要匹配 您还可以查看python中的其他地方,它实际上ping OandA的服务器 例如,使用curl时,live帐户使用 “https://api fxtrade.oanda.com/v3/accounts//orders” 练习帐户使用 “https://api fxpractice.oanda.com/v3/accounts//orders”
在练习帐户中使用live帐户上生成的API令牌将产生您所询问的错误。我现在面临同样的问题,有什么发现吗?您的帖子很有意义,谢谢。但是,我不知道您具体在哪里为实践帐户生成令牌。