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
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 = (
('period', 50), # Moving average period for AAPL
)
def __init__(self):
# Get 50-day moving average of AAPL
self.aapl_ma = bt.indicators.SimpleMovingAverage(self.datas[0].close, period=self.p.period)
logging.info('50-day SMA for AAPL initialized.')
# Calculate Relative Strength (RS) of AAPL to SPY: (AAPL Close / SPY Close)
self.relative_strength = self.datas[0].close / self.datas[1].close
logging.info('Relative Strength (AAPL/SPY) calculated.')
def next(self):
aapl_close = self.datas[0].close[0]
aapl_ma = self.aapl_ma[0]
rs = self.relative_strength[0] # relative strength
# Check for buy conditions: RS > 0 and AAPL close > 50-day SMA
if rs > 0 and aapl_close > aapl_ma and not self.position:
size = self.broker.get_cash() / aapl_close
self.buy(size=size)
logging.info(f'BUY AAPL: RS > 0 and AAPL Close > 50d MA | Date: {self.datas[0].datetime.date(0)} | Size: {size}')
# Check for sell conditions: RS < 0
elif rs < 0 and self.position:
self.sell(size=self.position.size)
logging.info(f'SELL AAPL: RS < 0 | Date: {self.datas[0].datetime.date(0)} | Size: {self.position.size}')
# Define the lookback period based on the longest indicator params, this must be done to provide a warmup period for indicators
lookback_period = 50 # just use the largest number in params, do not use functions here to define lookback_period
# Fetch and add data. Make sure to add data feeds in the order that they are used in the strategy
aapl_data = bt.feeds.PandasData(dataname=yf.download('AAPL', start_date, end_date), name='AAPL')
spy_data = bt.feeds.PandasData(dataname=yf.download('SPY', start_date, end_date), name='SPY')
cerebro.adddata(aapl_data)
cerebro.adddata(spy_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-3.5 Turbo | ✓ | ✓ | ✓ | ✓ |
GPT-4o Turbo/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 |
Operation | Path | Description | Examples |
---|---|---|---|
Basics | N/A | Append the requested path based on the operation needed followed by the ticker symbol. Replace query parameters like <start> , <end> , <interval> , and <period> as needed. |
Example |
Get Stock Data | /data/{ticker} | Retrieve historical data for a specific stock ticker. Specify the start date, end date, interval, and period as query parameters. | Example |
Get Indicator Data | /indicator/{indicator}/{ticker} | Retrieve historical indicator data for a specific stock ticker. Specify the start date, end date, interval, and period as query parameters. | Example |
Calculate Moving Average | /moving_average/{ticker} | Calculate the moving average for a specific stock ticker. Specify the number of days, start date, end date, interval, and period as query parameters. | Example |
Get Volume Data | /volume/{ticker} | Retrieve the trading volume for a specific stock ticker. Specify the start date, end date, interval, and period as query parameters. | Example |
Calculate Volatility | /volatility/{ticker} | Calculate the volatility for a specific stock ticker. Specify the start date, end date, interval, and period as query parameters. | Example |
Calculate Price Change | /price_change/{ticker} | Calculate the price change for a specific stock ticker. Specify the start date, end date, interval, and period as query parameters. | Example |
Calculate Bollinger Bands | /bollinger_bands/{ticker} | Calculate the Bollinger Bands for a specific stock ticker. Specify the window, start date, end date, and interval as query parameters. | Example |
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