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
persistable sclass LivePullbackToProfitAnalysis {
settable double pullbackLimit = 1.0;
settable double adversity = 0.2;
settable boolean isShort;
settable long startTime;
settable double openingPrice;
settable double crest = 0;
settable double maxPullback;
settable PullbackToProfit ptp;
double priceToProfit(double price) {
var profit = asPercentIncrease(price, openingPrice());
if (isShort()) profit = neg(profit);
ret profit-adversity();
}
void add aka feed(PricePoint pp) {
if (startTime == 0) {
startTime(pp.time());
openingPrice(pp.price());
}
var price = pp.price();
var time = pp.time();
var profit = priceToProfit(price);
crest = max(crest, profit);
var pullback = crest-profit;
maxPullback = max(maxPullback, pullback);
if (done()) ret;
var result = new PullbackToProfit().pullback(maxPullback).profit(crest-maxPullback);
if (ptp == null || !ptp.replaces(result))
ptp(result
.isShort(isShort)
.timestamp(time)
.startTime(startTime()));
}
double cleanness() {
ret ptp == null ? 0 : ptp.cleanness();
}
double profit() {
ret ptp == null ? -infinity() : ptp.profit();
}
bool done() {
ret maxPullback >= pullbackLimit();
}
}