Ret/Open DD ratio

Ret/Open DD ratio



Extremely easy to implement. 


More useful than Ret/DD (Sometimes open dd can be bigger than dd, so the max risk/minimum amount of money needed to run a strategy is more than expected. Ret/Open DD ratio would solve so many problems).

Attachments
No attachments
  • Votes +3
  • Project StrategyQuant X
  • Type Feature
  • Status New
  • Priority Normal

History

KF
#1

remEmb3r

23.03.2024 01:19

Task created

k
#2

Karish

23.03.2024 11:39
Voted for this task.
k
#3

Karish

23.03.2024 11:49
You can close this Task unless the SQX Dev team wants to include it as Built-In,

here is the a code for Return / OpenDrawdown:
/*
 * Copyright (c) 2017-2018, StrategyQuant - All rights reserved.
 *
 * Code in this file was made in a good faith that it is correct and does what it should.
 * If you found a bug in this code OR you have an improvement suggestion OR you want to include
 * your own code snippet into our standard library please contact us at:
 * https://roadmap.strategyquant.com
 *
 * This code can be used only within StrategyQuant products.
 * Every owner of valid (free, trial or commercial) license of any StrategyQuant product
 * is allowed to freely use, copy, modify or make derivative work of this code without limitations,
 * to be used in all StrategyQuant products and share his/her modifications or derivative work
 * with the StrategyQuant community.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES
 * OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */
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 ReturnOpenDD extends DatabankColumn {
   
    public ReturnOpenDD() {
        super(L.tsq("Ret/OpenDD Ratio"), DatabankColumn.Decimal2, ValueTypes.Maximize, 0, -100, 100);

        setDependencies("NetProfit", "OpenDrawdown", "NumberOfTrades");
        setTooltip(L.tsq("Return / OpenDrawdown Ratio"));
    }

    //------------------------------------------------------------------------

    @Override
    public double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception {
        double netProfit  = stats.getDouble("NetProfit");
        double DD = Math.abs(stats.getDouble("OpenDrawdown"));
        int numberOfTrades = stats.getInt("NumberOfTrades");
       
        if(numberOfTrades==0) {
            return 0;
        }
       
        if(DD == 0) {
            // if there is no drawdown return half of the avg. max value of this ratio
            return 10d;
        }
        return round2(safeDivide(netProfit, DD));
    }  
}
A
#4

Asoea

31.03.2024 03:56
Voted for this task.
h
#5

hruyak41287

18.04.2024 10:47
Voted for this task.

Votes: +3

Drop files to upload

or

choose files

Max size: 5MB

Not allowed: exe, msi, application, reg, php, js, htaccess, htpasswd, gitignore

...
Wait please