Libraryless. Click here for Pure Java version (35L/1K).
// calculate profit in percent for a position // direction = 1 for long, -1 for short static double calculatePositionProfit(double openingPrice, double closingPrice, int direction, int leverage) { ret (closingPrice-openingPrice)*direction/openingPrice*leverage*100; }
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: | 143 / 194 |
Referenced in: | #1006654 - Standard functions list 2 (LIVE, continuation of #761) |