Skip to main content

fm-sdk-python

Python SDK for the Flexemarkets API.

Requirements

  • Python 3.11+

Install

pip install fm-sdk

Configuration

The SDK loads credentials and endpoint from these sources (highest priority first):

  1. Arguments passed to Flexemarkets.connect()
  2. Files ~/.fm/credential and ~/.fm/endpoint (Java .properties format)
  3. Environment variable FM_API_URL (defaults to https://api.flexemarkets.com)

Credential file

Create ~/.fm/credential:

account=myaccount
email=user@example.com
password=secret

Or use a bearer token:

token=eyJhbGciOiJIUzI1NiJ9...

Endpoint file

Create ~/.fm/endpoint:

endpoint=https://api.flexemarkets.com/api/marketplaces/123

SDK usage

from fm import Flexemarkets, OrderBooks, MarketplaceTrades

# Connect
fm = Flexemarkets.connect(
    credential="~/.fm/credential",
    endpoint="https://api.flexemarkets.com/api/marketplaces/123",
    client_description="my-bot",
)

# REST API
marketplace_id = fm.endpoint_marketplace_id
markets = fm.markets(marketplace_id)
session = fm.session(marketplace_id)
holdings = fm.holdings(marketplace_id)

# Submit orders
order = fm.submit_limit(marketplace_id, market_id, "BUY", units=1, price=950)
fm.submit_cancel(marketplace_id, market_id, order.id)

# WebSocket events
import queue

q = queue.Queue(maxsize=1000)
fm.listen(marketplace_id, q)

books = OrderBooks(markets)
trades = MarketplaceTrades(markets)

while True:
    event = q.get()
    match event:
        case list() as orders:
            books.update(orders)
            trades.update(orders)
        case Session() as s:
            print(s.state)
        case Holding() as h:
            print(h.cash)

fm.close()

The client also works as a context manager:

with Flexemarkets.connect(credential, endpoint, "my-bot") as fm:
    ...

Applications

ticker

Live terminal display of order book best bid/ask, spread, and recent trade prices.

python3.11 ticker.py -C ~/.fm/credential -E 123

Options:

Flag Description
-C, --credential Credential file path or bearer token
-E, --endpoint Marketplace id, endpoint file path, or URL

Output:

fm-ticker                                              OPEN

  Symbol     Bid     Ask  Spread   Last trades
  ------  ------  ------  ------   -----------
    AAPL  $ 9.50  $10.50  $ 1.00   $9.50  $10.00
     IBM  $ 4.00  $ 5.00  $ 1.00   $4.50

The display refreshes on each order book update. Press Ctrl-C to stop.

Metadata

Release files for fm-sdk 0.1.4

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

Source distribution (sdist)

Source distribution for fm-sdk 0.1.4
File Size Uploaded Provenance
fm_sdk-0.1.4.tar.gz 68.8 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for fm-sdk 0.1.4
File Interpreter ABI Platform
fm_sdk-0.1.4-py3-none-any.whl Python 3 none any Details

Total release size: 113.0 kB

Release files / fm_sdk-0.1.4.tar.gz

Download URL fm_sdk-0.1.4.tar.gz
Size 68.8 kB
Tags Source
SHA-256 checksum
How to use checksums
280eda1901e00450e168dacf7166165db376e1d9f84d04dc70318d53b66b90ef
BLAKE2b-256 checksum
How to use checksums
47aba52694b5f87f4572f27be796e93e1cb75d5353a814804b903ae103a01ecc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 31, 2026.

Transparency log

Release files / fm_sdk-0.1.4-py3-none-any.whl

Download URL fm_sdk-0.1.4-py3-none-any.whl
Size 44.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c12d0a9407a56ec812aed4a03863a916c3dc4d2af51975ad359621d20e703798
BLAKE2b-256 checksum
How to use checksums
4d862cb0b9b0e5defac59c95f5cd852cd7a0afcbaef2333d354e44ed6989a174
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Aug 31, 2026.

Transparency log

Security for fm-sdk 0.1.4

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

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fm_sdk-0.1.4.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 Aug 31, 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.

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