Stock 1
Clone Algorithm
3
Backtest from
to
with
initial capital
Cumulative performance:
Algorithm
Benchmark
Custom data:
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns | 1 Month | 3 Month | 6 Month | 12 Month |
Alpha | 1 Month | 3 Month | 6 Month | 12 Month |
Beta | 1 Month | 3 Month | 6 Month | 12 Month |
Sharpe | 1 Month | 3 Month | 6 Month | 12 Month |
Sortino | 1 Month | 3 Month | 6 Month | 12 Month |
Volatility | 1 Month | 3 Month | 6 Month | 12 Month |
Max Drawdown | 1 Month | 3 Month | 6 Month | 12 Month |
""" This algorithm trades once per week by going 100% long in AAPL. For more teaching examples, check out the Quantopian Lecture Series: https://www.quantopian.com/lectures and the Tutorials: https://www.quantopian.com/tutorials Please direct any questions, feedback, or corrections to [email protected] """ import quantopian.algorithm as algo import quantopian.optimize as opt def initialize(context): # Reference to the AAPL security. context.att = sid(351) # Rebalance every day, one hour and a half after market open. algo.schedule_function( rebalance, algo.date_rules.every_day(), algo.time_rules.market_open(hours=1, minutes=30) ) def rebalance(context, data): # Target a 100% long allocation of our portfolio in AAPL. objective = opt.TargetWeights({context.att: 1.0}) # The Optimize API allows you to define portfolio constraints, which can be # useful when you have a more complex objective. In this algorithm, we # don't have any constraints, so we pass an empty list. constraints = [] # order_optimal_portfolio uses `objective` and `constraints` to find the # "best" portfolio weights (as defined by your objective) that meet all of # your constraints. Since our objective is just "target 100% in AAPL", and # we have no constraints, this will maintain 100% of our portfolio in AAPL. algo.order_optimal_portfolio(objective, constraints)