Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

33
LINES

< > BotCompany Repo | #1036117 // TradingRun - a bull run oder bear run in crypto

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (9803L) is out of date.

persistable sclass TradingRun extends TradingCandle is IntSize {
  settable new L<TradingCandle> candles;
  
  *(Iterable<TradingCandle> candles) {
    fOr (c : candles) add(c);
  }
  
  void add aka addCandle(TradingCandle candle) {
    candles.add(candle);
    addValue(candle.start, candle.startTime);
    addValue(candle.end, candle.endTime);
    if (candle.min < min) min = candle.min;
    if (candle.max > max) max = candle.max;
  }
  
  public int size() { ret l(candles); }
  
  double changePercent() {
    ret asPercentIncrease(changeRatio());
  }
  
  S myType() {
    ret "run length " + n2(candles) + ", change " + formatDouble2X(changePercent()) + "%";
  }
  
  bool isCompatibleCandle(TradingCandle candle) {
    ret candle.isWhite() || eq(candle.colorText(), colorText());
  }
  
  public TradingRun clone() {
    ret shallowClone(this).candles(map(candles, -> .clone()));
  }
}

Author comment

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 bull run oder bear run in crypto
Eternal ID of this version: #1036117/16
Text MD5: 9ef5dabee5b147de5a35ec2d2d4b05f5
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-09-28 20:22:00
Source code size: 926 bytes / 33 lines
Pitched / IR pitched: No / No
Views / Downloads: 28 / 87
Version history: 15 change(s)
Referenced in: [show references]