- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 Python 和 Oanda api 下 Fx 订单。
from requests import post
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <auth code>"
}
data = {
"order": {
"units": "100",
"instrument": "EUR_USD",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}
}
#Practice Account
r = post(
"https://api-fxpractice.oanda.com/v3/accounts/<acct #>/orders",
headers=headers,
data=data
)
print(r.text)
Invalid JSON, ParseErrorCode: 3, Message: Invalid value.
body=$(cat << EOF
{
"order": {
"units": "100",
"instrument": "EUR_USD",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}
}
EOF
)
curl \
-X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer <AUTHENTICATION TOKEN>" \
-d "$body" \
"https://api-fxtrade.oanda.com/v3/accounts/<ACCOUNT>/orders"
最佳答案
您必须使用 json.dumps
对字典进行编码.我还从值中删除了引号。
这是代码:
from requests import post
import json
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer <auth code>"
}
data = {
"order": {
"units": 10,
"instrument": "EUR_USD",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}
}
data = json.dumps(data)
#Practice Account
r = post(
"https://api-fxpractice.oanda.com/v3/accounts/<acct #>/orders",
headers=headers,
data=data
)
print(r.text)
关于python - 尝试使用 Python 请求在 Oanda 上下订单。获取 JSON 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59654479/
我想向oanda发送订单进行交易,我使用ipython笔记本来编译我的代码,这是我的代码: import oandapy trade_expire=datetime.now()+timedelta(d
我想获取货币和金属的数据。当我尝试一些软件包时,很多人建议使用 quantmod。所以我用了 getSymbols如下: getSymbols("USD/EUR",src="oanda") Error
作为学习算法交易和 OANDA 基础知识的一种方式, 我找到了 a tutorial关于如何制作一个非常基本的交易算法来“练习”算法交易。唯一的问题是教程使用 OANDA 的 v1 REST API,
>>> import sys >>> sys.path.append("/usr/local/oanda_fxtrade.jar") # add the jar to your path >
我想在 R 中处理比特币价格,但我无法从雅虎和谷歌下载时间序列。 来自Yahoo BTCUSD 历史时间序列丢失,并且当符号为“CURRENCY:EURUSD”时,Google 无法识别由 getSy
这是我在这里的第一篇文章。当遇到一些代码问题时,我通常会找到我正在寻找的东西。不过这个不同。 我正在尝试运行一个自动交易算法,但我在网上找到的可以帮助我编写此代码的东西要么已经过时,要么我猜我用错了。
我正在尝试使用 Python 和 Oanda api 下 Fx 订单。 from requests import post headers = { "Content-Type": "appli
我正在尝试stream the price来自 Oandas V20 Rest api 的仪器,但没有取得太大成功。我正在使用 python requests,因为它适用于常规 get 请求。这是我必
当我尝试安装这个包时: go get github.com/jasonnfls/goanda 我收到这个错误: /usr/local/go/bin/src/github.com/jasonnfls/g
该脚本在我的 MacBook 上运行良好,但是每当我尝试在我的树莓派上运行它时都会出错。我似乎无法找到解决方案,有人可以指出正确的方向!请和谢谢 Traceback (most recent call
我是一名优秀的程序员,十分优秀!