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

5
LINES

< > BotCompany Repo | #1036505 // calculatePositionProfit

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

Libraryless. Click here for Pure Java version (35L/1K).

1  
// calculate profit in percent for a position
2  
// direction = 1 for long, -1 for short
3  
static double calculatePositionProfit(double openingPrice, double closingPrice, int direction, int leverage) {
4  
  ret (closingPrice-openingPrice)*direction/openingPrice*leverage*100;
5  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1036505
Snippet name: calculatePositionProfit
Eternal ID of this version: #1036505/1
Text MD5: 4723259844268af87796f8ae359b5baa
Transpilation MD5: f6d8d69deea120d311cd6c2b28f9c9ab
Author: stefan
Category: javax / trading
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2023-01-16 14:36:39
Source code size: 273 bytes / 5 lines
Pitched / IR pitched: No / No
Views / Downloads: 142 / 192
Referenced in: [show references]