Skip to main content

Financial markets ORM, engines, and application management extensions for Main Sequence.

Project description

MainSequence Markets

MainSequence Markets

Docs License Python Package Open Issues Last Commit Maintained

ms-markets is the financial markets extension layer for the Main Sequence platform. It provides reusable market-domain ORM models, market DataNodes, portfolio construction utilities, repository operations, and application-facing helpers for building financial systems on top of Main Sequence. Portfolio and QuantLib-backed pricing capabilities are packaged as separate import surfaces so core msm stays focused on shared markets primitives.

The Python distribution is named ms-markets. The core import package is intentionally short:

import msm

Portfolio workflows import from msm_portfolios. Optional QuantLib-backed pricing imports from msm_pricing.

Project Status

The initial core package was migrated from mainsequence-sdk/mainsequence/markets into this repository under src/msm. Architecture and implementation decisions are tracked in Architecture Decision Records.

What This Repository Contains

Main package areas:

  • msm.api.accounts: account identity and account target assignment row APIs
  • msm.api.calendars: calendar identity, date, session, and event row APIs
  • msm.api: user-facing Pydantic row objects and typed class methods for markets MetaTable records
  • msm.constants: static built-in keys such as asset type constants used across applications and examples
  • msm.client: client-facing Main Sequence market models and API wrappers
  • msm.data_nodes: market DataNode contracts, including account holdings, execution events, asset snapshots, and asset pricing details
  • msm.api.execution: order managers, target quantities, orders, events, trades, and execution error row APIs
  • msm.models: SQLAlchemy market-domain *Table declarations and MetaTable registration order
  • msm_portfolios: portfolio configuration, signal weights, rebalance strategies, virtual funds, and portfolio construction workflows
  • msm_pricing: optional QuantLib-backed instruments, curves, fixings, pricing helpers, and pure-data analytics installed with pricing or analytics extras
  • msm.repositories: compiled persistence operations over market-domain models
  • msm.services: application-level orchestration over repositories, including asset lookup and OpenFIGI service helpers
  • msm CLI: package maintenance helpers such as explicit agent-skill copying and SDK-managed MetaTable migration commands

Repository areas:

  • docs/: MkDocs documentation, tutorials, knowledge guides, ADRs, and API reference scaffold
  • examples/msm/: core assets, accounts, calendars, derived indexes, platform, and row-workflow examples
  • examples/msm_portfolios/: single portfolio construction example with index linkage and canonical portfolio DataNodes
  • examples/msm_pricing/: optional pricing and QuantLib-backed examples
  • .agents/skills/ms_markets/: source agent skills for market-domain workflows
  • tests/: automated tests

Documentation Map

The documentation is organized into four reading modes:

  1. Tutorial: guided learning material
  2. Knowledge: concept-oriented guides for each msm package area
  3. Architecture: ADRs that record implementation decisions
  4. Reference: generated API reference scaffold

Recommended entry points:

Quick Start

Install the package from this repository in editable mode:

python -m pip install -e ".[dev]"

Or with uv:

uv sync --extra dev

Install pricing support only when needed:

uv sync --extra pricing

Install the named analytics surface when working with optional spread analytics:

uv sync --extra analytics

Install portfolio workflow support only when needed:

uv sync --extra portfolios

Install the project-level FastAPI surface only when needed:

uv sync --extra public_api

Verify the core import:

python -c "import msm; print(msm.__version__)"

After installing the pricing extra, verify the optional pricing import:

python -c "import msm_pricing; print(msm_pricing.FixedRateBond)"

Copy the packaged ms-markets skills into a host Main Sequence project only when you explicitly want them available to agents in that project:

msm copy-msm-skills --path /path/to/project

Importing msm never mutates the current directory or auto-copies skills. The command writes only to <project>/.agents/skills/ms_markets/ and leaves unrelated .agents content alone. Use --dry-run or --json to inspect the copy plan.

Common Development Commands

Run tests:

pytest

Run focused linting for optional pricing:

ruff check src/msm_pricing

Serve the docs locally:

mkdocs serve

Build the docs:

mkdocs build --strict

Build the package:

uv build

Publish a tagged release to PyPI:

git tag v0.0.2
git push origin v0.0.2

Pushing a v* tag triggers .github/workflows/publish-to-pypi.yml, which builds the distribution and publishes it to PyPI through GitHub Actions using trusted publishing for the repository pypi environment.

Core Dependencies

Runtime dependencies are declared in pyproject.toml. The core stack starts with:

  • mainsequence for platform integration
  • SQLAlchemy for market-domain ORM models
  • pydantic for typed configuration and serialized row contracts
  • pandas and numpy for tabular market data

Optional extras provide analytics, documentation, development, portfolio, public API, and pricing tooling. The analytics and pricing-analytics extras reserve the dependency boundary for optional analytics helpers; the current spread helpers use the core numpy and pandas dependencies. The portfolios extra installs portfolio-only helpers such as pandas-market-calendars. The public_api extra installs FastAPI and Uvicorn for the project-level apps/v1 surface. The pricing extra installs QuantLib and the optional pricing runtime exposed as msm_pricing.

Package Metadata

Project metadata is defined in pyproject.toml.

License

This project is open source under the Apache License 2.0.

Project details


Release history Release notifications | RSS feed

Download files

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

Source Distribution

ms_markets-0.0.97.tar.gz (2.2 MB view details)

Uploaded Source

Built Distribution

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

ms_markets-0.0.97-py3-none-any.whl (650.8 kB view details)

Uploaded Python 3

File details

Details for the file ms_markets-0.0.97.tar.gz.

File metadata

  • Download URL: ms_markets-0.0.97.tar.gz
  • Upload date:
  • Size: 2.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ms_markets-0.0.97.tar.gz
Algorithm Hash digest
SHA256 aa36930809f06eb0d1d724189b6fc05df95f35e2edfb758484db31d9102c303a
MD5 0b4d53c9517a00c5351c1259c83960f7
BLAKE2b-256 33913179325b498e409eab2743082ffaeaad8768aa33a6916fbbd4ca95638981

See more details on using hashes here.

Provenance

The following attestation bundles were made for ms_markets-0.0.97.tar.gz:

Publisher: publish-to-pypi.yml on mainsequence-projects/MainSequenceMarkets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ms_markets-0.0.97-py3-none-any.whl.

File metadata

  • Download URL: ms_markets-0.0.97-py3-none-any.whl
  • Upload date:
  • Size: 650.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for ms_markets-0.0.97-py3-none-any.whl
Algorithm Hash digest
SHA256 9ac41088baad693a3216535bf2f332189f2010291829fc0c2a84cade6ef2ee00
MD5 a09cb60ed7a74f64c7d86a6efae93fb8
BLAKE2b-256 bf61e43cd7afc31d56a9deef6077e4dc103442ba71fbd1a1e4bcccf35bbefe41

See more details on using hashes here.

Provenance

The following attestation bundles were made for ms_markets-0.0.97-py3-none-any.whl:

Publisher: publish-to-pypi.yml on mainsequence-projects/MainSequenceMarkets

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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