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
# Setup logging configuration
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# Define your strategy for trading leveraged ETFs
class ExampleStrategy(bt.Strategy):
params = (
('short_period', 10), # Short period for the moving average
('long_period', 30), # Long period for the moving average
)
def __init__(self):
# Initialize short and long moving averages for leveraged ETFs
self.short_ma = bt.indicators.SimpleMovingAverage(self.datas[0].close, period=self.p.short_period)
self.long_ma = bt.indicators.SimpleMovingAverage(self.datas[0].close, period=self.p.long_period)
logging.info('Short and Long MAs for Leveraged ETF initialized.')
def next(self):
short_ma = self.short_ma[0]
long_ma = self.long_ma[0]
close_price = self.datas[0].close[0]
# Log current cash and portfolio value for better trade visibility
cash = self.broker.get_cash()
value = self.broker.get_value()
# Buy/Sell signals based on moving averages.
if short_ma > long_ma and not self.position:
size = int(cash / close_price) # Calculate size
self.buy(size=size)
logging.info(f'BUY Signal: Short MA > Long MA | Date: {self.datas[0].datetime.date(0)} | Size: {size} | Portfolio Value: {value}')
elif short_ma < long_ma and self.position:
self.sell(size=self.position.size)
logging.info(f'SELL Signal: Short MA < Long MA | Date: {self.datas[0].datetime.date(0)} | Size: {self.position.size} | Portfolio Value: {value}')
# Define the lookback period based on the longest indicator params
lookback_period = 30 # Using the largest number in params as lookback period
# Fetch and add data for leveraged ETFs (e.g., UPRO - a 3x leveraged S&P 500 ETF)
leveraged_etf_data = bt.feeds.PandasData(dataname=yf.download('UPRO', start_date, end_date), name='UPRO')
cerebro.adddata(leveraged_etf_data)
globals()['lookback_period'] = lookback_period # Update global variable for lookback period usage
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