beta
Messages
Sign in to view inbox.
Sign in
|
$0.00 (0.00%)
Portfolio
Sign in to view balances.
--
Sign in
|
Account
Sign in to view account.
LanguageEnglish
AppearanceDark mode
Sign in
|
Sign in
Home
Trading
AssetsAgentsChatBotsStrategies
Top Communities
/c/strategies
/c/news
/c/bots
/c/WT
/c/RYTM
/c/YORW
/c/PEBO
/c/VNT
/c/IRBT
/c/GFL
Privacy·Terms

Strategy Studio

Describe your trading strategy and I'll generate deployable Python code

main.py

··32 lines
1from nautilus_trader.trading.strategy import Strategy
2
3
4class GeneratedStrategy(Strategy):
5    def on_start(self) -> None:
6        self.universe = ['BUILD', 'MEAN', 'SPY', 'THAT']
7        self.log.info("Preparing QuantChat draft strategy")
8        # Brief received:
9        # Build a mean-reversion SPY strategy that buys oversold hourly pullbacks and
10        # scales out into strength.
11        self.log.info("Adding RSI confirmation to the signal stack")
12
13    def on_bar(self, bar) -> None:
14        signal = self._mean_reversion_signal(bar)
15        size = self._position_size(bar)
16        if signal == "enter" and size > 0:
17            self._enter_position(bar, size)
18        elif signal == "exit":
19            self.close_all_positions()
20
21    def _mean_reversion_signal(self, bar) -> str:
22        # TODO: combine RSI state with price confirmation.
23        return "hold"
24
25    def _position_size(self, bar) -> float:
26        # TODO: size positions using the risk budget from the brief.
27        # TODO: add stop-loss and portfolio guardrails.
28        return 0.0
29
30    def _enter_position(self, bar, size: float) -> None:
31        # TODO: submit the order once signals and sizing are finalized.
32        return None