ドキュメント
アプリケーション
Last updated on 12. 10. 2021 by Mark Fric
ResultsGroup の操作
ページのコンテンツ
結果グループ is the object that SQX uses to store:
- strategy code/XML
- backtest results
- other results from optimizations and cross checks
- settings used in the last backtests
- other useful custom values in its key-value store
Each strategy you see in the databank is in fact a 結果グループ object containing the strategy + results that are then displayed in the databank columns or in trades list, equity chart, etc.
Getting individual results from group
There can be multiple backtests or optimizations performed for one strategy – you can have main backtest + backtests on additional markets, or additional WF optimizations.
The results of these separate backtests are stored as separate Result objects in the ResultsGroup, so ResultsGroup object is in fact a group of Result objects plus few other things.
Individual results in the ResultsGroup are accessible by calling サブ結果(結果キー) method, where resultKey is the name (key) of the subresult you want to get.
You can get a list of all result keys by calling getResultKeys(), which will return an array of all the keys the ResultGroup contains.
You can also use a special method getMainResultKey() to get key of the main backtest result.
Result mainResult = resultsGroup.subResult( resultsGroup.getMainResultKey() ) // will return the main backtest result.
ResultsGroup object name is the strategy name you see in databank, so calling resultsGroup.getName() will return “Strategy 1.2.3” for example
ポートフォリオ
There is also a special portfolio result that is added automatically if ResultsGroup contains more than one result. You can get portfolio result by simply calling ResultsGroup.ポートフォリオ()
Result portfolioResult = resultsGroup.ポートフォリオ().
If there is just one result this call will return the main backtest result.
Getting metrics from a Result
When you have a Result you can easily get the metrics such as Net profit, SharpeRatio etc. that were computed for this result.
All computed metrics are stored in SQStats object that you can get by calling Result.stats(Direction, PLType, SampelType). Note that the stats() method has three parameters – the stats are computed separately for:
- every direction (Long, Short, Both),
- PL type (money, percent, pips)
- sample type (FullSample, InSample, OutOfSample).
SQStats statsIS = result.stats(Directions.Both, PlTypes.Money, SampleTypes.InSample); SQStats statsOOS = result.stats(Directions.Both, PlTypes.Money, SampleTypes.OutOfSample); SQStats statsLong = result.stats(Directions.Long, PlTypes.Money, SampleTypes.FullSample);
その SQStats object is a simple key-value map that contains the computed metrics for the given stats combination. The metrics are stored under the keys that correspond to the class names of Java snippets, for example “NetProfit”, “Drawdown”, etc.
Once you have SQStats object you can get the value of the metric by simply calling:
double netProfit = stats.getDouble("NetProfit");
int noOfTradest = stats.getInt("NumberOfTrades");
この記事は参考になりましたか? この記事は役に立った この記事は役に立たなかった
Hi before I study this in detail….. does this allow me to select specific walk forward runs to build an optimized portfolio? I had posted a request below so that the trades from a specific run can be used in quant analyzer. Does this do the same? thanks
https://roadmap.strategyquant.com/tasks/sq4_8403
This is very helpful, I am testing it. Thank you Mark
where can I find example of Result objects ?
, subResult(resultKey) method ?,
getResultKeys(), getMainResultKey()
SQStats statsIS = result.stats(Directions.Both, PLTypes.Money, SampleTypes.InSample);
I search in the code editor with getResultKey, and other key word but I didn’t find any example.
こんにちは,
this might help you as well https://strategyquant.com/doc/programming-for-sq/working-with-resultsgroup/
ありがとう