Libraryless. Click here for Pure Java version (10842L/61K).
1 | persistable sclass TradingRun extends TradingCandle is IntSize {
|
2 | settable new L<TradingCandle> candles; |
3 | |
4 | *(Iterable<TradingCandle> candles) {
|
5 | fOr (c : candles) add(c); |
6 | } |
7 | |
8 | void add aka addCandle(TradingCandle candle) {
|
9 | candles.add(candle); |
10 | addValue(candle.start, candle.startTime); |
11 | addValue(candle.end, candle.endTime); |
12 | projectedEndTime(candle.projectedEndTime); |
13 | if (candle.min < min) min = candle.min; |
14 | if (candle.max > max) max = candle.max; |
15 | } |
16 | |
17 | public int size() { ret l(candles); }
|
18 | |
19 | double changePercent() {
|
20 | ret asPercentIncrease(changeRatio()); |
21 | } |
22 | |
23 | S myType() {
|
24 | ret "run length " + n2(candles) + ", change " + formatDouble2X(changePercent()) + "%"; |
25 | } |
26 | |
27 | // TODO: This really doesn't fit anymore |
28 | bool isCompatibleCandle(TradingCandle candle) {
|
29 | ret candle.isWhite() || eq(candle.colorText(), colorText()); |
30 | } |
31 | |
32 | public TradingRun clone() {
|
33 | ret shallowClone(this).candles(map(candles, -> .clone())); |
34 | } |
35 | |
36 | TradingCandle asCandle() {
|
37 | ret shallowCloneToClass(TradingCandle, this); |
38 | } |
39 | } |
Began life as a copy of #1036115
download show line numbers debug dex old transpilations
Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj
No comments. add comment
| Snippet ID: | #1036117 |
| Snippet name: | TradingRun - a list of successive TradingCandles |
| Eternal ID of this version: | #1036117/21 |
| Text MD5: | 6c3f9c219f3aec0d32953e9770b8b7e4 |
| Transpilation MD5: | f922a4355289273b3f5e3e7805ef0bc0 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX fragment (include) |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2023-03-20 21:43:46 |
| Source code size: | 1108 bytes / 39 lines |
| Pitched / IR pitched: | No / No |
| Views / Downloads: | 718 / 925 |
| Version history: | 20 change(s) |
| Referenced in: | [show references] |