Tradestation – Robusteness Index
1 replies
C C
4 years ago #276911
<span class="Y2IQFc" lang="en">I try to create a snippet of the metric in question but I get error on TotalDataDays. I ask for help in finishing it. Thank you</span>
0
C C
4 years ago #276912
package SQ.Columns.Databanks;
import com.strategyquant.lib.*;
import com.strategyquant.datalib.*;
import com.strategyquant.tradinglib.*;
public class RobustnessIndex extends DatabankColumn {
public RobustnessIndex() {
super(“RobustnessIndex”,
DatabankColumn.Decimal2, // value display format
ValueTypes.Maximize, // whether value should be maximized / minimized / approximated to a value
0, // target value if approximation was chosen
0, // average minimum of this value
100); // average maximum of this value
setWidth(80); // defaultcolumn width in pixels
setTooltip(“Robusteness Index from Tradestation”);
}
//————————————————————————
public String getValue(ResultsGroup results, String resultKey, byte direction, byte plType, byte sampleType) throws Exception {
SQStats statsIS = results.subResult(resultKey).stats(Directions.Both, PlTypes.Money, SampleTypes.InSample);
SQStats statsOOS = results.subResult(resultKey).stats(Directions.Both, PlTypes.Money, SampleTypes.OutOfSample);
SQStats statsdataIS = results.subResult(resultKey).stats(Directions.Both, PLtypes.Money, SampleTypes.InSample);
SQStats statsdataOOS = results.subResult(resultKey).stats(Directions.Both, PlTypes.Money, SampleTypes.OutOfSample);
double npIS = 0, npOOS = 0;
int totaldataIS = 0, totaldataOOS=0;
if(statsIS != null) npIS = statsIS.getDouble(“NetProfit”);
if(statsOOS != null) npOOS = statsOOS.getDouble(“NetProfit”);
if(statsdataIS != null) totaldataIS = statsdataIS.getInt(“TotalDataDays”);
if(statsdataOOS != null) totaldataOOS = statsdataOOS.getInt(“TotalDataDays”);
//RobustenessIndex = (OOS Profit * 365 / numeber of OOS days) / (IS Profit * 365 / number of IS days) * 100
double ratio = SQUtils.safeDivide(((npOOS*365)/totaldataOOS),((npIS*365)/totaldataIS))*100;
return String.format(“%.2f”, ratio);
}
}
0
Viewing 1 replies (of 1 total)