Add SeedInitialPrices and cosmetic changes to C# templates#2384
Open
Ruuudy1 wants to merge 6 commits intoQuantConnect:masterfrom
Open
Add SeedInitialPrices and cosmetic changes to C# templates#2384Ruuudy1 wants to merge 6 commits intoQuantConnect:masterfrom
Ruuudy1 wants to merge 6 commits intoQuantConnect:masterfrom
Conversation
DerekMelchin
requested changes
May 8, 2026
| using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm; | ||
| using Calendar = QuantConnect.Data.Consolidators.Calendar; | ||
| #endregion | ||
| using System.Linq; |
Collaborator
There was a problem hiding this comment.
We should keep the default imports
| Settings.SeedInitialPrices = true; | ||
| // Let's select CFD contracts that trade in different market | ||
| // hours so the algorithm is always invested. | ||
| // Let's select CFD contracts that trade in different market. |
| // You can also create a consolidator with a period of one day and start time of 17 | ||
| // var consolidator = new QuoteBarConsolidator(TimeSpan.FromDays(1), TimeSpan.FromHours(17)); | ||
| // You can also create a consolidator with a period of one day and start time of 17. | ||
| // Var consolidator = new QuoteBarConsolidator(TimeSpan.FromDays(1), TimeSpan.FromHours(17));. |
| //Example Line Format: | ||
| //{"high": "441.00", "last": "421.86", "timestamp": "1411606877", "bid": "421.96", "vwap": "428.58", "volume": "14120.40683975", "low": "418.83", "ask": "421.99"} | ||
| // Example Line Format: | ||
| // {"high": "441.00", "last": "421.86", "timestamp": "1411606877", "bid": "421.96", "vwap": "428.58", "volume": "14120.40683975", "low": "418.83", "ask": "421.99"}. |
Collaborator
There was a problem hiding this comment.
drop period at the end
| //Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price | ||
| //2011-09-13 5.8 6.0 5.65 5.97 58.37138238, 346.0973893944 5.929230648356 | ||
| // Example Line Format: | ||
| // Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price. |
| // Trade if the current spread is the lowest bid-ask spread, | ||
| // since it is the most efficient, liquid price with lowest slippage. | ||
|
|
||
| // Trade if the current spread is the lowest bid-ask spread,. |
| _option.SetFilter(u => u.Expiration(0, 0).Strikes(-1, 1)); | ||
| // Filter the option universe by Delta. The last SetFilter call prevails. | ||
| // _option.SetFilter(optionFilterUniverse => optionFilterUniverse.Delta(0.25m, 0.75m)); | ||
| // _option.SetFilter(optionFilterUniverse => optionFilterUniverse.Delta(0.25m, 0.75m));. |
| Log(message); | ||
| // See https://www.quantconnect.com/docs/v2/writing-algorithms/live-trading/notifications | ||
| // for all notification methods | ||
| // For all notification methods. |
| // and place the OCO orders to sell it. | ||
| // Otherwise, we will short 75% of the portfolio value | ||
| // and place OCO orders to rebuy. | ||
| // If the price is above the EMA, we will buy 75% of the portfolio value. |
|
|
||
| # Rebalance shortly after the open so today's intersection is locked in. | ||
| self.schedule.on(self.date_rules.every_day("SPY"), self.time_rules.at(9, 0, 0), self._rebalance) | ||
| # Rebalance shortly after the open. |
Collaborator
There was a problem hiding this comment.
Not true given the time_rule
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Settings.SeedInitialPrices = true;afterSetCashin all 44 C# templates (skipped where noSetCashor already present)liquidateExistingHoldings: true→ positionaltrue,Equity/Equitiescapitalised where referring to asset class///) left untouchedTest plan
SeedInitialPricesplacement and comment style