fundedops
The official Python SDK for the FundedOps API: typed access to accounts, positions, orders, trade history, live quotes and candles, trading and real-time streaming, backed by pydantic v2 models that mirror the wire format exactly.
Supports both MT4 and MT5 accounts: the same clients, methods and models work the same way on either platform.
This file doubles as the package's PyPI page.
Install
pip install fundedops
Requires Python 3.10+.
Authentication
Every request carries your API key as a bearer token
(Authorization: Bearer fo_...). Create a key from the developer portal. The
key travels in the WebSocket URL's query string — never log stream URLs.
Usage
Two first-class clients with an identical method surface — synchronous
FundedOps and asynchronous AsyncFundedOps. Every method lives under the
client.accounts namespace, except wait_until_connected, stream and the
trading methods, which are on the client itself.
Synchronous
from fundedops import FundedOps
with FundedOps(api_key="fo_live_...") as client:
for account in client.accounts.list():
print(account.id, account.state, account.connection_status)
info = client.accounts.account_information(account.id)
print(info.balance, info.equity, info.currency)
# Deploy and block until connected (timeout is mandatory). Raises
# DeployFailedError right away if the deploy fails, TimeoutError on timeout.
client.accounts.deploy(account.id)
client.wait_until_connected(account.id, timeout=180)
The full lifecycle and read surface is available on client.accounts:
create, get, list, update, delete, deploy, undeploy,
redeploy, account_information, positions, pending_orders,
history_deals, history_positions, and history_orders.
Asynchronous
AsyncFundedOps is the exact awaitable mirror — same constructor, same
method names, same return types (a parity test enforces it):
import asyncio
from fundedops import AsyncFundedOps
async def main():
async with AsyncFundedOps(api_key="fo_live_...") as client:
accounts = await client.accounts.list()
info = await client.accounts.account_information(accounts[0].id)
print(info.equity)
asyncio.run(main())
Streaming
client.stream([account_id, ...]) opens a WebSocket, subscribes each
account, answers server pings for you, and yields typed events:
from fundedops import FundedOps
client = FundedOps(api_key="fo_live_...")
for event in client.stream(["9b2c..."]):
if event.type == "positions_updated":
print("open:", len(event.updated), "closed:", event.removed_ids)
Prices
accounts.quote returns the latest bid and ask, and accounts.candles returns up to
1,000 bars of one timeframe (M1 to MN1, oldest first). Both also exist on
AsyncFundedOps.
quote = client.accounts.quote("9b2c...", "EURUSD")
print(quote.bid, quote.ask)
bars = client.accounts.candles("9b2c...", "EURUSD", "H1", limit=200)
print(bars.candles[-1].close)
accounts.quotes returns the latest prices of 1 to 50 distinct symbols in one call.
Every symbol ends up in quotes or in errors, so one unknown symbol never fails the
call. An error's status is the HTTP status quote would answer for that symbol alone
(404 or 503), with code when that answer carries one.
result = client.accounts.quotes("9b2c...", ["EURUSD", "GBPUSD", "XAUUSD"])
for quote in result.quotes:
print(quote.symbol, quote.bid, quote.ask)
for error in result.errors:
print(error.symbol, error.status, error.code)
Calculations
Three read-only calls ask the account what a trade would cost, without trading. They work with a Read Only key.
margin = client.accounts.calculate_margin("9b2c...", "EURUSD", "buy", 0.1)
print(margin.margin, margin.currency)
profit = client.accounts.calculate_profit("9b2c...", "EURUSD", "buy", 0.1, 1.08, 1.09)
print(profit.profit)
check = client.accounts.check_order("9b2c...", "buy_limit", "EURUSD", 0.1, price=1.08)
if not check.can_place:
print(check.code, check.message)
else:
print(check.margin, check.free_margin, check.margin_level)
A refusal is a normal answer, not an exception: can_place is false with a code
such as E_INVALID_VOLUME or E_ACCOUNT_CANNOT_TRADE. The money fields describe
the account after the order; they are None when the order cannot be placed for a
reason other than free margin.
For live prices, call the subscribe methods on the stream, before the loop or while iterating. Frames sent before iteration wait and go out once, right after the accounts subscribe. A stream holds up to 50 price subscriptions (quote symbols plus candle streams together).
stream = client.stream(["9b2c..."])
stream.subscribe_quotes("9b2c...", ["EURUSD", "GBPUSD"])
stream.subscribe_candles("9b2c...", "EURUSD", "M5")
for event in stream:
if event.type == "quotes":
print([(q.symbol, q.bid, q.ask) for q in event.quotes])
elif event.type == "candle" and event.closed:
print("closed", event.symbol, event.candle.time, event.candle.close)
Trading
Trading needs a Full Access key. place_order, modify_order,
cancel_order, modify_position, close_position, close_position_by and
close_positions each return a TradeRequest and send an Idempotency-Key: pass
idempotency_key=, or the SDK generates one per call and exposes it as
trade.idempotency_key and as .idempotency_key on every error the call
raises. Sending a key again never trades twice: it returns the first request's
outcome. The SDK never retries on its own.
import uuid
from fundedops import FundedOps, TradeOutcomeUnknownError, TradeRejectedError
with FundedOps(api_key="fo_live_...") as client:
key = uuid.uuid4().hex
try:
trade = client.place_order(account_id, "buy", "EURUSD", 0.1,
stop_loss=1.079, idempotency_key=key)
except TradeOutcomeUnknownError:
# The connection failed before an answer arrived. Send the same call
# with the same key: you get the first request's outcome, never a
# second trade.
trade = client.place_order(account_id, "buy", "EURUSD", 0.1,
stop_loss=1.079, idempotency_key=key)
except TradeRejectedError as exc:
print(exc.code, exc.broker_code, exc.retryable)
raise
if trade.status in ("queued", "sent"):
trade = client.wait_for_trade_request(account_id, trade.id, timeout=60)
print(trade.status, trade.result)
close_position_by(account_id, ticket, opposite_ticket) closes two opposite
positions on the same symbol against each other. trade.result.remaining_ticket is
the position left open when the volumes differ, or None when both closed in full. None also when, on MT4, the new ticket of the rest could not be identified; message then says so, so list positions.
E_INVALID_CLOSE_BY means the two positions cannot be closed by each other (the
same ticket, different symbols or the same direction).
A write waits about 10 seconds for the broker. done comes back at once. A
request without an outcome comes back with HTTP 202: queued or sent while
it is in progress, or unknown when it may have reached the broker but no
outcome came back. wait_for_trade_request polls a queued or sent request
until its status is final:
| Status | Meaning |
|---|---|
done |
The broker carried it out. trade.result holds the tickets, price and volume. |
rejected |
The broker refused it. trade.error has code, broker_code and retryable. |
expired |
It was not sent before expires_in_seconds ran out. Nothing happened at the broker: send it again with a new key. |
unknown |
It may have reached the broker, for example the connection dropped while an open or a close was sent. Check positions and orders before sending it again. A late answer can still turn it into its real outcome. |
Errors a trading write raises:
| Error | When |
|---|---|
TradeRejectedError |
422: the broker rejected it. code, broker_code, retryable, trade_request_id. Send it again only with a new key, and only when retryable. |
TradeExpiredError |
503 E_REQUEST_EXPIRED: never sent. Send it again with a new key. |
TradeOutcomeUnknownError |
The connection failed before an answer arrived (timeout, reset, protocol error). Send it again with the same key, or find it with list_trade_requests. |
IdempotencyKeyReusedError |
422: the key was already used for a different request. |
ForbiddenError |
403: the key is Read Only (no code), or code is E_ACCOUNT_CANNOT_TRADE or E_TRADING_NOT_SUPPORTED. |
ServiceUnavailableError |
503 E_ACCOUNT_NOT_CONNECTED: nothing was stored. Retry shortly with the same key. |
RateLimitedError |
429: the request rate limit, or metadata["code"] == "E_QUEUE_FULL" when 50 requests are already waiting for the account. Nothing was stored. |
Errors
Every non-2xx response raises a typed exception derived from
FundedOpsError (ValidationError, CredentialsBlockedError,
UnauthorizedError, PaymentRequiredError, NotFoundError,
ConflictError, RateLimitedError with retry_after,
ServiceUnavailableError, and more), each carrying status, message, and
request_id.
wait_until_connected raises DeployFailedError as soon as the account
reaches deploy_failed. Its code (for example E_AUTH), retryable and
message come from the account's error.
from fundedops import DeployFailedError
try:
client.wait_until_connected(account.id, timeout=180)
except DeployFailedError as exc:
print(exc.code, exc.retryable, exc)
Rate limits
client.rate_limit holds the request budget from the latest response's
X-RateLimit-* headers: limit (bucket size), remaining (requests left)
and reset (seconds until the bucket is full again).
client.accounts.list()
print(client.rate_limit.remaining, client.rate_limit.reset)
Documentation
Full API reference: https://api.fundedops.com/v1/docs
License
MIT
Metadata
Release files for fundedops 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fundedops-0.9.0.tar.gz | 59.8 kB | Without provenance | Details for fundedops-0.9.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fundedops-0.9.0-py3-none-any.whl | Python 3 | none | any | Details for fundedops-0.9.0-py3-none-any.whl |
Total release size: 95.9 kB
Release files / fundedops-0.9.0.tar.gz
| Download URL | fundedops-0.9.0.tar.gz |
|---|---|
| Size | 59.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1fe4a9fa65a75838621efae171deb5f2092ecdece2d06d6a9e4117732c598c01
|
|
BLAKE2b-256 checksum How to use checksums |
7fcc20c4b864533b43447d7fe44c5ca15763fb0e6f75b05434f48665ab011b08
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Release files / fundedops-0.9.0-py3-none-any.whl
| Download URL | fundedops-0.9.0-py3-none-any.whl |
|---|---|
| Size | 36.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7cb93c0a402b1ccb237f65f85ea2ac771f0767f560d06e5512c08799df59d1d8
|
|
BLAKE2b-256 checksum How to use checksums |
6898abe768737d984ce6f5115b27c8d8ad6310ccb7c5be50dda41ace92e2dfad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.3
|
Security for fundedops 0.9.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.