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

31
LINES

< > BotCompany Repo | #1036514 // PullbackToProfit

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

Libraryless. Click here for Pure Java version (10327L/57K).

1  
sclass PullbackToProfit {
2  
  settable double pullback;
3  
  settable double profit;
4  
  settable long startTime;
5  
  settable long timestamp;
6  
  settable bool isShort;
7  
  
8  
  double cleanness() {
9  
    ret profit() <= 0 ? 0 : profit()/pullback();
10  
  }
11  
  
12  
  // Are we going backwards in time?
13  
  bool isBackwards() { ret timestamp < startTime; }
14  
  
15  
  toString {
16  
    var duration = formatMinutes(absDiff(timestamp(), startTime()));
17  
    ret shortenNumbers(2, concat(
18  
      isShort != isBackwards() ? "Short" : "Long", 
19  
      " with callback ",
20  
      pullback(),
21  
      "% yields ",
22  
      profit(), "% profit in ",
23  
      duration,
24  
      " (cleanness ", formatDouble1(cleanness()), ")"));
25  
  }
26  
  
27  
  bool replaces(PullbackToProfit ptp) {
28  
    ret pullback() <= ptp.pullback()
29  
      && profit() >= ptp.profit();
30  
  }
31  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1036514
Snippet name: PullbackToProfit
Eternal ID of this version: #1036514/5
Text MD5: 40fc48c6a81749bc85d4ae9e6f43ef69
Transpilation MD5: b284aa05c969cb31580adffb604ee10f
Author: stefan
Category: javax / trading
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-22 15:26:18
Source code size: 822 bytes / 31 lines
Pitched / IR pitched: No / No
Views / Downloads: 83 / 144
Version history: 4 change(s)
Referenced in: [show references]