MFX Hub
SDK reference

Accounts and catalogue

Generated from mfx-sdk-python 0.9.11·rebuilt on every release

What a terminal sees of its account, and what you can point a terminal at.

Accounts

Balance, positions, orders, history and spreads for one tenant's terminals.

async account(terminal_id: Id) -> Account

Balance, equity and margin, plus the slow profile facts. Each half with its own ts; a half never observed is null, not zero.

ParameterTypeDefaultDescription
terminal_idIdrequired

The terminal to act on. Another customer's id answers 404, never 403.

Returns Account

async positions(terminal_id: Id) -> PositionList

Every open position, as one snapshot with its as_of.

ParameterTypeDefaultDescription
terminal_idIdrequired

The terminal to act on. Another customer's id answers 404, never 403.

Returns PositionList

async pending_orders(terminal_id: Id) -> PendingOrderList

Every pending order, as one snapshot with its as_of.

ParameterTypeDefaultDescription
terminal_idIdrequired

The terminal to act on. Another customer's id answers 404, never 403.

Returns PendingOrderList

async deals( terminal_id: Id, *, from_: dt.datetime, to: dt.datetime, cursor: str | None = None, limit: int | None = None, ) -> Page[Deal]

Closed deals, newest first, inside a window.

ParameterTypeDefaultDescription
terminal_idIdrequired

The terminal to act on. Another customer's id answers 404, never 403.

from_ keyworddt.datetimerequired
to keyworddt.datetimerequired
cursor keywordstr | NoneNone

Where to continue from; the previous page's next cursor.

limit keywordint | NoneNone

How many to return at most.

Returns Page[Deal]

The window is required, by the API and so by this: an unbounded history request over a partitioned table is the query that takes a database down. Paged, because history does not change under you the way a live list does.

async spread(terminal_id: Id) -> SpreadList

The spread this terminal's own account is quoted, with each reading's age.

ParameterTypeDefaultDescription
terminal_idIdrequired

The terminal to act on. Another customer's id answers 404, never 403.

Returns SpreadList

A pool cannot answer this: the spread a user trades against is the one their broker gives their account, so it is read from their terminal.

Catalog

The brokers, servers and symbols this tenant may use.

async brokers(*, cursor: str | None = None, limit: int | None = None) -> Page[TenantBroker]

One page of the brokers MFX supports, with each one's status.

ParameterTypeDefaultDescription
cursor keywordstr | NoneNone

Where to continue from; the previous page's next cursor.

limit keywordint | NoneNone

How many to return at most.

Returns Page[TenantBroker]

status is the broker's: active is usable, suspended and retired are not. A terminal requested on a broker that is not usable is refused at request time, and the SDK turns that refusal into UnsupportedBrokerError.

async all_brokers() -> AsyncIterator[TenantBroker]

Every broker, following the cursor.

Returns AsyncIterator[TenantBroker]

async servers( broker_id: Id, *, cursor: str | None = None, limit: int | None = None, ) -> Page[TenantBrokerServer]

The the terminal servers this broker runs, and whether MFX can use each one now.

ParameterTypeDefaultDescription
broker_idIdrequired

The broker's id from the catalogue.

cursor keywordstr | NoneNone

Where to continue from; the previous page's next cursor.

limit keywordint | NoneNone

How many to return at most.

Returns Page[TenantBrokerServer]

server_name is what a credential names. enabled is the per-server switch and disabled_reason is the sentence the operator recorded for it — the same words the refusal carries, so a caller can show a user why before it asks for a terminal rather than after. A terminal requested on a disabled server is refused 409 and reaches the caller as UnsupportedBrokerError with refused_by == "server_disabled", which means try another server of this broker.

async symbols( broker_id: Id, *, server_id: Id | None = None, account_type: str | None = None, cursor: str | None = None, limit: int | None = None, ) -> Page[Symbol]

The symbols this broker lists, in its own names.

ParameterTypeDefaultDescription
broker_idIdrequired

The broker's id from the catalogue.

server_id keywordId | NoneNone

The server's id from the catalogue.

account_type keywordstr | NoneNone

server_id and account_type narrow the list to one server or one account type, for a tenant with more than one on this broker.

cursor keywordstr | NoneNone

Where to continue from; the previous page's next cursor.

limit keywordint | NoneNone

How many to return at most.

Returns Page[Symbol]

server_id and account_type narrow the list to one server or one account type, for a tenant with more than one on this broker.

These are the names to pass to terminals.create and to execution.place_order: MFX never renames an instrument on a tenant's behalf, so BTCUSD.lv is what a broker that calls it that will answer to.

async symbol( broker_id: Id, symbol: str, *, server_id: Id | None = None, account_type: str | None = None, ) -> Symbol

One symbol's specification, including pip_value_per_lot.

ParameterTypeDefaultDescription
broker_idIdrequired

The broker's id from the catalogue.

symbolstrrequired

The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument.

server_id keywordId | NoneNone

The server's id from the catalogue.

account_type keywordstr | NoneNone

A symbol listed on more than one of the tenant's servers or account types is answered 409 ambiguous_symbol; name server_id and account_type to say which.

Returns Symbol

A symbol listed on more than one of the tenant's servers or account types is answered 409 ambiguous_symbol; name server_id and account_type to say which.

async quote( broker_id: Id, symbol: str, *, server_id: Id | None = None, account_type: str | None = None, ) -> SymbolQuote

The current quote for one symbol, with its age.

ParameterTypeDefaultDescription
broker_idIdrequired

The broker's id from the catalogue.

symbolstrrequired

The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument.

server_id keywordId | NoneNone

The server's id from the catalogue.

account_type keywordstr | NoneNone

A symbol listed on more than one of the tenant's servers or account types is answered 409 ambiguous_symbol; name server_id and account_type to say which.

Returns SymbolQuote

A quote is never returned without saying how old it is: a stale quote reads exactly like a live one and gets acted on.

A symbol listed on more than one of the tenant's servers or account types is answered 409 ambiguous_symbol; name server_id and account_type to say which.

UsageReader

One call, because there is one question: what has been used and what is left.

async get() -> Usage

Consumption per metric, this key's ceilings, and the remaining budget with its source.

Returns Usage