Libraryless. Click here for Pure Java version (29633L/186K).
1 | sclass G22StrategyRun {
|
2 | settable G22TradingStrategy strategy; |
3 | settable TickerSequence ticker; |
4 | settable new TickerSequence profitTicker; |
5 | settable double finalProfit; |
6 | settable transient IIteratorMonitor iteratorMonitor = dummyIteratorMonitor(); |
7 | |
8 | double totalProfit() { ret finalProfit; }
|
9 | |
10 | run {
|
11 | strategy(strategy.emptyClone()); |
12 | strategy.logToPrint(false); |
13 | strategy.actualTicker(ticker); |
14 | strategy.primed(true); |
15 | strategy.active(true); |
16 | |
17 | temp it = iteratorMonitor.monitorIterator("Backtest", ticker.pricePoints());
|
18 | for (pricePoint : it) {
|
19 | if (!strategy.active()) break; |
20 | strategy.feed(pricePoint); |
21 | double profit = strategy.coinProfit(); |
22 | profitTicker.addIfPriceChanged(profit, pricePoint.timestamp); |
23 | } |
24 | |
25 | strategy.closeMyself(); |
26 | finalProfit(strategy.coinProfit()); |
27 | } |
28 | } |
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mowyntqkapby, mqqgnosmbjvj
No comments. add comment
| Snippet ID: | #1036303 |
| Snippet name: | G22StrategyRun - one run of a trading strategy |
| Eternal ID of this version: | #1036303/15 |
| Text MD5: | 1ff77367a31872fada0e79d778edcda8 |
| Transpilation MD5: | 5e44dfd5a0cfe0e85fe1d815c9bbec1c |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-01-22 16:47:29 |
| Source code size: | 877 bytes / 28 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 619 / 809 |
| Version history: | 14 change(s) |
| Referenced in: | [show references] |