Add seed_initial_prices and cosmetic changes to Python templates#2383
Open
Ruuudy1 wants to merge 9 commits intoQuantConnect:masterfrom
Open
Add seed_initial_prices and cosmetic changes to Python templates#2383Ruuudy1 wants to merge 9 commits intoQuantConnect:masterfrom
Ruuudy1 wants to merge 9 commits intoQuantConnect:masterfrom
Conversation
This reverts commit 7daa8e2.
DerekMelchin
requested changes
May 8, 2026
| # Seed the price of each asset with its last known price to | ||
| # avoid trading errors. | ||
| # Seed the price of each asset with its last known price to | ||
| # Avoid trading errors. |
Collaborator
There was a problem hiding this comment.
"Avoid" shouldn't be capitalized here
| # Set scheduled events to hold each CFD contract during | ||
| # their regular trading hours. | ||
| # Set scheduled events to hold each CFD contract during. | ||
| # Their regular trading hours. |
| # You can also create a consolidator with a period of one day and start time of 17 | ||
| # consolidator = QuoteBarConsolidator(timedelta(1), timedelta(hours=17)) | ||
| # You can also create a consolidator with a period of one day and start time of 17. | ||
| # Consolidator = QuoteBarConsolidator(timedelta(1), timedelta(hours=17)). |
Collaborator
There was a problem hiding this comment.
This line edit is incorrect. Keep the original comment
| if is_live_mode: | ||
| # 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"} | ||
| # {"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.
Shouldn't have a period at the end
| # Example Line Format: | ||
| # 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 | ||
| # Date Open High Low Close Volume (BTC) Volume (Currency) Weighted Price. |
Collaborator
There was a problem hiding this comment.
Remove periods at the end of these comments
|
|
||
| # 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,. |
| self._option.set_filter(lambda u: u.expiration(0, 0).strikes(-1, 1)) | ||
| # Filter the Option universe by Delta. The last set_filter call prevails. | ||
| # self._option.set_filter(lambda u: u.delta(0.25, 0.75)) | ||
| # Self._option.set_filter(lambda u: u.delta(0.25, 0.75)). |
| def on_data(self, slice: Slice) -> None: | ||
| # Since we are trading 0DTE, they will expire on end of day. | ||
| # So we don't need to remove them explicitly. |
| self.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. |
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
self.settings.seed_initial_prices = Trueafterset_cashin all 44 Python templates (skipped where noset_cashor already present)100000→100_000),on_dataparameter rename (slice→data),liquidate_existing_holdings=True→ positionalTrue,time_rules.attrailing zero removed,schedule.on/trainexpanded to multi-line,and/oroperators moved to end of lineEquity/Equitiescapitalised in comments where referring to the asset classTest plan
python project-templates/python/run_syntax_check.py— expect 100% passseed_initial_pricesplacement and comment style