Skip to main content

mftik

The strategy SDK and command-line client for a MFTIK node — a self-hosted, mid-frequency algorithmic trading platform.

You run the node yourself with Docker Compose — mftik node-init writes the stack for you. This package is both that and what you install on the machine you write strategies on.

pip install mftik

Writing a strategy

A strategy is a subclass of Strategy and a directory of .py files. It reads market data through the hooks it overrides and trades through the accessors the base class binds.

from mftik.strategy import Strategy


class MyStrategy(Strategy):
    name = "my_strategy"

    async def on_best_quote(self, quote) -> None:
        await self.log(f"{quote.universal_ticker} {quote.bid}/{quote.ask}")

self.oms places and cancels orders, self.ledger reads balances, self.mds queries history the feeds do not carry, self.tape warms up on prints from before the session started, self.symbols gives you the tick and step sizes to round to, and self.timer schedules work. See Strategy's docstring for the full set of hooks.

A session that was running when STS went away can come back. Override on_rebuild and set rebuildable = True. Facts you remember while running are handed back there, before on_start; resting orders, fills and position come from recon, not from anything you stored. Leave rebuildable off if coming back would mean trading beside orders you no longer know are yours.

A strategy may import the standard library, mftik, and other files in its own directory — nothing else. The node runs the source you send it rather than an environment you built, so a third-party import would be a module that is not there. mftik check tells you before you push.

The client

mftik node-init ./mynode                 # a whole node: compose, edge, .env
mftik connect https://node.example.com   # sign in once; stores an API key
mftik whoami                             # who you are to that node
mftik profiles                           # every node this machine knows
mftik disconnect <name>                  # forget one
mftik init ./hello                       # scaffold, filled in from that node
mftik check ./hello                      # import gate and on_initialized, offline
mftik run ./hello                        # push, deploy, tail; ^C stops it
mftik push ./hello                       # copy the tree into the node's private registry
mftik run ./hello                        # push, deploy, tail the session log
mftik ps                                 # what is running
mftik logs -f <session>                  # what it is saying
mftik stop <session>                     # stop it

connect signs in with your password, mints an API key through that session, stores the key and drops the session — so the password is never written down. Profiles live in ~/.config/mftik/config.toml at mode 0600. For CI, pass an existing key with --token and no prompt is reached.

init is being built — see docs/CLI.md for the shape it is landing in.

License

MIT

Release files for mftik 0.9.5

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

Source distribution (sdist)

Source distribution for mftik 0.9.5
File Size Uploaded
mftik-0.9.5.tar.gz 724.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mftik 0.9.5
File Interpreter ABI Platform
mftik-0.9.5-py3-none-any.whl Python 3 none any Details

Total release size: 1.4 MB

Release files / mftik-0.9.5.tar.gz

Download URL mftik-0.9.5.tar.gz
Size 724.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f10b378d3aaf321b40cfbf25a11f66c3d85c69cceb5981a5e89a1501dbbc04a1
BLAKE2b-256 checksum
How to use checksums
87de2866b820190c1b382cc7ec8ddd9056bbfa29a8673fa514786b202acc50a7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / mftik-0.9.5-py3-none-any.whl

Download URL mftik-0.9.5-py3-none-any.whl
Size 630.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
20641e42c3330a12139e58be57f1ee201a00ab4fc09a7e1b718474ca39c28809
BLAKE2b-256 checksum
How to use checksums
46941c1b1cb07f99c7b0b0b0ae41e939e841448c4af996219ddcb122fa4c4959
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.13 {"installer":{"name":"uv","version":"0.12.13","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.11.0

2 release files

0.10.0

2 release files

0.9.7

2 release files

0.9.6

2 release files

This release

0.9.5 This release

2 release files

0.6.0

2 release files

0.5.2

2 release files

0.4.1

2 release files

0.3.5

2 release files

0.3.1

2 release files

0.2.0

2 release files

0.0.11

2 release files

0.0.4

2 release files

0.0.3

2 release files

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