Skip to content

Add SeedInitialPrices and cosmetic changes to C# templates#2384

Open
Ruuudy1 wants to merge 6 commits intoQuantConnect:masterfrom
Ruuudy1:bug-project-templates-cs-rest
Open

Add SeedInitialPrices and cosmetic changes to C# templates#2384
Ruuudy1 wants to merge 6 commits intoQuantConnect:masterfrom
Ruuudy1:bug-project-templates-cs-rest

Conversation

@Ruuudy1
Copy link
Copy Markdown
Contributor

@Ruuudy1 Ruuudy1 commented May 8, 2026

Summary

  • Add Settings.SeedInitialPrices = true; after SetCash in all 44 C# templates (skipped where no SetCash or already present)
  • Cosmetic improvements: comment capitalisation and punctuation, liquidateExistingHoldings: true → positional true, Equity/Equities capitalised where referring to asset class
  • XML doc comments (///) left untouched

Test plan

  • Spot-check a few templates for correct SeedInitialPrices placement and comment style

using QCAlgorithmFrameworkBridge = QuantConnect.Algorithm.QCAlgorithm;
using Calendar = QuantConnect.Data.Consolidators.Calendar;
#endregion
using System.Linq;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

// 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));.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

//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"}.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

// 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,.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

_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));.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

Log(message);
// See https://www.quantconnect.com/docs/v2/writing-algorithms/live-trading/notifications
// for all notification methods
// For all notification methods.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment

// 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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert comment


# 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.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not true given the time_rule

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants