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).

1  
sclass TradingSignal extends Meta {
2  
  settable S coin;
3  
  settable bool isLong;
4  
  settable Timestamp timestamp;
5  
  settable TradingRun afterRun;
6  
  
7  
  toString {
8  
    S text = (isLong ? "Long" : "Short") + " signal "
9  
      + (empty(coin) ? "" : "for " + coin + " ") + "at "
10  
      + timestamp;
11  
    if (afterRun != null)
12  
      text += " after " + formatDouble2X(afterRun.changePercent()) + "% run";
13  
    ret text;
14  
  }
15  
  
16  
  // last candle before signal
17  
  TradingCandle candle() { ret afterRun == null ?: last(afterRun.candles); }
18  
  
19  
  // Price at signal
20  
  double price() {
21  
    var candle = candle();
22  
    ret candle == null ? Double.NaN : candle.end();
23  
  }
24  
}

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: 150 / 260
Version history: 9 change(s)
Referenced in: [show references]