FiveTwenty
FiveTwenty is a Python client for OANDA's v20 REST API. Use it to read market data,
manage orders and trades, and follow account activity. Choose AsyncClient for
asyncio applications or Client for synchronous code.
Features
- Access accounts, instruments, orders, trades, positions, pricing and transactions.
- Work with typed Pydantic models,
Decimalfinancial values and Pythondatetimeobjects. - Reuse HTTP connections and handle failures with structured exceptions and retries for eligible read requests.
- Stream prices and transactions, with an optional reconnection helper for pricing.
The documentation includes tutorials, integration guides and a full API reference.
Quick start
You need Python 3.10 or later and an OANDA v20 practice account. Install FiveTwenty
and python-dotenv, the optional helper used here to load credentials from a file:
pip install fivetwenty python-dotenv
With uv, use uv add fivetwenty python-dotenv instead.
Create a .env file in your project directory and replace the placeholders with
your practice token and account ID.
Add .env to .gitignore to keep credentials out of version control:
FIVETWENTY_OANDA_TOKEN=your-practice-token
FIVETWENTY_OANDA_ACCOUNT=your-account-id
FIVETWENTY_OANDA_ENVIRONMENT=practice
Save the following as quickstart.py in the same directory. It reads your account
balance and a price snapshot for EUR/USD without placing an order. The
load_dotenv() call loads .env; FiveTwenty then reads the environment variables.
import asyncio
from dotenv import load_dotenv
from fivetwenty import AsyncClient, Environment
load_dotenv()
async def main() -> None:
async with AsyncClient() as client:
if client.config.environment != Environment.PRACTICE:
message = "Use a practice account for this example"
raise ValueError(message)
response = await client.accounts.get_account_summary(client.account_id)
account = response["account"]
print(f"Balance: {account.balance} {account.currency}")
response_prices = await client.pricing.get_pricing(
client.account_id, instruments=["EUR_USD"]
)
for price in response_prices["prices"]:
print(f"{price.instrument}: {price.closeout_bid} / {price.closeout_ask}")
if __name__ == "__main__":
asyncio.run(main())
Run it with python quickstart.py, or uv run quickstart.py in a uv project.
Responses combine dictionaries and typed models: response["account"] selects the
account model, and account.balance reads its Decimal balance. Other dictionary
keys, such as lastTransactionID, preserve OANDA's response metadata. See
models and response shapes
for details.
Next steps
- Create and close a practice trade.
- Choose between async and sync clients.
- Browse runnable scripts and notebooks.
- Look up methods, parameters and return types.
Before submitting orders, read the error-handling guide. The SDK sends write requests once. If a request times out, check account or transaction state before submitting it again: OANDA may already have processed it.
Compatibility and upgrades
While FiveTwenty is below version 1.0, minor releases may include breaking changes. Read the changelog before upgrading. It includes migration examples for changes to response types and dependent-order cancellation.
Requirements and development
FiveTwenty requires HTTPX >= 0.26.0 and Pydantic >= 2.7.0; the installer supplies both. See the testing guide for supported Python versions, coverage checks and opt-in practice-account tests.
License
FiveTwenty is released under the MIT License.
Disclaimer
This library is provided for educational and demonstration purposes only.
Trading financial instruments involves substantial risk of loss. Test against a practice account before risking real capital; you are solely responsible for your trading decisions, and the authors accept no liability for losses incurred through use of this software. Past performance is not indicative of future results.
USE AT YOUR OWN RISK.
Metadata
Release files for fivetwenty 0.5.1
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 | |
|---|---|---|---|---|
| fivetwenty-0.5.1.tar.gz | 70.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| fivetwenty-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 147.0 kB
Release files / fivetwenty-0.5.1.tar.gz
| Download URL | fivetwenty-0.5.1.tar.gz |
|---|---|
| Size | 70.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
598d93b2a417f10da9a886414fdc29bf26425e8987935df6656efa55f6dc96fe
|
|
BLAKE2b-256 checksum How to use checksums |
759be3801ceca92d63b26c96693f29d3af184d1318dd13e99df819c3862f99d2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.6
|
Release files / fivetwenty-0.5.1-py3-none-any.whl
| Download URL | fivetwenty-0.5.1-py3-none-any.whl |
|---|---|
| Size | 76.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
14d4dcce3ae9c0f0f84c9bf214de840b42b2da8870490b955e766110e4a14a2b
|
|
BLAKE2b-256 checksum How to use checksums |
d4daefed10094537b60077e7dfffe815c7884633c117b9b79198bf1ee85c80bd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.6
|
Security for fivetwenty 0.5.1
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.