Hello can someone please show me in C# how to make a basic put shorting algorithim?
Don't have an account? Join QuantConnect Today
QuantConnect Community Discussions
QUANTCONNECT COMMUNITY
LEAN is the open-source algorithmic trading engine powering QuantConnect. Founded in 2012 LEAN has been built by a global community of 180+ engineers and powers more than 300+ hedge funds today.
Join QuantConnect's Discord server for real-time support, where a vibrant community of traders and developers awaits to help you with any of your QuantConnect needs.
The Open-Quant League is a quarterly competition between universities and investment clubs for the best-performing strategy. The previous quarter's code is open-sourced, and competitors must adapt to survive.
Request for sample code in C# for basic put shorting algorithm.
Continue ReadingRefer to our Research Guidelines for high quality research posts.
Create an account on QuantConnect for the latest community delivered to your inbox.
Sign Up Today
|
|
|||||||
|
|
||||||||
|
Shorting Puts Sample Code in C#
Yuanming Yao | July 2020
Hello can someone please show me in C# how to make a basic put shorting algorithim?
QuantConnectâ„¢ 2025. All Rights Reserved
Yuanming Yao
namespace QuantConnect.Algorithm.CSharp { public class VerticalResistanceThrustAssembly : QCAlgorithm { private Symbol spySymbol; public override void Initialize() { SetStartDate(2016, 12, 7); //Set Start Date SetEndDate(2017,1,21); SetCash(1000000); //Set Strategy Cash var spy = AddEquity("SPY", Resolution.Minute); var symbols = new [] {QuantConnect.Symbol.Create("SPY", SecurityType.Equity, Market.USA)}; SetUniverseSelection(new ManualUniverseSelectionModel(symbols)); spy.SetDataNormalizationMode(DataNormalizationMode.Raw); spySymbol = spy.Symbol; var option = AddOption("SPY"); option.SetFilter(-5, 5, TimeSpan.Zero, TimeSpan.FromDays(10)); SetBenchmark(spy.Symbol); } /// OnData event is the primary entry point for your algorithm. Each new data point will be pumped in here. /// Slice object keyed by symbol containing the stock data public override void OnData(Slice data) { if (!Portfolio.Invested) { OptionChain chain; if (data.OptionChains.TryGetValue("SPY", out chain)) { // find the second call strike under market price expiring today var contract = ( from optionContract in chain.OrderByDescending(x => x.Strike) where optionContract.Right == OptionRight.Put where optionContract.Strike < chain.Underlying.Price select optionContract ).FirstOrDefault(); if (contract != null) { SetHoldings(contract.Symbol, -1); } } } } } }
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.
Yuanming Yao
I tried programming it but nothing happens, here is my code.
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.
Artemiusgreat
This discussion is old, but you could take a look here
https://www.quantconnect.com/forum/discussion/3725/optionchainprovider-getoptioncontractlist-example-in-c/p1/comment-11579
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.
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!