A unified, high-performance API layer that powers all trading infrastructure across the HedgeTech ecosystem, providing modular, scalable, and real-time interfaces for market data, order management, and execution systems.
Project description
HedgeTech Python SDK
HedgeTech Python SDK is a professional, lightweight, and modular Python package designed to provide seamless access to HedgeTech services. The SDK is crafted for developers, data analysts, and algorithmic traders who want to interact with the Tehran Stock Exchange (TSE & IFB) using a clean, reliable, and easy-to-use API. It supports both synchronous and asynchronous workflows, offering maximum flexibility and performance for different application scenarios.
Note: This SDK requires Python >= 3.10 and is currently in Beta. Some APIs may change in future releases, but it is stable enough for daily use.
Features
- Secure authentication with both async and sync clients.
- Real-time and historical market data retrieval from TSE & IFB.
- Full EMS Engine order management (buy/sell, edit, status, delete) for both Sync and Async workflows.
- Modular and maintainable architecture, designed to support multiple engines (DataEngine engines, WebSocket clients, etc.).
- Structured request and response types for robust data handling.
- Fully asynchronous support for high-performance applications.
- Easy to integrate into trading bots, analytics pipelines, dashboards, or WebSocket feeds.
Installation
Install HedgeTech SDK via PyPI:
pip install HedgeTech
Updating the Package
To update HedgeTech SDK to the latest version in your environment, use:
pip install --upgrade HedgeTech
Usage
The SDK exposes all major clients through the top-level modules, so you generally do not need to import internal implementation files directly.
Authentication
Note: Make sure to use the matching async or sync Auth client depending on your workflow.
Async Authentication
from HedgeTech.Auth import AuthAsyncClient
auth_async_client = await AuthAsyncClient.login(
UserName_or_Email='<YOUR UserName_or_Email>',
Password='<YOUR Password>'
)
print(auth_async_client.token)
Sync Authentication
from HedgeTech.Auth import AuthSyncClient
auth_sync_client = AuthSyncClient.login(
UserName_or_Email='<YOUR UserName_or_Email>',
Password='<YOUR Password>'
)
print(auth_sync_client.token)
DataEngine / TSE IFB
The DataEngine is designed to support multiple engines in a modular way. Each engine provides its own async and sync clients, structured request and response types, and can be integrated with other engines such as WebSocket clients.
Important Note on Sync vs Async: All clients have the same method names and behavior in both Sync and Async versions. The only difference is how they execute: Sync runs in a blocking manner, while Async requires
awaitand an event loop. This design allows you to switch between Sync and Async without changing the logic or input/output of your code.
Async Data Client
from HedgeTech.DataEngine import DataEngine_TseIfb_AsyncClient
client = DataEngine_TseIfb_AsyncClient(auth_async_client)
data = await client.live_best_limit_by_isin(
symbol_isins=['IRT1AHRM0001','IRO1IKCO0001']
)
print(data)
# websocket Example
async for update in client.websocket_by_name(
channels=["best-limit", "order-book"],
symbol_names=["فملی","اطلس"]
):
print(update["data"])
Sync Data Client
from HedgeTech.DataEngine import DataEngine_TseIfb_SyncClient
client = DataEngine_TseIfb_SyncClient(auth_sync_client)
data = client.historical_ohlcv_by_name(
symbolName='مهرگان',
start_timestamp=0,
end_timestamp='1763411432',
AdjustedPrice=True,
Resolution='D'
)
print(data)
# websocket Example
for update in client.websocket_by_isin(
channels=["best-limit", "order-book"],
symbol_isins=["IR1234567890"]
):
print(update["data"])
EMS Engine / Order Management
The SDK provides full order lifecycle management for TSE/IFB markets. You can create, edit, delete, and check the status of buy/sell orders with both Sync and Async clients.
Features
- Create buy/sell orders by symbol name or ISIN.
- Edit orders (price, volume, validity type/date).
- Retrieve current order status including executed and remaining volume.
- Delete/cancel orders.
- Fully Async/Sync compatible with identical method names.
Async Example
from HedgeTech.EMSEngine import EmsEngine_TseIfb_AsyncClient
ems_client = EmsEngine_TseIfb_AsyncClient(auth_async_client)
# Login to OMS
await ems_client.oms_login("username", "password", "captcha_value")
# Create a buy order
order = await ems_client.Buy_by_Name(
symbolName="اطلس",
Price=100000,
Volume=10
)
await order.send()
# Check status
status = await order.Status()
print(status)
# Edit order
await order.Edit(Price=105000, Volume=12)
# Delete order
await order.Delete()
print(order.is_deleted) # True
Sync Example
from HedgeTech.EMSEngine import EmsEngine_TseIfb_SyncClient
ems_client = EmsEngine_TseIfb_SyncClient(auth_sync_client)
# Login to OMS
ems_client.oms_login("username", "password", "captcha_value")
# Create a sell order
order = ems_client.Sell_by_Name(
symbolName="فملی",
Price=50000,
Volume=5
)
order.send()
# Check status
status = order.Status()
print(status)
# Edit order
order.Edit(Price=52000, Volume=6)
# Delete order
order.Delete()
print(order.is_deleted) # True
All methods for Async and Sync clients have the same parameters and naming for easy switching.
Important Notes for Users
- This SDK requires Python >=3.10.
- The SDK is currently in Beta — APIs may change in future releases, but it is usable for most workflows.
- Always install dependencies with the specified versions to avoid compatibility issues.
- Async clients require an asyncio event loop.
- All main clients are exposed through top-level modules; you do not need to access internal files.
- Keywords and classifiers are chosen to make the SDK easy to find for developers working in finance, trading, and data analysis.
Modules Overview
HedgeTech.Auth
Handles authentication for all HedgeTech clients. The async (AuthAsyncClient) and sync (AuthSyncClient) clients are exposed through the top-level Auth module.
HedgeTech.DataEngine
Handles interactions with the Tehran Stock Exchange IFB and other engines. Provides:
- Async and sync clients for fetching market data.
- Structured request and response types for predictable and robust data handling.
- Modular design that allows integration of additional engines, such as WebSocket clients or future data engines, without modifying the main interface.
HedgeTech.EMSEngine
Handles TSE/IFB order management (EMS Engine):
EmsEngine_TseIfb_AsyncClient/EmsEngine_TseIfb_SyncClientOrderclass for individual order lifecycle- Methods:
Buy_by_Name,Sell_by_Name,Buy_by_isin,Sell_by_isin,Edit,Status,Delete - Fully compatible with both Async and Sync workflows
Contributing
We welcome contributions from the community! Please follow standard Python coding conventions, write clear documentation for any new features, and submit pull requests for improvements or bug fixes.
License
This project is licensed under the Apache License 2.0. See the LICENSE file for full details.
Support
For questions or issues, please open a GitHub issue or contact the HedgeTech team directly. We aim to provide timely support and guidance for all developers using the SDK.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hedgetech-0.2.2b0.tar.gz.
File metadata
- Download URL: hedgetech-0.2.2b0.tar.gz
- Upload date:
- Size: 43.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
270a982191f19cea2a588aaa48ef8b3d63f13550157fb3d83fa74f2ed9a5d114
|
|
| MD5 |
378bbc6a98cf9a2e9311ed80a4da6bf5
|
|
| BLAKE2b-256 |
60c0a51e532f65794d48f075846a4b7f524e72bf7e8238d96ed8078f7d883b05
|
File details
Details for the file hedgetech-0.2.2b0-py3-none-any.whl.
File metadata
- Download URL: hedgetech-0.2.2b0-py3-none-any.whl
- Upload date:
- Size: 51.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
199686e2c81d004aa092d76f5b5bd4ada737b4ef97425fa6746f52edbf4fe5d1
|
|
| MD5 |
c8798edc6361ef6e82a5811c90d3c02e
|
|
| BLAKE2b-256 |
dc0f784dae3bafd3ad0a7d833b5f6f245b667edbddd31a90934cdee73f1e7e80
|