🎉
Oanda Japanをいじってみた
-
デモ口座開設
HPから本番口座かデモ口座の開設手続きに進める。今回はデモ口座を開設。
https://www.oanda.jp/ -
デモMT4アカウント取得
デモ口座のIDに加えて、デモMT4用のIDも作る必要がある。
それを以下のコードのIDとして使う。 -
Python API (oandapyV20)
https://oanda-api-v20.readthedocs.io/en/latest/index.html -
口座操作(残高確認・入金)
- 通貨ペアの情報取得
# ライブラリインポート
from oandapyV20 import API
import oandapyV20.endpoints.accounts as accounts
#自分のアカウントID、トークンをセット
accountID = "101-009-xxxxxxxx-xxx" # MT4 demo
access_token = 'xxxxxxxxxxxxxxxxxxxxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxx'
api = API(access_token=access_token, environment="practice")
# 通貨ペアを指定して情報取得
params = { "instruments": "EUR_USD,EUR_JPY,USD_JPY" }
r = accounts.AccountInstruments(accountID=accountID, params=params)
api.request(r)
data = r.response
print(data)
返り値は下記。何の形式すぐに分からなかったが辞書の中にリストで各通貨ペアの情報(辞書形式)が入っているという。。。
これをDataFrame形式に成形するのを次回挑戦したいと思います。
{'instruments': [{'name': 'EUR_USD', 'type': 'CURRENCY', 'displayName': 'EUR/USD', 'pipLocation': -4, 'displayPrecision': 5, 'tradeUnitsPrecision': 0, 'minimumTradeSize': '1', 'maximumTrailingStopDistance': '1.00000', 'minimumTrailingStopDistance': '0.00050',
'maximumPositionSize': '0', 'maximumOrderUnits': '100000000', 'marginRate': '0.04', 'guaranteedStopLossOrderMode': 'DISABLED', 'tags': [{'type': 'ASSET_CLASS', 'name': 'CURRENCY'}], 'financing': {'longRate': '-0.0366', 'shortRate': '-0.0058', 'financingDaysOfWeek': [{'dayOfWeek': 'MONDAY', 'daysCharged': 1}, {'dayOfWeek': 'TUESDAY', 'daysCharged': 1}, {'dayOfWeek': 'WEDNESDAY', 'daysCharged': 1}, {'dayOfWeek': 'THURSDAY', 'daysCharged': 1}, {'dayOfWeek': 'FRIDAY', 'daysCharged': 1}, {'dayOfWeek': 'SATURDAY', 'daysCharged': 0}, {'dayOfWeek': 'SUNDAY', 'daysCharged': 0}]}}, {'name': 'EUR_JPY', 'type': 'CURRENCY', 'displayName': 'EUR/JPY', 'pipLocation': -2, 'displayPrecision': 3, 'tradeUnitsPrecision': 0, 'minimumTradeSize': '1', 'maximumTrailingStopDistance': '100.000',
'minimumTrailingStopDistance': '0.050', 'maximumPositionSize': '0', 'maximumOrderUnits': '100000000', 'marginRate': '0.04', 'guaranteedStopLossOrderMode': 'DISABLED', 'tags': [{'type': 'ASSET_CLASS', 'name': 'CURRENCY'}], 'financing': {'longRate': '-0.0278', 'shortRate': '-0.0116', 'financingDaysOfWeek': [{'dayOfWeek': 'MONDAY', 'daysCharged': 1}, {'dayOfWeek': 'TUESDAY', 'daysCharged':
1}, {'dayOfWeek': 'WEDNESDAY', 'daysCharged': 1}, {'dayOfWeek': 'THURSDAY', 'daysCharged': 1}, {'dayOfWeek': 'FRIDAY', 'daysCharged': 1}, {'dayOfWeek': 'SATURDAY', 'daysCharged': 0}, {'dayOfWeek': 'SUNDAY', 'daysCharged': 0}]}}, {'name': 'USD_JPY', 'type': 'CURRENCY', 'displayName': 'USD/JPY', 'pipLocation': -2, 'displayPrecision': 3, 'tradeUnitsPrecision': 0, 'minimumTradeSize': '1', 'maximumTrailingStopDistance': '100.000', 'minimumTrailingStopDistance': '0.050', 'maximumPositionSize': '0', 'maximumOrderUnits': '100000000', 'marginRate': '0.04', 'guaranteedStopLossOrderMode': 'DISABLED', 'tags': [{'type': 'ASSET_CLASS', 'name': 'CURRENCY'}], 'financing': {'longRate': '-0.0087', 'shortRate': '-0.0233', 'financingDaysOfWeek': [{'dayOfWeek': 'MONDAY', 'daysCharged': 1},
{'dayOfWeek': 'TUESDAY', 'daysCharged': 1}, {'dayOfWeek': 'WEDNESDAY', 'daysCharged': 1}, {'dayOfWeek': 'THURSDAY', 'daysCharged': 1}, {'dayOfWeek': 'FRIDAY', 'daysCharged': 1}, {'dayOfWeek': 'SATURDAY', 'daysCharged': 0}, {'dayOfWeek': 'SUNDAY', 'daysCharged': 0}]}}], 'lastTransactionID': '53'}
Discussion