Backtest and deploy algorithmic strategies with AI.
This app is currently in Alpha and we are actively squashing bugs, thanks for your patience!
Register for free to access more AI models.
ideas remaining
Annual Return Average Loss Average Win Calmar Ratio Maximum Drawdown Profit Factor Sharpe Ratio Win Rate 21.33% $570.43 $1021.02 0.0048 44.33% 1.44 0.62 44.62%
Backtested historical performance does not necessarily represent future performance.
# Setup logging configuration
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Define your strategy
class ExampleStrategy(bt.Strategy): # You must leave this name ExampleStrategy the same or the strategy will not run, you can take out this comment in your generated code
# implement new params based on user specification
params = (
('short_period', 12), # Short term EMA period
('long_period', 26), # Long term EMA period
)
def __init__(self):
# Initialize EMA indicators with dynamic periods based on strategy parameters
self.short_ema = bt.indicators.EMA(self.datas[0], period=self.params.short_period)
self.long_ema = bt.indicators.EMA(self.datas[0], period=self.params.long_period)
self.ema_diff = self.short_ema - self.long_ema
self.prev_ema_diff = self.ema_diff(-1)
logging.info(f'EMA Indicators Initialized: Short={self.params.short_period}, Long={self.params.long_period}')
def next(self):
# Calculate the current and previous EMA differences
curr_ema_diff = self.ema_diff[0]
prev_ema_diff = self.prev_ema_diff[0]
# Log for tracking
logging.info(f'Date: {self.datas[0].datetime.date(0)}, Current EMA Diff: {curr_ema_diff}, Previous EMA Diff: {prev_ema_diff}')
# Check for buy signal
if curr_ema_diff > prev_ema_diff and not self.getposition(self.datas[0]).size:
size = int(self.broker.get_cash() / self.datas[0].close[0]) # Calculate size based on current cash
self.buy(size=size) # Execute buy order
logging.info(f'BUY ORDER PLACED on {self.datas[0].datetime.date(0)}, Size: {size}, EMA Diff: {curr_ema_diff}, Cash: {self.broker.get_cash()}')
# Check for sell signal
elif curr_ema_diff < prev_ema_diff and self.getposition(self.datas[0]).size:
self.sell(size=self.position.size) # Execute sell order using current position size
logging.info(f'SELL ORDER PLACED on {self.datas[0].datetime.date(0)}, Size: {self.position.size}, EMA Diff: {curr_ema_diff}, Cash: {self.broker.get_cash()}')
# Adjust start and end dates for data fetching to account for the lookback period
lookback_period = max(26, 12) # The largest period used in EMA calculation
adjusted_start_date = (start_date - pd.Timedelta(days=lookback_period)).strftime('%Y-%m-%d')
extended_end_date = (end_date + pd.Timedelta(days=lookback_period)).strftime('%Y-%m-%d')
# Fetch and add data to Cerebro
# Note: Adjust the stock ticker to TQQQ as specified by the user
leveraged_etf_data = bt.feeds.PandasData(dataname=yf.download('TQQQ', start=adjusted_start_date, end=extended_end_date), name='TQQQ')
cerebro.adddata(leveraged_etf_data)
globals()['lookback_period'] = lookback_period # Update global variable for lookback period usage
You need to connect a brokerage account to deploy strategies.
Select a broker to connect:
You are not following any algorithms yet.
You have not invested in any algorithms yet.
Test Pass | Quant Pass | Trade Pass | Enterprise | |
---|---|---|---|---|
Test trading strategies without code | ✓ | ✓ | ✓ | ✓ |
Test stocks/futures/cryptocurrency/forex strategies | ✓ | ✓ | ✓ | ✓ |
GPT-4o and mini models | ✓ | ✓ | ✓ | ✓ |
Fine tuned/thinking/proprietary Models | ✓ | ✓ | ✓ | |
Dedicated API keys | ✓ | |||
Fine tuned models for your organization's tech stack | ✓ | |||
Ideas per Month | 3 | ?? | ??? | Unlimited |
Basic analytics | ✓ | ✓ | ✓ | ✓ |
Detailed analytics | ✓ | ✓ | ✓ | |
Test options strategies* | ✓ | ✓ | ✓ | |
Minute resolution data* | ✓ | ✓ | ✓ | |
Save strategies* | ✓ | ✓ | ✓ | |
Iterative strategy updates with AI assistant* | ✓ | ✓ | ||
Deploy strategy with exchange* | ✓ | ✓ | ||
View code structure | ✓ | ✓ | ||
Fees | Free | $TBA | $TBA | $TBA |
* = Features on roadmap |
By using this app, you agree to: https://www.statisfund.com/legal - This app is built and managed by Statis Fund LLC - for questions and support email shawn@statisfund.com