Привет. Я пытаюсь реализовать алгоритм торговли на рынке Форекс, используя API-интерфейс OANDA. Я создал учетную запись в OANDA, и ключ был сгенерирован.
Когда был реализован следующий код, я не получил никакой ошибки, но кажется, что данные не извлекаются.
"""
The main file that will evolve into our trading library
"""
from datetime import datetime, timedelta
import v20
OANDA_ACCESS_TOKEN = ""
OANDA_ACCOUNT_ID = '' #put your access id here
def main():
print("------ System online -------", datetime.now())
latest_price_time = (datetime.utcnow() - timedelta(seconds=15)).isoformat('T')+'Z'
api = v20.Context(
'api-fxpractice.oanda.com',
'443',
token=OANDA_ACCESS_TOKEN)
response = api.pricing.get(
OANDA_ACCOUNT_ID,
instruments='EUR_USD',
since=latest_price_time,
includeUnitsAvailable=False)
print(response)
prices = response.get("prices", 200)
print (prices)
if len(prices):
buy_price = prices[0].bids[0].price
print("Buy at " + str(buy_price))
response = api.order.market(
OANDA_ACCOUNT_ID,
instrument='EUR_USD',
units=5000)
print("Trading id: " + str(response.get('orderFillTransaction').id))
print("Account Balance: " + str(response.get('orderFillTransaction').accountBalance))
print("Price: " + str(response.get('orderFillTransaction').price))
else:
print(response.reason)
if __name__ == "__main__":
main()
Вот вывод, который я получил.
------ Система онлайн ------- 2019-04-27 13: 08: 32.531057 Метод = GET Path =
https://api -fxpractice.oanda.com: 443 / v3 / account / 101-011-11099167-001 / инструменты расчета цены = EUR_USD и с тех пор = 2019-04-27T07% 3A38% 3A17.531057Z & includeUnitsAvailable = False Статус = 200 Причина = OK Content-Type = application / json
[] ОК
Но при доступе к указанному выше пути я получаю следующую ошибку.
![enter image description here](https://i.stack.imgur.com/skHO6.png)