Skip to main content

brandzivio-trade-costs

Tiny, dependency-free helpers for backtests and paper trading:

  • slippage(expected_price, fill_price, side) per-unit slippage (positive = worse than expected)
  • slippage_bps(expected_price, fill_price, side) the same in basis points
  • net_pnl(entry, exit, qty, side, slippage_bps_per_leg, brokerage_per_order, charges_pct) round-trip P&L after costs
from brandzivio_trade_costs import slippage_bps, net_pnl

slippage_bps(200, 200.2, "buy")                       # 10.0 bps
net_pnl(100, 110, 10, slippage_bps_per_leg=5,
        brokerage_per_order=20, charges_pct=0.05)     # net of slippage, brokerage and charges

What it deliberately does not do

  • It has no built-in tax or exchange charge rates. Statutory rates change, so pass charges_pct from your own broker's current charge sheet.
  • It does not model market impact, partial fills or queue position.
  • A backtest result describes the past and is not a promise of future returns.

Where it fits

Slippage, brokerage and charges are the fill-model inputs of a backtester: see Algo Trading Software Architecture for how the backtester, paper trading and order layer fit together. Source: algo-trading-platform-architecture.

By Brandzivio. MIT licensed.

Metadata

Release files for brandzivio-trade-costs 0.1.0

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

Source distribution (sdist)

Source distribution for brandzivio-trade-costs 0.1.0
File Size Uploaded Provenance Actions
brandzivio_trade_costs-0.1.0.tar.gz 4.1 kB Without provenance Details for brandzivio_trade_costs-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for brandzivio-trade-costs 0.1.0
File Interpreter ABI Platform Actions
brandzivio_trade_costs-0.1.0-py3-none-any.whl Python 3 none any Details for brandzivio_trade_costs-0.1.0-py3-none-any.whl

Total release size: 8.5 kB

Release files / brandzivio_trade_costs-0.1.0.tar.gz

Download URL brandzivio_trade_costs-0.1.0.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
9a4ec9e5d9aa9735e1289ecddf50891369120a2595f0692a8800d1c9fe97a324
BLAKE2b-256 checksum
How to use checksums
5861736f86a9bad4743fbc8eea97b7ae55500787571ae1508b483184b47daeeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / brandzivio_trade_costs-0.1.0-py3-none-any.whl

Download URL brandzivio_trade_costs-0.1.0-py3-none-any.whl
Size 4.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
23ba8a5b7f20350f8fa9956d481f1adbd55548efb500c826f5286bb90e250ff6
BLAKE2b-256 checksum
How to use checksums
5b6a7f9b759bc33055facdc66deb2d0185bb1a356caf1ab8576339db5669d72b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for brandzivio-trade-costs 0.1.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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