-
Notifications
You must be signed in to change notification settings - Fork 0
/
code.txt
216 lines (195 loc) · 6.08 KB
/
code.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
Time,Ask,Bid,AskVolume,BidVolume
->
Time,Bid,Ask,BidVolume,AskVolume
ln -s `pwd` env/lib/python3.7/site-packages/qsforex
curl -H "Authorization: Bearer 24655e327e5d3b21160261116d9f028b-c9779d30d729c87b093158a296568d7e" https://api-fxpractice.oanda.com/v3/accounts
python -m unittest broker/oanda/tests.py
python -m unittest broker/oanda/tests.py TestAccount.test_pending_order
python -m unittest broker/oanda.tests.TestAccount.test_pending_order
entry accuracy= 1 - min / (max-min)
exit accuracy= 1 - profit missed / (max-min)
risk:reward= 1: max/-min or 1:max
drawdown
accountId: 3261139
accountName: 03261139
amountK: 330
close: 110.665 current_price
com: 0
currency: USD/JPY
currencyPoint: 29.80209
grossPL: 149.09863 profit
isBuy: False
isDisabled: False
limit: 106.2 take_profit
open: 110.715 open_price
roll: 0
stop: 110.96 stop_loss
stopMove: 0
time: 2019-03-22 02:11:39 open_time
tradeId: 207362756
usedMargin: 825
valueDate:
visiblePL: 5.2 pips
ac.trades['99'].__dict__
Out[12]:
{'id': '99',
'instrument': 'EUR_USD',
'price': 1.1337,
'openTime': '2019-02-21T02:34:07.523411595Z',
'state': 'OPEN',
'initialUnits': 10000.0,
'initialMarginRequired': 316.988,
'currentUnits': 10000.0,
'realizedPL': 0.0,
'unrealizedPL': 0.2792,
'marginUsed': 316.628,
'averageClosePrice': None,
'closingTransactionIDs': None,
'financing': 0.0,
'closeTime': None,
'clientExtensions': <v20.transaction.ClientExtensions at 0x1135b2b70>,
'takeProfitOrderID': None,
'stopLossOrderID': '100',
'trailingStopLossOrderID': '101'}
ac.orders['100'].__dict__
Out[13]:
{'id': '100',
'createTime': '2019-02-21T02:34:07.523411595Z',
'state': 'PENDING',
'clientExtensions': None,
'type': 'STOP_LOSS',
'guaranteedExecutionPremium': None,
'tradeID': '99',
'clientTradeID': None,
'price': 1.1317,
'distance': None,
'timeInForce': 'GTC',
'gtdTime': None,
'triggerCondition': 'DEFAULT',
'guaranteed': False,
'fillingTransactionID': None,
'filledTime': None,
'tradeOpenedID': None,
'tradeReducedID': None,
'tradeClosedIDs': None,
'cancellingTransactionID': None,
'cancelledTime': None,
'replacesOrderID': None,
'replacedByOrderID': None}
ac.orders['101'].__dict__
Out[14]:
{'id': '101',
'createTime': '2019-02-21T02:34:07.523411595Z',
'state': 'PENDING',
'clientExtensions': None,
'type': 'TRAILING_STOP_LOSS',
'tradeID': '99',
'clientTradeID': None,
'distance': 0.001,
'timeInForce': 'GTC',
'gtdTime': None,
'triggerCondition': 'DEFAULT',
'trailingStopValue': 1.13299,
'fillingTransactionID': None,
'filledTime': None,
'tradeOpenedID': None,
'tradeReducedID': None,
'tradeClosedIDs': None,
'cancellingTransactionID': None,
'cancelledTime': None,
'replacesOrderID': None,
'replacedByOrderID': None}
ac.trades['99'].clientExtensions.__dict__
Out[15]: {'id': None, 'tag': 'test', 'comment': 'test'}
"""
MarketOrderTransaction
==================== ==============================
Transaction ID 50
Time 2019-02-20T11:07:09.929954793Z
User ID 10496264
Account ID 101-011-10496264-001
Transaction Batch ID 50
Request ID 78561536958074011
Type MARKET_ORDER
Instrument EUR_USD
Amount 10000.0
Time In Force FOK
Position Fill DEFAULT
Reason CLIENT_ORDER
==================== ==============================
OrderFillTransaction
================================= ==============================
Transaction ID 51
Time 2019-02-20T11:07:09.929954793Z
User ID 10496264
Account ID 101-011-10496264-001
Transaction Batch ID 50
Request ID 78561536958074011
Type ORDER_FILL
Filled Order ID 50
Fill Instrument EUR_USD
Fill Units 10000.0
Gain Quote Home Conversion Factor 1.397799863016
Loss Quote Home Conversion Factor 1.398053908959
Fill Price 1.13392
Full VWAP 1.13392
Price <pricing.ClientPrice>
Fill Reason MARKET_ORDER
Profit/Loss 0.0
Financing 0.0
Commission 0.0
Guranteed Execution Fee 0.0
Account Balance 99999.8521
Trade Opened <transaction.TradeOpen>
Half Spread Cost 0.9087
================================= ==============================
{'id': '50',
'time': '2019-02-20T11:07:09.929954793Z',
'userID': 10496264,
'accountID': '101-011-10496264-001',
'batchID': '50',
'requestID': '78561536958074011',
'type': 'MARKET_ORDER',
'instrument': 'EUR_USD',
'units': 10000.0,
'timeInForce': 'FOK',
'priceBound': None,
'positionFill': 'DEFAULT',
'tradeClose': None,
'longPositionCloseout': None,
'shortPositionCloseout': None,
'marginCloseout': None,
'delayedTradeClose': None,
'reason': 'CLIENT_ORDER',
'clientExtensions': None,
'takeProfitOnFill': None,
'stopLossOnFill': None,
'trailingStopLossOnFill': None,
'tradeClientExtensions': None}
{'id': '51',
'time': '2019-02-20T11:07:09.929954793Z',
'userID': 10496264,
'accountID': '101-011-10496264-001',
'batchID': '50',
'requestID': '78561536958074011',
'type': 'ORDER_FILL',
'orderID': '50',
'clientOrderID': None,
'instrument': 'EUR_USD',
'units': 10000.0,
'gainQuoteHomeConversionFactor': 1.397799863016,
'lossQuoteHomeConversionFactor': 1.398053908959,
'price': 1.13392,
'fullVWAP': 1.13392,
'fullPrice': <v20.pricing.ClientPrice at 0x118f9f3c8>,
'reason': 'MARKET_ORDER',
'pl': 0.0,
'financing': 0.0,
'commission': 0.0,
'guaranteedExecutionFee': 0.0,
'accountBalance': 99999.8521,
'tradeOpened': <v20.transaction.TradeOpen at 0x118f9f470>,
'tradesClosed': None,
'tradeReduced': None,
'halfSpreadCost': 0.9087}
"""