Skip to main content

Speculo Studio CLI — backtest your trading strategies locally and sync results.

Project description

Speculo CLI

Run Speculo Studio backtests on your own machine — your hardware, your data, results synced to your Studio history.

Install

pip install speculo

Authenticate

Create a CLI token in Studio → Settings → CLI tokens, then:

speculo login --token spk_xxxxxxxxxxxx
# self-hosted / staging:
speculo login --token spk_xxx --api https://api.staging.speculotrading.com

Credentials are stored in ~/.speculo/config.json (mode 600). You can also set SPECULO_TOKEN / SPECULO_API in the environment.

Backtest

# real historical data (fetched via the platform's cached proxy)
speculo backtest strategy.py --symbol AAPL --timeframe 1d --capital 100000

# your own OHLCV CSV
speculo backtest strategy.py --csv mydata.csv

# synthetic demo series
speculo backtest strategy.py --bars 500

Add --no-sync to keep a run private (compute locally, don't upload).

Strategy contract

A strategy defines on_bar(ctx) and optionally initialize(ctx) — identical to the web editor:

def initialize(ctx):
    ctx.state["fast"], ctx.state["slow"] = 5, 20

def on_bar(ctx):
    c = ctx.closes()
    if len(c) < ctx.state["slow"]:
        return
    fast = sum(c[-ctx.state["fast"]:]) / ctx.state["fast"]
    slow = sum(c[-ctx.state["slow"]:]) / ctx.state["slow"]
    if fast > slow and ctx.position == 0:
        ctx.broker.place_order(symbol=ctx.symbol, quantity=10, side="BUY", order_type="MARKET")
    elif fast < slow and ctx.position > 0:
        ctx.broker.place_order(symbol=ctx.symbol, quantity=10, side="SELL", order_type="MARKET")

The backtest engine itself is fetched from the platform at runtime, so the CLI always runs the exact same engine as the web app.

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

speculo-0.1.0.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

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

speculo-0.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: speculo-0.1.0.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for speculo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9117f0494756abfa4df8965e215495bdaa4efddf8827b71135ed8723b751be25
MD5 5b8922d00af11d5ed3cb2977b720a411
BLAKE2b-256 894887fe6ddefcadb6c770db8e78b7031a184cab9e50c021ccbb2a385ab29a17

See more details on using hashes here.

File details

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

File metadata

  • Download URL: speculo-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.2

File hashes

Hashes for speculo-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 71d71cba4f80c9750534cf93d5a9cddf56912fcc964f8554ab1223edfec45d29
MD5 bb3493c87dbee0f9433df25ea17b77cc
BLAKE2b-256 e360d925d490a15db4a57a685e17cbcd84b6350898e1ea2b6a32d4f0ac613736

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