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 (not available on PyPi yet)

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 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.0.tar.gz (17.1 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.0-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sc_cli_py-0.1.0.tar.gz
  • Upload date:
  • Size: 17.1 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.0.tar.gz
Algorithm Hash digest
SHA256 c52fb23013051e9b2fa8b3314ecdffc60c4a6e72c4b4213a68e28ca300f7c13f
MD5 2357ae3dcbdbaeebd6c5d27d631211ba
BLAKE2b-256 b5659d70a5425c542f654de9fb9e06bc39a472774ef7c6bc4f0c04c9b9cf6b1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sc_cli_py-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 16.3 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e085d8fbf6fe7db1dd80978d20f43f9b0cd2cbdcc1ea012fb2f144e0af77940
MD5 acd8dcefd71ed1db81f92f312f127541
BLAKE2b-256 8eb3ba60f2369ff7cad6f7ccc1835cd9258a8634092231f4ec458c665cc907e6

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