27. 5. 2020

5 3

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));
    }
}

 

 

Subscribe
Notify of
3 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
pequeno
pequeno
16. 9. 2020 2:19 pm

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

tomas262
tomas262
Reply to  pequeno
30. 10. 2020 9:04 pm

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

Emmanuel
11. 1. 2022 4:04 pm

excellent ! thank you !!!