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

24
LINES

< > BotCompany Repo | #1036118 // TradingSignal

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

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

sclass TradingSignal extends Meta {
  settable S coin;
  settable bool isLong;
  settable Timestamp timestamp;
  settable TradingRun afterRun;
  
  toString {
    S text = (isLong ? "Long" : "Short") + " signal "
      + (empty(coin) ? "" : "for " + coin + " ") + "at "
      + timestamp;
    if (afterRun != null)
      text += " after " + formatDouble2X(afterRun.changePercent()) + "% run";
    ret text;
  }
  
  // last candle before signal
  TradingCandle candle() { ret afterRun == null ?: last(afterRun.candles); }
  
  // Price at signal
  double price() {
    var candle = candle();
    ret candle == null ? Double.NaN : candle.end();
  }
}

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): elmgxqgtpvxh, mqqgnosmbjvj, wnsclhtenguj

No comments. add comment

Snippet ID: #1036118
Snippet name: TradingSignal
Eternal ID of this version: #1036118/10
Text MD5: b6efb6df89bee63b0bdc2303e5a0042b
Transpilation MD5: 87419779e93db714ff2e109fac1576a9
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-12-15 20:57:55
Source code size: 672 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 95 / 174
Version history: 9 change(s)
Referenced in: #1003674 - Standard Classes + Interfaces (LIVE continued in #1034167)