(Quant Trading Question!) Using RD-Agent to find and optimize profitable strategies?
(Quant Trading Question!) Using RD-Agent to find and optimize profitable strategies?
I wonder if you have any examples, or if no examples yet, can clarify if you think this api is READY for this type of program or close to it.
- You have a python backtesting library (ex. Freqtrade, Backtrader)
- You use RD-Agent to create new strategies (and or optimize/finetune)
- It can go back-and-forth running backtest, getting back statistics, then planning, "Researching" and "developing" updated strategy.
This is much better approach then deep-learning because formula-based strategies outperform on new-data than deep-learning! I believe this will be a new approach to birthing trading strategies. Will definitely be popular if you then just translate/sell to MT5 store or use yourself on prop firms etc.
Hi,
Thank you for your interest! You can refer to the demo link on our project's homepage, which showcases examples of RD-Agent in the financial domain. Our RD-Agent can generate new factors and models, and we've integrated with Qlib for seamless backtesting in financial scenarios.
@TPLin22 I watched the video "RD-Agent, let AI Drive AI:Quant Factory, Fully automate the time-consuming feature engineering work" .
This does 95% of what I want. However this is unpractical for quant trading, nobody trades "features", they use "strategies".
Do you know if it is EASY from here on to use RD-Agent to write trading-strategies instead of factors? Swapping out Qlib for some other backtesting framework like "Freqtrade", "VectorBT" or "Backtrader"?
I am unfamiliar with Qlib, if I am missing out on its possibilities, I did not find it very useful from its github repo or practical.
Wonderful project by the way, I love it!!!!!!!!!!!!! #1 fan!
example of what i mean by a strategy:
from freqtrade.strategy import IStrategy
from pandas import DataFrame
class SuperSimpleStrategy(IStrategy):
INTERFACE_VERSION = 3
timeframe = '1h'
# ๐ฐ Aim for 2% profit, cut losses at 1%
minimal_roi = {"0": 0.02}
stoploss = -0.01
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# ๐ Calculate 5-period SMA
dataframe['sma'] = dataframe['close'].rolling(window=5).mean()
return dataframe
def populate_entry_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# ๐ Buy when price > SMA
dataframe.loc[dataframe['close'] > dataframe['sma'], 'enter_long'] = 1
return dataframe
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# ๐ Sell when price < SMA
dataframe.loc[dataframe['close'] < dataframe['sma'], 'exit_long'] = 1
return dataframe
# ๐งช Usage:
# 1. Save as `super_simple_strategy.py` in `user_data/strategies/`
# 2. Run: freqtrade backtesting --strategy SuperSimpleStrategy
# 3. Optimize: freqtrade hyperopt --strategy SuperSimpleStrategy -e 100
Exciting idea! From my perspective, a suitable way is to build a new scenario (like qlib) where you could try connecting the backtesting parts with the R&D sections. Check out the "runner" step in the R&D loop, where you could use a Docker to encapsulate relevant environment and conduct backtesting. Currently, apart from the quant factors demo that you referred, we also explored the automation of optimising machine learning models. A combination of these two sound to me like what you are referring to. Good luck : )
Hello Keithorange,
Currently in the Qlib scenario, the tuning of factors and models is relatively separate. You can connect the two by modifying parts of the framework code. Meanwhile, Qlib's backtesting framework corresponds to real-world feedback as demonstrated. We currently encapsulate it in Docker to make it easier for you to use and switch. Of course, you can change it to another framework that better suits your needs. We also welcome you to do so and contribute to the open-source community.
If you have any technical needs, please feel free to let us know.
@Xisen-Wang @WinstonLiyt Awesome! Thanks for building this great idea and out of a LOT of ai projects, THIS one has HUGE implications. Imagine in a few years when you have access to free, near infinite LLM access, and you can parallelize across a MILLION agents some research. Like for medicine this can cure diseases! For finance it will MINE trading strategies! Awesome !!!!
Hi @keithorange,
To contribute to this discussion, I recommend reading the Qlib original paper. As you'll see, Qlib was designed specifically for strategy researchers, portfolio implementation researchers, and traders. It covers the entire process, from data onboarding and storage to model training, backtesting, portfolio metrics, risk, and execution assessment. In contrast, backtrader focuses more on execution simulation and portfolio analytics.
Iโve developed extensive proprietary code (which, unfortunately, I cannot open-source) on top of backtrader to address institutional issues affecting strategy trade-offs, such as fund leverage, passive NAV flows, and margin control. I can attest to the package's reliability and well-thought-out architecture. However, I don't believe it makes sense to run both under RD-Agent. In short, Qlib and backtrader (and its siblings) are not complementary. Since Qlib has a more full-stack approach and was built for the modern AI-driven quant researcher, I suggest focusing on integrating the features we like from backtrader that are missing in Qlib.
Lastly, regarding your thoughts on the traditional quant research approach: having worked as a quant researcher and trader in the hedge fund industry for the past seven years, I agree that the "formula-based" method has long been preferred. However, times are changing. I've seen impressive out-of-sample performance from new transformer-based neural network architectures, which could potentially outshine traditional models. I have a full library of articles covering that here. Happy to answer any further questions through the Discord chat.
Best regards