SQX Custom Project – Databank Filter
3件の返信
Good morning and happy new year.
Does anyone know how I can filter a Databank by a specific column in a custom project (not in a builder)?
Personally, I am interested in obtaining the 200 strategies with the highest Net profit after applying Monte Carlo and before applying Walk Forward Matrix within a Custom project.
When applying Monte Carlo, I cannot filter the maximum number of strategies in the Databank as I would do with the builder in the Ranking tab, and Filtering does not allow me to do so either.
どうもありがとうございます
<!–a=1–>
0
こんにちは、,
could be done using the Custom Analysis feature. You can check how it works here https://strategyquant.com/doc/programming-for-sq/example-per-databank-custom-analysis/
0
Thanks Thomas
I don’t know how to create it, as I haven’t found any documentation about the Code Editor libraries, just some examples.
I can’t sort the ResultGroup by net profit
<!–a=1–>
0
テオ・ゴットヴァルト
1年前 #288657
To filter a Databank by a specific column in a custom project (not in a builder) and obtain the 200 strategies with the highest Net Profit after applying Monte Carlo and before applying Walk Forward Matrix, you can modify the filterStrategy method in your custom analysis class. This method is called for each strategy in the Databank, and you can use it to filter strategies based on specific criteria.
Here’s how you can modify the filterStrategy method to achieve your goal:
- Filter by Net Profit: You need to access the Net Profit value for each strategy and filter based on that.
- Sort and Limit: After filtering, you can sort the strategies by Net Profit and limit the results to the top 200.
Below is an example of how you can modify the
filterStrategymethod to filter and sort strategies by Net Profit:com.strategyquant.lib.*; をインポートする;import com.strategyquant.tradinglib.*;import com.strategyquant.tradinglib.project.ProjectEngine;import com.strategyquant.tradinglib.results.SpecialValues;import com.strategyquant.tradinglib.results.stats.comparator.OrderComparatorByOpenTime;import java.util.ArrayList;import java.util.Collections;import java.util.Comparator;import java.util.List;public class WFPortfolio extends CustomAnalysisMethod {private List<ResultsGroup> filteredStrategies = new ArrayList<>();public WFPortfolio() {super(“WFPortfolio”, TYPE_PROCESS_DATABANK);}@Overridepublic boolean filterStrategy(String project, String task, String databankName, ResultsGroup rg) throws Exception {// Get the Net Profit value from the strategy’s resultsdouble netProfit = rg.getSpecialValues().getDouble(SpecialValues.NetProfit, 0);// Add the strategy to the filtered list if it meets your criteria// For example, you might want to filter strategies with a Net Profit greater than a certain valueif (netProfit > 0) { // Adjust the condition as neededfilteredStrategies.add(rg);}// Return true to include the strategy in the databank, or false to exclude ittrueを返します。;}@Overridepublic ArrayList<ResultsGroup> processDatabank(String project, String task, String databankName, ArrayList<ResultsGroup> databankRG) throws Exception {// Sort the filtered strategies by Net Profit in descending orderfilteredStrategies.sort((rg1, rg2) -> {double netProfit1 = rg1.getSpecialValues().getDouble(SpecialValues.NetProfit, 0);double netProfit2 = rg2.getSpecialValues().getDouble(SpecialValues.NetProfit, 0);return Double.compare(netProfit2, netProfit1); // Sort in descending order});// Limit the results to the top 200 strategiesint limit = Math.min(200, filteredStrategies.size());List<ResultsGroup> topStrategies = filteredStrategies.subList(0, limit);// Create a new ResultsGroup for the top strategiesResultsGroup portfolioRG = new ResultsGroup(“Top 200 Strategies by Net Profit”);// Add the top strategies to the new ResultsGroupfor (ResultsGroup strategyRG : topStrategies) {portfolioRG.addSubresult(strategyRG.getName(), strategyRG.getSettings(), strategyRG);}// Add the new ResultsGroup to the databankDatabank databank = ProjectEngine.get(project).getDatabanks().get(databankName);databank.add(portfolioRG, true);return databankRG;}// Other methods remain unchanged…
filterStrategy方法:- This method is called for each strategy in the Databank.
- It checks the Net Profit value of each strategy and adds it to the
filteredStrategieslist if it meets the criteria (e.g., Net Profit > 0).
processDatabank方法:- After filtering, the strategies are sorted by Net Profit in descending order.
- The top 200 strategies are selected and added to a new
結果グループ. - The new
結果グループis then added to the Databank.
<h3>注意事項:</h3>
- SpecialValues.NetProfit: This is a placeholder for the actual key used to access the Net Profit value in your ResultsGroup. You may need to adjust this based on the actual key used in your environment.
- Condition: The condition
if (netProfit > 0)is just an example. You can adjust this condition based on your specific filtering criteria. - Sorting: The strategies are sorted by Net Profit in descending order, so the highest Net Profit strategies come first.
This approach allows you to filter and sort strategies based on Net Profit and limit the results to the top 200 strategies, which can then be processed further as needed.
敬具
テオ・ゴットヴァルト
SPRおよびビジュアルオートメーションのトップエキスパート
???? **Q4アップデートの新機能**
1️⃣ Open AI Vision: 最先端の画像認識でSPRを強化。目に見えないものを見る。????????
2️⃣ Open AI TTS: テキストを自然でリアルな音声にシームレスに変換します。違いを聞いてみてください。 ????️????
3️⃣ OpenAIの128kトークンコンテキストウィンドウ搭載GPT-4:AIとの対話で比類なき深みを体験しよう。より深く思考する。????????
4️⃣ OpenAIのDALLE-3:革命的なAIに命令して、息をのむような画像を生成させましょう。想像のその先へ。????️????
5️⃣ ElevenLabs テキスト読み上げ:まるで人間が話しているかのような、リアルな音声合成を体験してください。????️
6️⃣ Automatic1111によるStable Diffusionのローカル&オンライン利用:ローカルとクラウドの両方の画像生成で創造性を解き放ちます。いつでもどこでも作成可能。☁️✨
7️⃣ GPT4All & LM Studio: 強力なオフラインAI機能を活用。あなたのスタジオを、もっと賢く。????️????
8️⃣ DeepL翻訳(SPR統合):リアルタイムで正確な翻訳を実現。世界の言葉を話そう。????????
9️⃣ OpenAIのChatGPT:自然でダイナミックな会話を通じてSPRとエンゲージメントを図りましょう。心からのつながりを築きましょう。 ????️
???? WHISPER by OpenAI: Convert voice to text with effortless precision. Listen, transcribe, act. ????️????
Mistral AI:シームレスな効率性でAI統合をスケール。AIの歩みを次のレベルへ。
AnthropicのClaude 3:次世代のAIの理解力とインタラクティビティを体験してください。人間らしい温かみを持つAIを発見しましょう。
???? **住所:**
ドイツ、デッテンハイム、ヘーレン通り 11
???? **電話:**
オフィス: +49 (7247) 9851112
Mobile: +49 160 6688 222
Fax: +49 (7247) 9851113
???? **メール:**
[[email protected]](mailto:[email protected])
???? **ウェブサイト:**
[IT-Berater](http://www.it-berater.org) | [Smart Package](http://www.smart-package.com)
0
3件の返信を表示中 - 1 - 3件目 (全3件中)