Transpiled version (9950L) is out of date.
sclass PositionCloseOracle { // The currently open position settable TradingPosition position; // our loss tolerance (how much of our investment we are // prepared to lose in one trade) settable double lossTolerancePercent = 10; // Set when position should be closed settable bool closeSignal; // Set when the position is expected to lose money settable bool badClose; // React to a new ticker value coming in void addValue(double price, Timestamp timestamp) { // Feed new price to position position.closingPrice(price); // Bad case - end because too much loss if (lossTooBig()) { closeSignal(true); badClose(true); } // Good case - end because good run ended (TODO) } double absoluteLossTolerance() { ret lossTolerancePercent()*100*position.margin(); } bool lossTooBig() { ret position.expectedPNL() > absoluteLossTolerance(); } }
download show line numbers debug dex old transpilations
Travelled to 2 computer(s): elmgxqgtpvxh, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036120 |
| Snippet name: | PositionCloseOracle - decides when to close a trading position [abandoned] |
| Eternal ID of this version: | #1036120/4 |
| Text MD5: | 8c6e12dc67ab2e565c9f26a54d034305 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2022-11-07 12:16:17 |
| Source code size: | 988 bytes / 39 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 679 / 814 |
| Version history: | 3 change(s) |
| Referenced in: | [show references] |