Databank column always shows zero value
1 replies
Julian Gonzalez
10 months ago #291831
I have created a Databank column and a template code is auto-generated calculating netProfit. I compile it and restart SQX UI. When I open the DataBank from Builder and add the column, it always shows zero value. The same happens if I download snippets from the community.
If I create a new one with just getNumericValue() and getValue() it works perfectly. So it seems that the compute() function it does nothing, why?
I already tried with 136, 142 and 143 versions. Help!
This is the template:
package SQ.Columns.Databanks;import com.strategyquant.lib.*;import com.strategyquant.datalib.*;import com.strategyquant.tradinglib.*;public class Prueba2 extends DatabankColumn {public Prueba2() {super(“Prueba2”,DatabankColumn.Decimal2, // value display formatValueTypes.Maximize, // whether value should be maximized / minimized / approximated to a value0, // target value if approximation was chosen0, // average minimum of this value100); // average maximum of this valuesetWidth(80); // defaultcolumn width in pixelssetTooltip(“Your tooltip here”);/* If this new column is dependent on some other columns that have to vbe computed first, put them here.Make sure you don’t creat circular dependency, such as A depends on B and B depends on A.Columns (=stats values) are identified by the name of class)*///setDependencies(“DrawdownPct”, “NumberOfTrades”);}//————————————————————————/*** This method should return computed value of this new column. You should typically compute it from the list of orders* or from some already computed statistical values (other databank columns).*/@Overridepublic double compute(SQStats stats, StatsTypeCombination combination, OrdersList ordersList, SettingsMap settings, SQStats statsLong, SQStats statsShort) throws Exception {/* an example – this is how you can get other values that this new value is dependent on *///int numberOfTrades = stats.getInt(“NumberOfTrades”);//double drawdownPct = stats.getDouble(“DrawdownPct”);/* an example – calculating net profit from the list of trades */double netProfit = 0;for(int i = 0; i<ordersList.size(); i++) {Order order = ordersList.get(i);if(order.isBalanceOrder()) {// don’t count balance orders (deposits, withdrawals) incontinue;}/* method getPLByStatsType automatically returns PL depending on given stats type – in money, % or pips */double PL = getPLByStatsType(order, combination);netProfit += PL;}/* round and return the value. It will be saved into stats under the key “Prueba2” */return round2(netProfit);}}
0
Julian Gonzalez
10 months ago #291832
Solved!
It seems the compute() function only updates when you force the strategy to be backtested again (retesting it or generating a new strategy). Instead, getNumericValue() and getValue() functions does not need it.
🙂
1
Viewing 1 replies (of 1 total)