Market data
Subscriptions to ticks and depth, delivered on the stream.
Types
| Alias | Values |
|---|---|
| Id | str | UUID |
SubscriptionDegraded
A subscription whose symbol cannot tick, or should be ticking and is not.
Sent once, when it becomes degraded. A closed market is not a degradation, and neither is a terminal that restarts and is back inside a few minutes. reason is the platform's own word and is text, not a closed list: symbol_removed, subscription_refused, terminal_disconnected, report_stale and no_ticks_in_session today, and a platform that learns another will send it. A reason that gives way to another while the subscription stays degraded sends nothing; read the subscription for the one that holds.
| Field | Type | Default | Meaning |
|---|---|---|---|
| subscription_id | UUID | ||
| broker_id | UUID | ||
| server_id | UUID | ||
| symbol | str | ||
| reason | str | ||
| since | dt.datetime | ||
| last_tick_at | dt.datetime | None | The symbol's last tick, or None when it has never ticked. |
SubscriptionRecovered
A degraded subscription that is delivering again. Sent once.
reason is what it recovered from and since when it had become degraded, so the two together with recovered_at are the whole gap, without the first message being kept.
| Field | Type | Default | Meaning |
|---|---|---|---|
| subscription_id | UUID | ||
| broker_id | UUID | ||
| server_id | UUID | ||
| symbol | str | ||
| reason | str | ||
| since | dt.datetime | ||
| recovered_at | dt.datetime | ||
| last_tick_at | dt.datetime | None |
Book
A symbol's whole order book as one terminal read it. Replace yours with every one.
Prices and volumes are Decimal, exact as the platform sent them. levels is the most a side the platform reads, so a side shorter than it is the broker's whole side. Not a reconstruction: MFX Hub builds no book from ticks or from several terminals.
| Field | Type | Default | Meaning |
|---|---|---|---|
| channel | str | ||
| seq | int | None | ||
| bids | tuple[tuple[Decimal, Decimal], ...] | Buy orders, highest price first: | |
| asks | tuple[tuple[Decimal, Decimal], ...] | Sell orders, lowest price first. | |
| broker_ts | str | When the terminal read it, on the broker's clock, as a tick's | |
| levels | int |
MarketData
client.md — what this tenant has asked to be streamed.
Ask for a symbol's ticks on one broker server, and optionally its candles.
| Parameter | Type | Default | Description |
|---|---|---|---|
| server_id | Id | required | The server's id from the catalogue. |
| symbol | str | required | The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument. |
| idempotency_key keyword | str | required | Required on every write and never defaulted. Retrying with the same key returns the original answer; a fresh key asks for a new action. |
| timeframes keyword | list[str] | None | None |
|
Returns MdSubscription
symbol is the broker's own name, exactly as the tenant's catalogue lists it (EURUSD.sd, not EURUSD): a broker's suffix is part of the name, and the platform matches what the terminal reports rather than guessing.
timeframes names the candles to build; none means ticks only. Candles arrive on their own channel, candles:{server_id}:{symbol}:{tf}.
Subscribing twice with the same idempotency_key returns the same subscription rather than a second one.
One page of what this tenant has subscribed, newest first.
| Parameter | Type | Default | Description |
|---|---|---|---|
| cursor keyword | str | None | None | Where to continue from; the previous page's next cursor. |
| limit keyword | int | None | None | How many to return at most. |
Returns Page[MdSubscription]
Every subscription, following the cursor.
Returns AsyncIterator[MdSubscription]
Stop streaming this symbol. The channel stops; nothing else is affected.
| Parameter | Type | Default | Description |
|---|---|---|---|
| subscription_id | Id | required | |
| idempotency_key keyword | str | required | Required on every write and never defaulted. Retrying with the same key returns the original answer; a fresh key asks for a new action. |
Returns None
A symbol's bars for a window, oldest first: at most 1,000 a call.
| Parameter | Type | Default | Description |
|---|---|---|---|
| broker | Id | required | |
| symbol | str | required | The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument. |
| timeframe | str | required | One of M1, M5, M15, M30, H1, H4, D1, W1, MN1. |
| from_ keyword | dt.datetime | required | |
| to keyword | dt.datetime | required | When the window holds more than |
| limit keyword | int | None | None | How many to return at most. |
| server_id keyword | Id | None | None | The server's id from the catalogue. |
Returns CandleList
The bars are the ones the broker's server shows the tenant's own account, read through one of its ACTIVE terminals on that server. When the window holds more than limit bars the answer is the newest of them, so a chart asking for "up to now" gets the bars nearest now; ask again with an earlier to for the ones before. The bar still forming is included when the window reaches it: its close is the last price.
timeframe is one of M1, M5, M15, M30, H1, H4, D1, W1, MN1; any other is a ValueError here, before the wire. Each bar's ts is its open time as a true instant: a daily bar opens at the broker's midnight, which is not UTC midnight. symbol is the broker's own name. With terminals on more than one of the broker's servers, name server_id. No bar in the window is an empty answer, not an error.
One read of tick history: the first limit ticks at or after from_, oldest first.
| Parameter | Type | Default | Description |
|---|---|---|---|
| broker | Id | required | |
| symbol | str | required | The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument. |
| from_ keyword | dt.datetime | required | One read of tick history: the first |
| to keyword | dt.datetime | None | None |
|
| limit keyword | int | None | None | How many to return at most. |
| server_id keyword | Id | None | None | The server's id from the catalogue. |
Returns TickList
The ticks are the ones the broker's server keeps for the tenant's own account, read through one of its ACTIVE terminals on that server; MFX keeps no tick store of its own, so how far back they go is the broker's to say. At most 1,000 a call, which is also the default. to leaves out ticks after it. more on the answer is true when the window holds ticks beyond the ones returned - all_ticks follows it.
symbol is the broker's own name. With terminals on more than one of the broker's servers, name server_id.
Every tick of a window, in order, each once, a call at a time.
| Parameter | Type | Default | Description |
|---|---|---|---|
| broker | Id | required | |
| symbol | str | required | The broker's own symbol name, exactly as the catalogue returns it. MFX Hub never renames an instrument. |
| from_ keyword | dt.datetime | required | |
| to keyword | dt.datetime | None | None | |
| page_size keyword | int | None | None | |
| server_id keyword | Id | None | None | The server's id from the catalogue. |
Returns AsyncIterator[Tick]
The contract's way to continue is to ask again from the last tick's time, and several ticks can share one millisecond, so the next answer begins with ticks already held. This drops exactly those and yields the rest, which is easy to get subtly wrong by hand: drop by time alone and ticks are lost, drop nothing and they are doubled.
Every call is a round trip to capacity (a busy symbol passes 100,000 ticks a day): this is for reading history. The stream is the way to follow ticks as they happen.