Skip to main content

PyneCore Capital.com Plugin

Capital.com integration for PyneCore: historical and live market data plus live order execution over the public REST v1 + WebSocket API.

Status

Both the data provider (LiveProviderPlugin) and live order execution (BrokerPlugin) are implemented: session-based authentication, historical plus live OHLCV, and position-based order routing with server-side stop-loss / take-profit / trailing stop.

Demo first

Capital.com has a full demo environment (demo-api-capital.backend-capital.com) — run your strategy there before risking funds. Set demo = true and the plugin talks to the demo host; the same API key works on both hosts, and the host you authenticate against decides which account list (demo or live) you see. Note two demo-side differences: fills are effectively deterministic at the requested price (slippage and partial fills are simulated away), and the hourly order-POST rate limit is tighter than on live.

Configuration

Settings live in workdir/config/plugins/capitalcom.toml, auto-generated from CapitalComConfig on first run. One credential block serves both market data and order execution:

demo = false           # demo host vs. live real funds
user_email = ""        # your Capital.com account email
api_key = ""           # API key from Settings -> API integrations
api_password = ""      # the password you set when generating the key

Generating the key: enable two-factor authentication on your account first (Capital.com requires 2FA before API key generation), then create the key under Settings -> API integrations on the platform; the API password is set there as part of key creation. The plugin encrypts the password with the server-provided RSA key at login and keeps the session tokens refreshed proactively.

Capital.com limits POST /session to one request per second per API key. Concurrent broker/provider instances in one process therefore share a keyed bootstrap gate. Session POST starts are spaced by at least one second, and a bootstrap throttle receives one bounded retry. Existing tokens stay visible while a replacement session is created, so an active WebSocket is never sent an empty credential pair.

Symbols

Capital.com identifies instruments by epic (e.g. EURUSD, GOLD) — use the epic directly in the provider string:

capitalcom:EURUSD@1

Pine scripts written with TradingView-style symbols keep working through the optional symbol_map translation table in the config:

[symbol_map]
"FX:EURUSD" = "EURUSD"
"OANDA:XAUUSD" = "GOLD"

Architecture

  • Transport: REST v1 (api-capital.backend-capital.com, or the demo host with demo = true) for account, orders, and history; WebSocket for live quotes and OHLC updates. Execution events are polled from REST (/positions, /workingorders, /history/activity) — Capital.com has no order-event WebSocket channel.
  • Authentication: API key + email + API password. The plugin encrypts the password with the server-provided RSA key and keeps the session tokens refreshed proactively.
  • Order model: position-based (dealId rows) with server-side stop-loss / take-profit / trailing stop as position attributes. One-way (netting) accounts use the direct execution path; hedging-mode accounts run through PyneCore's one-way emulation layer, so Pine one-way semantics hold on both.

Account-mode notes

  • Hedging mode is detected at connect time (GET /accounts/preferences) and handled transparently: closes, reversals, and brackets are decomposed per position row by the core one-way emulator.
  • Partial closes on a hedging account are not supported: DELETE /positions/{dealId} is full-row only (it ignores any size parameter), so a fractional strategy.close(qty=...) becomes a loud, non-halting skip. Use a one-way (netting) account for partial closes — there the plugin emulates them via opposite-direction orders.
  • Deferred trailing activation (Pine trail_price + trail_points) is only available on netting accounts; on a hedging account the trailing stop arms immediately at the given offset (logged as a warning).

License

Apache-2.0. See LICENSE and NOTICE.

Metadata

Release files for pynesys-pynecore-capitalcom 0.9.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pynesys-pynecore-capitalcom 0.9.7
File Size Uploaded Provenance Actions
pynesys_pynecore_capitalcom-0.9.7.tar.gz 475.5 kB With provenance Details for pynesys_pynecore_capitalcom-0.9.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pynesys-pynecore-capitalcom 0.9.7
File Interpreter ABI Platform Actions
pynesys_pynecore_capitalcom-0.9.7-py3-none-any.whl Python 3 none any Details for pynesys_pynecore_capitalcom-0.9.7-py3-none-any.whl

Total release size: 758.5 kB

Release files / pynesys_pynecore_capitalcom-0.9.7.tar.gz

Download URL pynesys_pynecore_capitalcom-0.9.7.tar.gz
Size 475.5 kB
Tags Source
SHA-256 checksum
How to use checksums
0590b7ed5a1ce3b6c0735a115ca17079d4e8fe6fddc5ce12a937108811db3fea
BLAKE2b-256 checksum
How to use checksums
e93fac3241446efb7f894dba90e16a51f228a63a2eef191f0165f238837cb05f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Release files / pynesys_pynecore_capitalcom-0.9.7-py3-none-any.whl

Download URL pynesys_pynecore_capitalcom-0.9.7-py3-none-any.whl
Size 283.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
36a1265cf9598ea2b8ff9f0d6808791fee64308f423bb356e69ca64c1e525095
BLAKE2b-256 checksum
How to use checksums
cf1681e4325bbfadb8ed2f6089c1b34f423f2620936bb18067753de4530365ba
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

Security for pynesys-pynecore-capitalcom 0.9.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for pynesys_pynecore_capitalcom-0.9.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page