Я пытаюсь перевести Керл на Python, но у меня что-то не так. Пожалуйста помоги.
CURL:
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"
PYTHON:
import requests
import json
def market_buy():
header = {"Accept": "application/json",
"Authorization": "Bearer <my auth code>"
}
data = {
"order": {
"units": "100",
"instrument": "EUR_USD",
"timeInForce": "FOK",
"type": "MARKET",
"positionFill": "DEFAULT"
}
}
url = "https://api-fxtrade.oanda.com/v3/accounts/<myaccount>/orders"
r = requests.post(url, data=data, headers=header)
print(r.text)
market_buy()
Сообщение об ошибке:
{"errorMessage":"Insufficient authorization to perform request."}
Я дважды проверил свои учетные данные , Я думаю, что-то не так с кодом.