Use the SDK as the authoring contract
The public investfly-sdk package provides typed strategy, market-data, portfolio, order, and indicator models plus an interactive CLI. Your code declares its universe, callbacks, configuration, and requested orders; Investfly supplies the supported hosted runtime and account services.
Start with the current Investfly Python API documentation. It is generated from the SDK and is the source for current signatures, models, command examples, and package requirements.
1. Install the SDK and copy samples
- Install Python 3.11 or later and create a virtual environment for the project.
- Install the current
investfly-sdkpackage. - Start
investfly-cli, review its help, and usecopysamplesto create a local sample directory. - Open the copied strategies in your IDE and trace the SDK types before changing the logic.
The SDK quickstart contains the exact current commands.
2. Define a strategy class
Subclass the SDK TradingStrategy interface. Define the security universe and add a market-data callback, one or more scheduled callbacks, or both. Read market and portfolio state through the injected services, and return only the orders your logic requests.
Keep each decision explicit: instruments, trigger timing, direction, size, order behavior, exits, and state. Hosted code runs inside a restricted environment with supported imports and runtime limits; do not assume an arbitrary package, network call, filesystem path, or unrestricted process is available.
3. Validate locally
- Type-check the strategy and copied examples with the current command from the SDK quickstart.
- Exercise small pure calculations locally where possible.
- Confirm callback names, decorators, return types, symbols, intervals, schedules, and SDK imports.
- Remove embedded passwords, tokens, private keys, and environment-specific file paths before upload.
A successful local import or type check validates the authoring surface; it does not reproduce hosted market data, account state, order validation, or fills.
4. Upload and inspect the saved strategy
Sign in through investfly-cli and use the current strategy create or update command with the Python file. The CLI uses the strategy class name as the Investfly strategy name. Then open Strategies in the web application and inspect the uploaded code and saved definition before testing it.
When you update the file, upload the new version and repeat the relevant backtest and deployment checks. Do not assume an existing deployment automatically represents the behavior you intended after an edit.
5. Backtest and run in simulation
Use the strategy Backtest tab to replay the uploaded code against available historical data. Inspect the trade list, portfolio path, warnings, and multiple periods using How to Backtest a Trading Strategy.
Next, deploy to a compatible Investfly virtual portfolio and observe current callbacks, orders, positions, schedules, and errors with simulated funds. Backtests and paper trading have different timing and fill assumptions, and neither predicts live results.
6. Authorize an eligible account only when ready
For live use, connect an eligible provider account, choose it from the strategy Deployment tab, review compatibility and live-trading terms, then authorize deployment yourself. Supported instruments, data, packages, account features, permissions, jurisdiction, and provider behavior determine what can run.
See the Python algorithmic trading platform page for supported product capabilities and the trading bot management guide for ongoing monitoring.