alanwhite / thierrybot

Automates management of orders and positions on IG Index as directed by SMS messages
1 stars 0 forks source link

Amend order directive fails to find position to update #6

Closed alanwhite closed 7 years ago

alanwhite commented 7 years ago

2017-06-26 17:26:28.790 (+01:00) 336619b0-5a8c-11e7-881a-9b4522390853 Amending order ... 2017-06-26 17:26:28.959 (+01:00) 336619b0-5a8c-11e7-881a-9b4522390853 [ { position: { contractSize: 1, createdDate: '2017/06/26 10:40:53:000', createdDateUTC: '2017-06-26T09:40:53', dealId: 'DIAAAABCN8F7DAJ', dealReference: '4C5HAERZ2JJ44TD', size: 10, direction: 'SELL', limitLevel: 7405, level: 7475, currency: 'GBP', controlledRisk: false, stopLevel: 7515, trailingStep: null, trailingStopDistance: null, limitedRiskPremium: null }, market: { instrumentName: 'FTSE 100', expiry: 'DFB', epic: 'IX.D.FTSE.DAILY.IP', instrumentType: 'INDICES', lotSize: 1, high: 7458.9, low: 7443.4, percentageChange: -0.01, netChange: -1, bid: 7451.9, offer: 7453.9, updateTime: '17:25:43', updateTimeUTC: '16:25:43', delayTime: 0, streamingPricesAvailable: true, marketStatus: 'TRADEABLE', scalingFactor: 1 } } ] 2017-06-26 17:26:29.190 (+01:00) 336619b0-5a8c-11e7-881a-9b4522390853 Error: no position to amend at findPosition (/var/task/functions/PositionManager.js:101:26) at ig.positions (/var/task/functions/PositionManager.js:196:7)

alanwhite commented 7 years ago

Code searches on trade direction to find a trade, amend directive doesn't include the direction. Approach will be to ignore the direction in the predicate for finding the position. We shouldn't have two simultaneous positions open on the same instrument in the system used.

alanwhite commented 7 years ago

Code only checks the instrument name when filtering positions since commit c4efb675a0abf3b627928b9487ad15c2f3f4dd02