Skip to main content

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 async and sync clients.
  • Real-time and historical market data from TSE & IFB.
  • Full EMS Engine order lifecycle management.
  • Modular architecture (Auth, DataEngine, EMSEngine).
  • Structured request/response types.
  • High-performance asyncio support.
  • Easy integration with trading bots and dashboards.

Installation

Install via PyPI:

pip install HedgeTech

Update

pip install --upgrade HedgeTech

Package Structure

HedgeTech/
 ├── Auth/
 ├── DataEngine/
 ├── EMSEngine/
 └── __init__.py

Authentication

All services require authentication.

Use matching Sync/Async clients.

Async Authentication

from HedgeTech.Auth import AuthAsyncClient

auth_async_client = await AuthAsyncClient.login(
    UserName_or_Email="user@example.com",
    Password="password"
)

print(auth_async_client.token)

Sync Authentication

from HedgeTech.Auth import AuthSyncClient

auth_sync_client = AuthSyncClient.login(
    UserName_or_Email="user@example.com",
    Password="password"
)

print(auth_sync_client.token)

DataEngine (Market Data)

The DataEngine module provides unified access to:

  • Live market data
  • Historical OHLCV
  • Order books
  • Best limits
  • WebSocket streams

All engines follow identical Sync/Async APIs.


Async Data Example

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)

async for update in client.websocket_by_name(
    channels=["best-limit","order-book"],
    symbol_names=["فملی","اطلس"]
):
    print(update["data"])

Sync Data Example

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)

for update in client.websocket_by_isin(
    channels=["best-limit","order-book"],
    symbol_isins=["IR1234567890"]
):
    print(update["data"])

EMSEngine (Order Management)

The EMSEngine module handles complete order management.

Supported markets: - TSE - IFB


EMSEngine Features

  • Buy/Sell by Name or ISIN
  • Edit Orders
  • Cancel/Delete Orders
  • Real-time Status
  • Async/Sync Compatibility
  • Order Object Lifecycle

Order Lifecycle

  1. Create Order
  2. Send
  3. Monitor Status
  4. Edit (Optional)
  5. Settle or Delete

Async Trading Example

from HedgeTech.EMSEngine import EmsEngine_TseIfb_AsyncClient

ems = EmsEngine_TseIfb_AsyncClient(auth_async_client)

captcha = await ems.Get_Captcha("Omex | Parsian")
captcha.show()

await ems.oms_login(
    username="user",
    password="pass",
    captcha_value="1234"
)

order = await ems.Buy_by_Name(
    symbolName="اطلس",
    Price=100000,
    Volume=10
)

await order.send()

status = await order.Status()
print(status)

await order.Edit(Price=105000, Volume=12)

await order.Delete()

Sync Trading Example

from HedgeTech.EMSEngine import EmsEngine_TseIfb_SyncClient

ems = EmsEngine_TseIfb_SyncClient(auth_sync_client)

captcha = ems.Get_Captcha("Omex | Parsian")
captcha.show()

ems.oms_login(
    username="user",
    password="pass",
    captcha_value="1234"
)

order = ems.Sell_by_Name(
    symbolName="فملی",
    Price=50000,
    Volume=5
)

order.send()

status = order.Status()
print(status)

order.Edit(Price=52000, Volume=6)

order.Delete()

Unified API Design

All Sync and Async clients share:

  • Same method names
  • Same parameters
  • Same return types

Only execution model differs.

This enables seamless switching between modes.


Error Handling

  • Invalid credentials raise ValueError
  • Network errors should be handled by user
  • Failed requests may return None

Recommended: wrap calls in try/except.


Performance

  • Non-blocking Async I/O
  • Connection pooling
  • Optimized request batching
  • Suitable for HFT and Algo Trading

Security

  • JWT Authentication
  • Encrypted Transport (HTTPS)
  • No password storage
  • Session isolation

Best Practices

  • Refresh tokens regularly
  • Monitor order status
  • Avoid duplicate send()
  • Validate inputs
  • Log critical operations

Modules Overview

HedgeTech.Auth

Provides:

  • AuthAsyncClient
  • AuthSyncClient
  • Token management
  • Session handling

HedgeTech.DataEngine

Provides:

  • Market data APIs
  • Historical data
  • WebSocket feeds
  • Modular engine design

HedgeTech.EMSEngine

Provides:

  • EmsEngine_TseIfb_AsyncClient
  • EmsEngine_TseIfb_SyncClient
  • Order class
  • Lifecycle management

Roadmap

  • Auto session refresh
  • Smart retry system
  • Risk control module
  • Order batching
  • Metrics & Monitoring
  • Strategy framework

Contributing

We welcome contributions.

Guidelines:

  • Follow PEP8
  • Add tests
  • Update documentation
  • Submit Pull Requests

License

Licensed under Apache License 2.0.

See LICENSE file.


Support

GitHub Issues: https://github.com/hedgetech/hedgetech-sdk

Email: support@hedgetech.ir


© 2026 HedgeTech. All rights reserved.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hedgetech-0.2.2.tar.gz (43.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hedgetech-0.2.2-py3-none-any.whl (50.7 kB view details)

Uploaded Python 3

File details

Details for the file hedgetech-0.2.2.tar.gz.

File metadata

  • Download URL: hedgetech-0.2.2.tar.gz
  • Upload date:
  • Size: 43.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hedgetech-0.2.2.tar.gz
Algorithm Hash digest
SHA256 d2e0c545edf6bfde6c999ee7f428f559b9f273c27316921cac561781cfbd52ea
MD5 a6f006d6ce658d3f2dd9fb27f396b483
BLAKE2b-256 c57bdc9373b45ed2224354858e939edd5f2a6dd7034b45f3de07316191012032

See more details on using hashes here.

File details

Details for the file hedgetech-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: hedgetech-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 50.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hedgetech-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a2a9660baaab41b4172fbf41d54d5acf5373fc05ff1fbe1d2ea4ad9ec422e085
MD5 980f27de95035c5ccb85eadb7b5c9423
BLAKE2b-256 22e4046d6340e22d7a29a7a950b8eb2fd35597a5836d88bc9828b9d44377cc70

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page