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

sclass PullbackToProfit {
  settable double pullback;
  settable double profit;
  settable long startTime;
  settable long timestamp;
  settable bool isShort;
  
  double cleanness() {
    ret profit() <= 0 ? 0 : profit()/pullback();
  }
  
  // Are we going backwards in time?
  bool isBackwards() { ret timestamp < startTime; }
  
  toString {
    var duration = formatMinutes(absDiff(timestamp(), startTime()));
    ret shortenNumbers(2, concat(
      isShort != isBackwards() ? "Short" : "Long", 
      " with callback ",
      pullback(),
      "% yields ",
      profit(), "% profit in ",
      duration,
      " (cleanness ", formatDouble1(cleanness()), ")"));
  }
  
  bool replaces(PullbackToProfit ptp) {
    ret pullback() <= ptp.pullback()
      && profit() >= ptp.profit();
  }
}

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