This directory contains configurations and extensions to enhance the development experience for Blueshift strategies in VS Code, providing code snippets and improved type checking.
The blueshift-code-extension provides useful code snippets for common Blueshift callback functions, accelerating development by reducing boilerplate.
To install this extension:
- Copy the
blueshift-code-extensiondirectory into your VS Code extensions folder (typically~/.vscode/extensions/). - Restart VS Code.
Once installed, you can trigger snippets by typing their prefixes in a Python file. For example, typing def initialize will suggest the initialize function snippet.
Available snippets include:
def initialize: Creates theinitializefunction.def before_trading_start: Creates thebefore_trading_startcallback function.def handle_data: Creates thehandle_datacallback function.def on_data: Creates theon_datacallback function.def on_trade: Creates theon_tradecallback function.def on_stoploss: Creates theon_stoplosscallback function.def on_takeprofit: Creates theon_takeprofitcallback function.def on_update: Creates theon_updatecallback function.
You can also use built-in templates to get you started. Start typing template and click the suggestions.
Available templates are:
sma crossover: A modular technical indicator based strategy with periodic signal check.intraday option: A simple option selling strategy highlighiting realtime response, option symbology, and stoploss use.large universe (pipeline): A ersion of time-series momentum strategy demonstrating the advanced pipeline APIs for handling large universe.
The pyrightconfig.json file provides configuration for Pyright, a static type checker for Python. This configuration helps suppress some errors in vs code/ pylance case you are developing Blueshift strategies with only the stub package for type hints and do not have the full package installed.
To use this configuration:
- Copy the
pyrightconfig.jsonfile to the root of your Blueshift strategy development workspace. - Ensure you have the official Python extension installed in VS Code.
With pyrightconfig.json in your workspace root, Pyright will automatically pick up the configuration, which includes:
"extraPaths": ".": Adds the current directory to the paths Pyright searches for modules."reportMissingModuleSource": false: Suppresses errors for missing module sources."reportAttributeAccessIssue": false: Suppresses errors for attribute access issues."reportWildcardImportFromLibrary":false: Suppresses errors for wildcard imports from libraries.
These settings are tailored to work well with the blueshift-stubs package, ensuring that type hints and autocompletion function correctly without unnecessary warnings or errors.