May 27, 2020

5 2

RecoveryFactor

as requested here: https://roadmap.strategyquant.com/tasks/sq4_6339

The code is very simple:

package SQ.Columns.Databanks;

import com.strategyquant.lib.L;
import com.strategyquant.lib.SettingsMap;
import com.strategyquant.tradinglib.DatabankColumn;
import com.strategyquant.tradinglib.OrdersList;
import com.strategyquant.tradinglib.SQStats;
import com.strategyquant.tradinglib.StatsTypeCombination;
import com.strategyquant.tradinglib.ValueTypes;

public class RecoveryFactor extends DatabankColumn {
    
    public RecoveryFactor() {
        super(L.t("RecoveryFactor"), DatabankColumn.Decimal2, ValueTypes.Maximize, 0, 0, 200);
        
        setDependencies("NetProfit", "DrawdownPct");
    }
    
    //------------------------------------------------------------------------

    @Override
    public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception {
        int netProfit = stats.getInt("NetProfit");
        int drawdownPct = stats.getInt("DrawdownPct");
        
        return round2(safeDivide(netProfit, drawdownPct));
    }
}

 

 

2 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
pequeno
pequeno
September 16, 2020 2:19 pm

Please, In which Strategyquant directory should the RecoveryFactor.sxp file be inserted?

tomas262
tomas262
Reply to  pequeno
October 30, 2020 9:04 pm

Simply open the CodeEditor in SQX using the </> button, then click Import / Export and import the SXP file