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

39
LINES

< > BotCompany Repo | #1036117 // TradingRun - a list of successive TradingCandles

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

Libraryless. Click here for Pure Java version (10842L/61K).

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);
    projectedEndTime(candle.projectedEndTime);
    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()) + "%";
  }
  
  // TODO: This really doesn't fit anymore
  bool isCompatibleCandle(TradingCandle candle) {
    ret candle.isWhite() || eq(candle.colorText(), colorText());
  }
  
  public TradingRun clone() {
    ret shallowClone(this).candles(map(candles, -> .clone()));
  }
  
  TradingCandle asCandle() {
    ret shallowCloneToClass(TradingCandle, this);
  }
}

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 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: 232 / 376
Version history: 20 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)