FinLab Command-Line Interface (CLI)
The current FinLab CLI is available through python -m finlab. It supports account login, credential export, session status, legacy token migration, and cloud strategy deployment and scheduling.
Still in testing
This feature is currently in alpha and may be buggy or unstable. Use with care. For any issues, please file a report on Discord and we will fix it as soon as possible.
Quick Setup
Install or update FinLab:
Log in to your FinLab account:
Check your login status:
Auth And Credentials
Login
Open a browser login flow and save credentials locally.
Logout
Clear local credentials and try to remove the server-side session.
Status
Show the current local session, whether the API key is configured, the plan name, and active server-side sessions.
Export Credentials
Export the current login credentials for headless or cloud environments.
Output shell export commands:
Migrate Legacy Token
Show guidance for migrating from the legacy FINLAB_API_TOKEN flow to the current login system.
Cloud Strategy Updates
Use the FinLab CLI to deploy strategies to the cloud, schedule daily runs, trigger manual runs, inspect execution logs, and review monthly usage.
Before You Start
Log in to your FinLab account:
Cloud strategy code runs in an isolated container with the FinLab SDK pre-installed. Strategy IDs must start with a letter or number, contain only letters, numbers, ., _, and -, and be at most 64 characters. Schedule times use HH:MM in the Asia/Taipei timezone.
Plans, Quotas, And Tiers
Cloud strategy execution limits available tiers and strategy count by plan. Use python -m finlab cloud status to view the current account's allowed tiers and execution count for the month.
Plan Limits
| Plan | Strategy limit | Default tier | Available tiers |
|---|---|---|---|
| Free | 0 | None | None |
| VIP | 3 | s |
s |
| AI | 5 | m |
m, l |
| AI MAX | 10 | s |
s, m, l, xl |
When --tier is omitted, a new strategy uses the account plan's default tier. Updating an existing strategy keeps its current tier when it already has one. Free users cannot deploy cloud strategies.
Tier Specs
| Tier | CPU | Memory | Timeout | Concurrency |
|---|---|---|---|---|
s |
1 | 2 GiB | 120 sec | 30 |
m |
2 | 4 GiB | 180 sec | 1 |
l |
4 | 16 GiB | 300 sec | 1 |
xl |
8 | 32 GiB | 600 sec | 1 |
List Strategies
List cloud strategies for the logged-in account:
List up to 500 strategies:
Inspect A Strategy
Fetch metadata for one strategy. Inline strategies include source code. Zip strategies show metadata and the entry script only, because source files are stored in cloud storage.
Print only inline strategy source code, which is useful when redirecting output to a file or piping it to another tool:
Deploy A Strategy
You can deploy a single Python file or a zip archive for multi-file strategies.
Deploy a single Python file:
Deploy and set a daily run time:
Deploy and opt into the contest:
python -m finlab cloud deploy my-strategy --code strategy.py --time 09:30 --contest --contest-alias TeamA
Deploy a multi-file strategy:
Use exactly one of --code and --zip. Inline source code is limited to 256 KiB. Zip uploads are limited to 5 MiB compressed, 50 MiB extracted, and 100 files.
Options:
| Name | Description | Default |
|---|---|---|
--code |
Single Python strategy file to deploy. | None |
--zip |
Zip archive to deploy for a multi-file strategy. | None |
--entry-script |
Python entry script inside the zip, for example main.py. Required with --zip. |
None |
--time |
Daily schedule time in HH:MM. Omit to keep an existing schedule unchanged. |
None |
--tier |
Compute tier: s, m, l, or xl, subject to plan access. |
Account default |
--contest |
Opt this strategy into the contest. Only scheduled executions count. | None |
--no-contest |
Withdraw this strategy from the contest. Rejoining after withdrawal is not supported by the backend. | None |
--contest-alias |
Public leaderboard alias, up to 64 characters. | None |
Contest strategies must upload a backtest report during scheduled execution, for example with sim(..., upload=True). Manual cloud run executions do not count toward contest results.
Run Manually
Trigger one execution immediately. The strategy must already be deployed. Manual triggers are rate-limited to 5 runs per strategy per hour.
Override the compute tier for this manual run only:
View Execution Logs
Show recent execution records for a strategy, including status, duration, and cost. Status values include queued, running, success, error, timeout, and quota_exceeded.
Limit the number of records and show stored stdout, stderr, and error messages:
Schedule Daily Runs
Set a daily run time:
Remove the daily schedule:
Check Monthly Quota
Show current cloud execution usage, allowed tiers, and execution counts:
Query a specific month:
Delete A Strategy
Delete a strategy, metadata, code, and schedule. Execution history is preserved.
Skip the deletion confirmation prompt: