Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tseopt

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tseopt

This library contains code for fetching and processing option data from the Tehran Stock Exchange using various public APIs.

  • 0.1.1
  • PyPI
  • Socket score

Maintainers
1

tseopt

This library contains code for fetching and processing option data from the Tehran Stock Exchange using various public APIs.


Requirements

1. Ensure Python version 3.12 or higher is installed

Check if Python is installed and available from the command line by running:

python3 --version # Unix/macOS

or

py --version # Windows

If you do not have Python, please install the latest 3.x version from python.org

2. Ensure you can run pip from the command line

python3 -m pip --version # Unix/macOS

or

py -m pip --version # Windows

If pip isn’t already installed, then first try to bootstrap it from the standard library:

python3 -m ensurepip --default-pip  # Unix/macOS

or

py -m ensurepip --default-pip # Windows

3. Ensure pip, setuptools, and wheel are up to date

python3 -m pip install --upgrade pip setuptools wheel # Unix/macOS

or

py -m pip install --upgrade pip setuptools wheel # Windows

Installation

Use the package manager pip to install tseopt.

pip install tseopt

Usage

For a better view of the output data, please refer to README.ipynb.

TSETMC Website API

Fetches all Bourse and FaraBours data (suitable for screening the total market).

from tseopt import get_all_options_data

entire_option_market_data = get_all_options_data()
print(entire_option_market_data.head(5))
print(entire_option_market_data.iloc[0])

Screen Market

import pandas as pd
from tseopt.use_case.screen_market import OptionMarket, convert_to_billion_toman

option_market = OptionMarket(entire_option_market_data=entire_option_market_data)

print(f"total_trade_value: {option_market.total_trade_value / 1e10:.0f} B Toman", end="\n\n")

most_trade_value_calls = pd.DataFrame(option_market.most_trade_value.get("call"))
most_trade_value_calls['ticker'] = most_trade_value_calls['ticker'].astype(str)
most_trade_value_calls["trades_value"] = convert_to_billion_toman(most_trade_value_calls["trades_value"])


most_trade_value_puts = pd.DataFrame(option_market.most_trade_value.get("put"))
most_trade_value_puts['ticker'] = most_trade_value_puts['ticker'].astype(str)
most_trade_value_puts["trades_value"] = convert_to_billion_toman(most_trade_value_puts["trades_value"])


most_trade_value_by_underlying_asset = pd.DataFrame(option_market.most_trade_value_by_underlying_asset)
most_trade_value_by_underlying_asset[["call", "put", "total"]] =convert_to_billion_toman(most_trade_value_by_underlying_asset[["call", "put", "total"]])


print(most_trade_value_calls)
print(most_trade_value_puts)
print(most_trade_value_by_underlying_asset)

Tadbir API

Provides low latency and more detailed data (such as initial margin and order book). This may be suitable for obtaining data for actual trading.

from tseopt import tadbir_api

isin_list = ["IRO9AHRM2501", "IROATVAF0621", "IRO9BMLT2771", "IRO9TAMN8991", "IRO9IKCO81M1"]

bulk_data = tadbir_api.get_last_bulk_data(isin_list=isin_list)
detail_data = tadbir_api.get_detail_data(isin_list[0])
symbol_info = detail_data.get("symbol_info")
order_book = pd.DataFrame(detail_data.get("order_book"))

print(bulk_data)

print(symbol_info)
print(order_book)

Mercantile Exchange

Fetches all data which mercantile exchange website provides.

from tseopt import make_a_mercantile_data_object


md = make_a_mercantile_data_object()
md.update_data(timeout=20)
print(md.gavahi[0])
print(md.sandoq[0])
print(md.salaf[0])
print(md.future[0])
print(md.markets_info[0])
print(md.cdc[0])
print(md.all_market)
print(md.future_date_time)

Technical Terms

English WordFarsi Translation
ua_tse_codeکد نماد دارایی پایه
ua_tickerنماد معاملاتی دارایی پایه
days_to_maturityروزهای باقی‌مانده تا سررسید
strike_priceقیمت اعمال
contract_sizeاندازه قرارداد
ua_close_priceقیمت پایانی دارایی پایه
ua_yesterday_priceقیمت روز گذشته دارایی پایه
begin_dateتاریخ شروع قرارداد
end_dateتاریخ سررسید قرارداد
tse_codeکد نماد آپشن
tickerنماد معاملاتی آپشن
trades_numتعداد معاملات آپشن
trades_volumeحجم معاملات آپشن
trades_valueارزش معاملات آپشن
last_priceآخرین قیمت آپشن
close_priceقیمت پایانی آپشن
yesterday_priceقیمت روز گذشته آپشن
open_positionsموقعیت‌های باز
yesterday_open_positionsموقعیت‌های باز روز گذشته
notional_valueارزش اسمی
bid_priceقیمت پیشنهادی خرید
bid_volumeحجم پیشنهادی خرید
ask_priceقیمت پیشنهادی فروش
ask_volumeحجم پیشنهادی فروش

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc