Warning: session_start(): open(/var/lib/php/sessions/sess_8suu8ph0g2nkvhkklgo1ufkj31, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
sclass TradingPosition {
settable S coin;
settable bool isLong;
settable int leverage;
// How much we originally invest in USDT
settable double marginInvestment;
// How much USDT margin we end up with
settable double margin;
// How much crypto we bet on
settable double amount;
// Is position still open?
settable bool ongoing;
settable long openingTime;
settable long closingTime;
settable double openingPrice;
// closing or current price
settable double closingPrice;
settable double openingFees;
settable double closingFees;
// Actual price movement during position
settable TradingCandle candle;
// Signal we acted on (optional)
settable TradingSignal afterSignal;
double openingFeePercentage() {
ret doubleRatio(openingFees, margin*leverage);
}
double priceDifference() {
ret closingPrice-openingPrice;
}
double leveragedPriceDifference() {
ret priceDifference()*leverage;
}
// PNL = Profit & Loss
double expectedPNL aka relativeValue() {
ret (isLong() ? 1 : -1)*leveragedPriceDifference()*amount;
}
bool isOpen() { ret ongoing; }
}