Skip to main content

A Python API wrapper for the Scalable CLI tool

Project description

(Unofficial) Scalable CLI Python API

The Pythonic wrapper for the Scalable Broker CLI.

Built for developers that need commands, structured data models, and a Python API for the Scalable Capital Broker.


Features · Quick start · Common operations · CLI Management


sc-cli-py is a high-level Python wrapper around the Scalable CLI. It provides a state-driven, object-oriented interface to interact with your Scalable Broker account programmatically, replacing raw JSON parsing with Pydantic models.

Why use sc-cli-py

  • Type Safety: Fully typed Pydantic models for holdings, transactions, overview, and search results.
  • Automated CLI Installation: Handles downloading, installing, and updating the underlying CLI binary automatically.

Affiliation

This project is not affiliated with Scalable Capital. It is a personal project. If you are Scalable Capital and want me to take this project down, please open an Issue and I will comply immediately. That said, I'd appreciate it if the community is allowed to build upon the CLI as it is common practice in the tech world.

The wrapper just uses the official Scalable CLI. For more information on the underlying capabilities, refer to the original documentation or the capabilities command.

[!CAUTION] This API has full power over your Scalable Capital account.

  • Do NOT rely on this code for anything but your personal projects.
  • Do NOT use this code unless you understand every line yourself. The code may contain bugs or unexpected behavior.
  • YOU are responsible for all of your actions. (Algorithmic) Trading is risky and I discourage everyone to use this API for anything beyond a hobby project.

Install

pip install sc-cli-py

Quick start

The library uses a stateful approach. You first initialize the API, then log in to get an active Broker session.

from sc_api import ScalableAPI

# 1. Initialize API (handles CLI binary automatically)
api = ScalableAPI()

# 2. Login (Smart flow: checks session, then goes interactive if needed)
broker = api.login()
print(f"Logged in as: {broker.user.first_name} {broker.user.last_name}")

# 3. Access Broker features directly
holdings = broker.get_holdings()
for item in holdings:
    print(f"{item.name}: {item.quantity} units")

[!TIP] Authentication will only work if your Scalable account is approved for CLI use. Read the official Scalable CLI docs to learn more.

Common operations

Portfolio Overview

Get a high-level summary of your portfolio performance and valuation.

overview = broker.get_overview()
print(f"Total Value: {overview.total:,.2f} EUR")
print(f"Securities:  {overview.securities:,.2f} EUR")

Trading

Trading is not yet implemented as it needs more rigorous testing.

Trading is an intentional two-step flow to ensure precision and allow for review.

# Phase 1: Preview (No confirm_id)
# Use isin, and amount (for buy) or shares (for sell)
# preview = broker.trade_buy(isin="ISIN_HERE", amount=100)
# print(f"Status: {preview.status}")

# Phase 2: Confirm (Using confirmation_id from preview)
# if preview.confirmation_id:
#     result = broker.trade_buy(
#         isin="ISIN_HERE", 
#         amount=100, 
#         confirm_id=preview.confirmation_id
#     )
#     print(f"Order Placed! ID: {result.order_id}")

[!CAUTION] It is highly advised that you treat this confirmation workflow as an actual human-in-the-loop approach. Spreads, fees, and other costs do apply and may add unexpectedly to the final cost of the trade. Ensure that all of information is clearly displayed to the account holder before confirmation is given.

Searching Instruments

results = broker.search("Apple")
for security in results:
    print(f"{security.name} ({security.isin}) -> {security.quote_mid_price} {security.quote_currency}")

CLI Management

The library automatically manages the underlying sc CLI binary in a user-specific data directory. If you need manual control:

from sc_api import CLIManager

mgr = CLIManager()
if not mgr.is_installed():
    mgr.download_and_install()

print(f"CLI Path: {mgr.get_bin_path()}")
print(f"CLI Version: {mgr.version}")

Configuration

sc-cli-py respects the same configuration as the Scalable CLI. You can configure backends (keyring, secure enclave) via config.toml.

See CLI Documentation for details on setting up secure storage for sessions and keys.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sc_cli_py-0.1.1.tar.gz (22.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sc_cli_py-0.1.1-py3-none-any.whl (20.2 kB view details)

Uploaded Python 3

File details

Details for the file sc_cli_py-0.1.1.tar.gz.

File metadata

  • Download URL: sc_cli_py-0.1.1.tar.gz
  • Upload date:
  • Size: 22.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for sc_cli_py-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7420c700d5741dd9f145e58c26bf29d4a02793019816a9a3391bfe408ea7df24
MD5 545528bac8f155cdb99f82a5b16277cf
BLAKE2b-256 1633fe0ee608edad35b099127e8b32f944206e8e94944ab5c62d972f39fb1044

See more details on using hashes here.

File details

Details for the file sc_cli_py-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: sc_cli_py-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 20.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for sc_cli_py-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ccca6942a9238685939520d4366a8bc7709dcde2139814496061715e2dbddc1
MD5 60608592b76e198c0c024aefb0516ecd
BLAKE2b-256 e16b40f30ec473297a8372c889356b4c407214c0b53c1e740d84592fc381d9a2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page