LEAN is the open source
algorithmic trading engine powering QuantConnect. Founded in 2013 LEAN has been built by a
global community of 80+ engineers and powers more than a dozen hedge funds today.
Alpha League Competition: $1,000 Weekly Prize Pool
Qualifying Alpha Streams Reentered Weekly Learn
more
Another way of doing it is to use proportions of opposite stocks, e.g. long SPY long VXX, but this portfolio may fluctuate significantly and is not exactly market-neutral.
How to create a combination of stocks bouncing around 0 and at the same time make sure that I don't overpay for it?
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Adam W
3.8k
,
One way would be to do regularly rebalancing in the Risk Model based on historical beta to the market:
class MyRiskModel(RiskManagementModel):
def Initialize(self, lookback=30):
self.lookback = lookback # Historical lookback period for finding beta
self.betaThreshold = betaThreshold # Some small threshold for market neutrality
def ManageRisk(self, algorithm, targets):
# Currently invested securities
currInvested = [x.Symbol for x in algorithm.Portfolio.Values if x.Invested]
# Compute current beta of portfolio (see Sharpe (1964), statsmodels.OLS, etc)
portfolioBeta = #
portfolioValue = algorithm.Portfolio.TotalHoldingsValue
for symbol in currInvested:
# Compute individual asset betas
# Get portfolio weights by
weight = abs(algorithm.Portfolio[symbol].Quantity) *
algorithm.Securities[symbol].Close /
algorithm.Portfolio.TotalHoldingsValue
# Store beta/weights by symbol in a dict/list/etc
# Constrain asset weights until the expected portfolio beta is 0
return # new constrained weights
Finding the "cheapest" is a bit more tricky and depends on the brokerage. Borrowing costs aren't modeled in yet and can make a big difference for strategies like this depending on the brokerage, but you can look into creating your own borrowing cost model specific to your brokerage.
2
Shile Wen
63.5k
,
Hi Artemiusgreat,
The easiest way to achieve this type of portfolio would be to long and short equal amounts of SPY (SPDR Services SPX) and VOO (Vanguard SPX), respectively. I’ve shown how to do this in the attached backtest.
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Loading...
To unlock posting to the community forums please complete at least 30% of Boot Camp. You can
continue your Boot Camp training progress from the terminal. We
hope to see you in the community soon!