Ceci est un mémo de v20-python-samples qui est un échantillon de OANDA V20 python lib. Vous pouvez l'utiliser comme un outil de ligne de commande qui vous permet de vérifier l'API.
https://github.com/oanda/v20-python-samples
La procédure d'installation est essentiellement basée sur l'environnement Linux, mais elle peut également être installée dans Windows. Pour les commandes suivantes de la procédure, procédez manuellement de la même manière dans l'environnement Windwos ci-dessous
linux
make bootstrap
windows_python3
virtualenv -p python3 env
env\Scripts\pip install -r requirements/base.txt
linux
source env/bin/activate
windows
env\Scripts\activate.bat
v20-account-details les détails vous donneront un résumé du compte et un solde pour chaque paire de devises.
v20-account-details
Account xxx-xxx-xxxxxxx-xxx
===========================
=============================== ==============================
Account ID xxx-xxx-xxxxxxx-xxx
Alias Primary
Home Currency JPY
Balance 374585.0125
Created by User ID xxxxxxx
Create Time 2020-07-09T03:27:35.393967207Z
Guaranteed Stop Loss Order Mode DISABLED
Profit/Loss -72865.1901
Resettable Profit/Loss -72865.1901
Profit/Loss Reset Time 0
Financing -2496.2074
Commission 0.0
Guaranteed Execution Fees 0.0
Margin Rate 0.04
Open Trade Count 0
Open Position Count 0
Pending Order Count 0
Hedging Enabled False
Unrealized Profit/Loss 0.0
Net Asset Value 374585.0125
Margin Used 0.0
Margin Available 374585.0125
Position Value 0.0
Closeout UPL 0.0
Closeout NAV 374585.0125
Closeout Margin Used 0.0
Margin Closeout Percentage 0.0
Margin Closeout Position Value 0.0
Withdrawal Limit 374585.0125
Last Transaction ID 6143
=============================== ==============================
13 Open Positions
=================
============ ========= ================ ========== ==========
Instrument P/L Unrealized P/L Long Short
============ ========= ================ ========== ==========
AUD_JPY -4643.11 0 0.0 @ None 0.0 @ None
AUD_USD -13941.5 0 0.0 @ None 0.0 @ None
EUR_AUD -4197.54 0 0.0 @ None 0.0 @ None
EUR_CAD 2187.31 0 0.0 @ None 0.0 @ None
EUR_GBP -4444.72 0 0.0 @ None 0.0 @ None
EUR_JPY -13217.7 0 0.0 @ None 0.0 @ None
EUR_USD 13787.9 0 0.0 @ None 0.0 @ None
GBP_AUD 6820.85 0 0.0 @ None 0.0 @ None
GBP_JPY -17401.3 0 0.0 @ None 0.0 @ None
GBP_USD -5079.87 0 0.0 @ None 0.0 @ None
USD_CAD -5946.91 0 0.0 @ None 0.0 @ None
USD_CHF -9440.97 0 0.0 @ None 0.0 @ None
USD_JPY -17347.7 0 0.0 @ None 0.0 @ None
============ ========= ================ ========== ==========
v20-account-instruments Une liste des devises pouvant être gérées et agrandies, etc. sera affichée
v20-account-instruments
71 Instruments
==============
======= ======== ====== =============
Name Type Pip Margin Rate
======= ======== ====== =============
AUD_CAD CURRENCY 0.0001 25:1 (0.04)
AUD_CHF CURRENCY 0.0001 20:1 (0.05)
AUD_HKD CURRENCY 0.0001 10:1 (0.1)
AUD_JPY CURRENCY 0.01 25:1 (0.04)
AUD_NZD CURRENCY 0.0001 25:1 (0.04)
AUD_SGD CURRENCY 0.0001 20:1 (0.05)
AUD_USD CURRENCY 0.0001 25:1 (0.04)
CAD_CHF CURRENCY 0.0001 20:1 (0.05)
CAD_HKD CURRENCY 0.0001 10:1 (0.1)
CAD_JPY CURRENCY 0.01 25:1 (0.04)
CAD_SGD CURRENCY 0.0001 20:1 (0.05)
CHF_HKD CURRENCY 0.0001 10:1 (0.1)
CHF_JPY CURRENCY 0.01 20:1 (0.05)
CHF_ZAR CURRENCY 0.0001 10:1 (0.1)
EUR_AUD CURRENCY 0.0001 25:1 (0.04)
EUR_CAD CURRENCY 0.0001 25:1 (0.04)
EUR_CHF CURRENCY 0.0001 20:1 (0.05)
EUR_CZK CURRENCY 0.0001 20:1 (0.05)
EUR_DKK CURRENCY 0.0001 10:1 (0.1)
EUR_GBP CURRENCY 0.0001 20:1 (0.05)
EUR_HKD CURRENCY 0.0001 10:1 (0.1)
EUR_HUF CURRENCY 0.01 20:1 (0.05)
EUR_JPY CURRENCY 0.01 25:1 (0.04)
EUR_NOK CURRENCY 0.0001 25:1 (0.04)
EUR_NZD CURRENCY 0.0001 25:1 (0.04)
EUR_PLN CURRENCY 0.0001 20:1 (0.05)
EUR_SEK CURRENCY 0.0001 25:1 (0.04)
EUR_SGD CURRENCY 0.0001 20:1 (0.05)
EUR_TRY CURRENCY 0.0001 10:1 (0.1)
EUR_USD CURRENCY 0.0001 25:1 (0.04)
EUR_ZAR CURRENCY 0.0001 10:1 (0.1)
GBP_AUD CURRENCY 0.0001 20:1 (0.05)
GBP_CAD CURRENCY 0.0001 20:1 (0.05)
GBP_CHF CURRENCY 0.0001 20:1 (0.05)
GBP_HKD CURRENCY 0.0001 10:1 (0.1)
GBP_JPY CURRENCY 0.01 20:1 (0.05)
GBP_NZD CURRENCY 0.0001 20:1 (0.05)
GBP_PLN CURRENCY 0.0001 20:1 (0.05)
GBP_SGD CURRENCY 0.0001 20:1 (0.05)
GBP_USD CURRENCY 0.0001 20:1 (0.05)
GBP_ZAR CURRENCY 0.0001 10:1 (0.1)
HKD_JPY CURRENCY 0.0001 10:1 (0.1)
NZD_CAD CURRENCY 0.0001 25:1 (0.04)
NZD_CHF CURRENCY 0.0001 20:1 (0.05)
NZD_HKD CURRENCY 0.0001 10:1 (0.1)
NZD_JPY CURRENCY 0.01 25:1 (0.04)
NZD_SGD CURRENCY 0.0001 20:1 (0.05)
NZD_USD CURRENCY 0.0001 25:1 (0.04)
SGD_CHF CURRENCY 0.0001 20:1 (0.05)
SGD_HKD CURRENCY 0.0001 10:1 (0.1)
SGD_JPY CURRENCY 0.01 20:1 (0.05)
TRY_JPY CURRENCY 0.01 10:1 (0.1)
USD_CAD CURRENCY 0.0001 25:1 (0.04)
USD_CHF CURRENCY 0.0001 20:1 (0.05)
USD_CNH CURRENCY 0.0001 20:1 (0.05)
USD_CZK CURRENCY 0.0001 20:1 (0.05)
USD_DKK CURRENCY 0.0001 25:1 (0.04)
USD_HKD CURRENCY 0.0001 10:1 (0.1)
USD_HUF CURRENCY 0.01 20:1 (0.05)
USD_INR CURRENCY 0.01 20:1 (0.05)
USD_JPY CURRENCY 0.01 25:1 (0.04)
USD_MXN CURRENCY 0.0001 12:1 (0.08)
USD_NOK CURRENCY 0.0001 25:1 (0.04)
USD_PLN CURRENCY 0.0001 20:1 (0.05)
USD_SAR CURRENCY 0.0001 20:1 (0.05)
USD_SEK CURRENCY 0.0001 25:1 (0.04)
USD_SGD CURRENCY 0.0001 20:1 (0.05)
USD_THB CURRENCY 0.01 20:1 (0.05)
USD_TRY CURRENCY 0.0001 10:1 (0.1)
USD_ZAR CURRENCY 0.0001 10:1 (0.1)
ZAR_JPY CURRENCY 0.01 10:1 (0.1)
======= ======== ====== =============
v20-transaction-range Vérifiez l'historique des transactions dans la plage des ID de transaction. Puisqu'il n'y a pas d'informations détaillées, il est dommage ou gênant d'avoir à obtenir des informations détaillées séparément Aussi, je veux le prendre dans la plage de la date, mais ce n'est pas dans cet exemple.
v20-transaction-range.exe 4000 9999
#### **`v20-transaction-range`**
```consoe
Transaction 4000: Create Take Profit Order 4000 (ON_FILL): Close Trade 3999 @ 71.693
Transaction 4001: Create Stop Loss Order 4001 (ON_FILL): Close Trade 3999 @ 68.745
Transaction 4002: Cancel Order 4000
Transaction 4003: Create Take Profit Order 4003 (REPLACEMENT): Close Trade 3999 @ 71.693
Transaction 4004: Cancel Order 4001
Transaction 4005: Create Stop Loss Order 4005 (REPLACEMENT): Close Trade 3999 @ 68.736
Transaction 4006: Fill Order 3998 (STOP_LOSS_ORDER): -14604.0 of GBP_USD @ 1.24422
Transaction 4007: Fill Order 4005 (STOP_LOSS_ORDER): -17552.0 of AUD_JPY @ 68.736
Transaction 4008: Cancel Order 4003
Transaction 4009: Fill Order 3995 (STOP_LOSS_ORDER): -18483.0 of AUD_USD @ 0.64342
Transaction 4010: Create Market Order 4010 (CLIENT_ORDER): -8925.0 of AUD_JPY
Transaction 4011: Fill Order 4010 (MARKET_ORDER): -8925.0 of AUD_JPY @ 68.308
Transaction 4012: Create Take Profit Order 4012 (ON_FILL): Close Trade 4011 @ 65.534
Transaction 4013: Create Stop Loss Order 4013 (ON_FILL): Close Trade 4011 @ 68.64
Transaction 4014: Create Market Order 4014 (CLIENT_ORDER): 8405.0 of EUR_GBP
Transaction 4015: Fill Order 4014 (MARKET_ORDER): 8405.0 of EUR_GBP @ 0.87327
Vous pouvez affiner le type de transaction en spécifiant le type
v20-transaction-range.exe --type ORDER_FILL 4000 9999
```consoe
Transaction 4006: Fill Order 3998 (STOP_LOSS_ORDER): -14604.0 of GBP_USD @ 1.24422
Transaction 4007: Fill Order 4005 (STOP_LOSS_ORDER): -17552.0 of AUD_JPY @ 68.736
Transaction 4009: Fill Order 3995 (STOP_LOSS_ORDER): -18483.0 of AUD_USD @ 0.64342
Transaction 4011: Fill Order 4010 (MARKET_ORDER): -8925.0 of AUD_JPY @ 68.308
Transaction 4015: Fill Order 4014 (MARKET_ORDER): 8405.0 of EUR_GBP @ 0.87327
Transaction 4025: Fill Order 4024 (MARKET_ORDER_TRADE_CLOSE): -8405.0 of EUR_GBP @ 0.8733
Transaction 4029: Fill Order 4028 (MARKET_ORDER_TRADE_CLOSE): 8925.0 of AUD_JPY @ 68.372
v20-transaction-get Vérifiez les détails par ID de transaction.
v20-transaction-get
id: '4100'
time: '2020-04-19T14:17:16.552497903Z'
userID: 2202754
accountID: xxx-xxx-xxxxxxx-xxx
batchID: '4100'
type: ORDER_FILL
orderID: '4099'
instrument: USD_CAD
units: 16311.0
gainQuoteHomeConversionFactor: 77.674
lossQuoteHomeConversionFactor: 77.693
price: 1.38913
fullVWAP: 1.38913
fullPrice:
type: PRICE
bids:
- price: 1.38894
liquidity: '10000000'
asks:
- price: 1.38913
liquidity: '10000000'
closeoutBid: 1.38894
closeoutAsk: 1.38913
reason: STOP_LOSS_ORDER
pl: -1406.6481
financing: 0.0
commission: 0.0
guaranteedExecutionFee: 0.0
accountBalance: 278334.8247
tradesClosed:
- tradeID: '4098'
units: 16311.0
price: 1.38913
realizedPL: -1406.6481
financing: 0.0
guaranteedExecutionFee: 0.0
halfSpreadCost: 120.3749
halfSpreadCost: 120.3749
J'ai publié par inadvertance des informations supplémentaires, je les ai donc supprimées et republiées ...
Recommended Posts