Skip to content

Add TickerAll (hosted MetaTrader 4/5) broker and feeds - #3

Draft
miguelangelo78 wants to merge 4 commits into
neurallayer:mainfrom
miguelangelo78:feat/tickerall-metatrader-broker
Draft

Add TickerAll (hosted MetaTrader 4/5) broker and feeds#3
miguelangelo78 wants to merge 4 commits into
neurallayer:mainfrom
miguelangelo78:feat/tickerall-metatrader-broker

Conversation

@miguelangelo78

@miguelangelo78 miguelangelo78 commented Jul 30, 2026

Copy link
Copy Markdown

What this adds

A roboquant/tickerall module that lets roboquant trade and stream market data from a MetaTrader 4/5 broker account through the hosted TickerAll API. No local MetaTrader terminal, no Windows VM, no MetaTrader Python package, so it runs anywhere Python runs.

It mirrors the existing roboquant/alpaca module:

  • TickerAllBroker (a LiveBroker): sync() returns an Account (cash, buying power, open positions), and place_orders() handles new market/limit orders plus modify and cancel, following roboquant's id/size order model.
  • TickerAllLiveFeed (a LiveFeed): live bid/ask ticks published as Quote items over a websocket.
  • TickerAllHistoricFeed (an InMemoryFeed): historic OHLC candles published as Bar items for backtesting.

It is built on the official tickerall Python SDK, added as a new optional tickerall extra. No other new dependency.

This is the Python counterpart of the Kotlin integration discussed in neurallayer/roboquant#104.

Testing it yourself with a free account

You can run the whole integration suite yourself at no cost:

  1. Create a free account at https://tickerall.com and generate an API key.
  2. Connect a broker demo account (any MetaTrader demo works). The free tier supports demo connections, which is all these tests need.
  3. Set two env vars and run the credential-gated tests:
export TICKERALL_API_KEY=your_key
export TICKERALL_ACCOUNT_ID=your_connected_account_id
python -m unittest tests.unit.test_tickerall_it -v

tests/unit/test_tickerall_it.py exercises every surface against the live demo: account sync, historic candles, live ticks, and a demo-guarded round-trip that places and closes a market order and places, modifies, then cancels a pending order. It refuses to run against a non-demo account, and it is gated on the two env vars so it skips cleanly in CI without secrets. tests/unit/test_tickerall.py is a set of unit tests that need no credentials at all.

A note on cost, so there are no surprises

There is no free lunch on live trading: connecting a real-money broker account is a paid tier. But demo connections, historic candles, and the whole integration suite above are free, so testing, backtesting, and paper-style trading against a demo cost nothing.

Opening as a draft so the shape and the test approach can be reviewed before this is a formal review request.

@jbaron

jbaron commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR!!Finalizing some refactoring. Will have a look at the PR once that is done.

Adds a roboquant/tickerall module so roboquant can trade and stream market
data from a MetaTrader broker account through the hosted TickerAll API, with no
local MetaTrader terminal and from any operating system.

- TickerAllBroker: account sync (cash, buying power, positions) + order
  placement (market/limit, modify, cancel), mirroring the Alpaca broker.
- TickerAllLiveFeed: live bid/ask ticks published as Quotes over websocket.
- TickerAllHistoricFeed: historic OHLC candles published as Bars.
- Built on the official 'tickerall' Python SDK, added as a new optional
  'tickerall' extra; no other new dependency.
- Unit tests run in CI; live integration tests are credential-gated.
@miguelangelo78
miguelangelo78 force-pushed the feat/tickerall-metatrader-broker branch from c25cbfa to 15f2731 Compare August 8, 2026 11:56
@jbaron

jbaron commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

I thought I left a comment before, but now I cannot find it :( So here again

The overall project structure changed a bit after you created the PR, so I created new branch called tickerall that has for now the feed, broker and integration tests.

Have been playing around with it (integration test) and 2 findings:

  1. The session.start step is not really clear. Perhaps nice to make it part of Feed and Broker API. Right now I do it myself (is this correct??):
def __connect(self, client):
        assert MT5_ACCOUNT and MT5_PASSWORD and MT5_SERVER
        return client.sessions.start(
            broker="mt5",
            server=MT5_SERVER,
            account=MT5_ACCOUNT,
            password=MT5_PASSWORD
        )
  1. I do get errors, while testing same connection (OANDA demo account) on the tickerall web portal works fine.
======================================================================
ERROR: test_live_ticks (tests.integration.test_tickerall.TestTickerAllIT.test_live_ticks)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/peter/Development/roboquant.py/tests/integration/test_tickerall.py", line 46, in test_live_ticks
    self.__connect(feed._client)
  File "/Users/peter/Development/roboquant.py/tests/integration/test_tickerall.py", line 36, in __connect
    return client.sessions.start(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/peter/Development/roboquant.py/.venv/lib/python3.12/site-packages/tickerall/namespaces/sessions.py", line 55, in start
    data = self._client._request_idempotent(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/peter/Development/roboquant.py/.venv/lib/python3.12/site-packages/tickerall/client.py", line 294, in _request_idempotent
    return self._request(
           ^^^^^^^^^^^^^^
  File "/Users/peter/Development/roboquant.py/.venv/lib/python3.12/site-packages/tickerall/client.py", line 155, in _request
    return self._request_with_rearm(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/peter/Development/roboquant.py/.venv/lib/python3.12/site-packages/tickerall/client.py", line 179, in _request_with_rearm
    return self._request_once(
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/peter/Development/roboquant.py/.venv/lib/python3.12/site-packages/tickerall/client.py", line 258, in _request_once
    raise map_error_response(
tickerall.errors.TickerallForbiddenError: [FREE_TIER_LIVE_REJECTED] Free tier supports demo accounts, plus one live account from the terminal. Live trading via the API and multiple live accounts at once need Pro.

Expose the session-start step directly on the broker and feeds, so credentials go straight to a working broker without a separate client.sessions.start call. connect() uses keep_alive so a long-running session re-arms if the account goes cold, and close() ends only the session it opened; the existing account_id constructor is unchanged. Mirrors the roboquant-alpaca construct-from-credentials idiom.
@miguelangelo78

miguelangelo78 commented Aug 11, 2026

Copy link
Copy Markdown
Author

Thanks @jbaron, I've addressed your comment here: neurallayer/roboquant#104 (comment)

…r-number account id

The live IT suite required TICKERALL_ACCOUNT_ID to be the internal TickerAll account id, which is easy
to confuse with the broker account NUMBER — a mix-up that only surfaced as a later "Broker account not
found". The suite now derives the account id from a MetaTrader login
(TICKERALL_SERVER/TICKERALL_ACCOUNT/TICKERALL_PASSWORD) when no pre-connected id is given, so it runs
from broker credentials alone. Both the broker and feed constructors also reject an all-digits
account_id up-front with a message pointing at connect().
_sync_orders built the size from a float, which LiveBroker wraps in
Decimal(size), so 0.001 came back imprecise. Build it via str() like
_sync_positions does. Adds a regression test.
@miguelangelo78
miguelangelo78 force-pushed the feat/tickerall-metatrader-broker branch from e534bd2 to 6bd4f0c Compare August 12, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants