fima
fima یک کتابخانه پایتون برای دریافت، ساختاردهی و تحلیل دادههای بازارهای مالی ایران است. این پروژه در حال توسعه است و دادهها را از سرویسهای آنلاین عمومی دریافت میکند؛ بنابراین تغییر یا قطعی منبع داده میتواند بر خروجی توابع اثر بگذارد.
نیازمندیها
- Python 3.10 یا جدیدتر
- دسترسی اینترنت برای توابعی که داده زنده یا تاریخی دریافت میکنند
نصب
py -m pip install fima
بهروزرسانی به آخرین نسخه:
py -m pip install --upgrade fima
نمایش نسخه نصبشده:
py -c "from importlib.metadata import version; print(version('fima'))"
ماژولهای عمومی
نسخه عمومی بسته شامل این ماژولها است:
fima.Options: دادهها و محاسبات اختیار معاملهfima.IFB: دادههای فرابورس ایران و ابزارهای تأمین مالیfima.IME: دادههای بورس کالای ایرانfima.TSETMC: دادههای نمادها، شاخصها، معاملات و سهامدارانfima.TSEInstitutions: فهرست نهادهای مالی
برای جلوگیری از واردشدن نامهای کمکی، از import صریح استفاده کنید و از import * استفاده نکنید.
نمونه استفاده
اختیار معامله
from fima.Options import download_chain_contracts, ticker_info
option_info = ticker_info(ticker="ضهرم4018")
chain = download_chain_contracts(
underlying_ticker="اهرم",
j_date=True,
bsm=False,
greeks=False,
implied_volatility=False,
)
دریافت سابقه نماد اختیار و دارایی پایه:
from fima.Options import download_historical_data
option_history, underlying_history = download_historical_data(
ticker="ضهرم4018",
start_date="1404-01-01",
end_date="1404-01-31",
)
محاسبات مستقل بلک–شولز–مرتون و Greeks:
from fima.Options import (
calculate_black_scholes_merton,
calculate_delta,
calculate_gamma,
calculate_rho,
calculate_theta,
calculate_vega,
)
price = calculate_black_scholes_merton(
s=550,
k=28000,
t=71 / 365,
sigma=0.9588,
r_f=0.3372,
option_type="Call",
)
فرابورس ایران
from fima.IFB import get_all_bonds_without_coupons, get_risk_free_rate
risk_free_rate = get_risk_free_rate()
bonds = get_all_bonds_without_coupons(deprecated=False)
بورس کالای ایران
from fima.IME import get_all_ime_physical_trades
physical_trades = get_all_ime_physical_trades(
start_date="1403-01-01",
end_date="1403-12-29",
)
TSETMC
from fima.TSETMC import get_ticker_historical_data, get_tickers
tickers = get_tickers(tse=True, ifb=True, details=False)
history = get_ticker_historical_data(ticker="فملی")
نهادهای مالی
from fima.TSEInstitutions import get_all_institutions
institutions = get_all_institutions()
API عمومی
fima.Options
ticker_infodownload_historical_datadownload_chain_contractsdownload_market_watchdownload_all_underlying_assetsblack_scholes_mertonget_greeksget_implied_volatilitycalculate_black_scholes_mertoncalculate_deltacalculate_gammacalculate_thetacalculate_vegacalculate_rho
fima.IFB
get_risk_free_rateget_all_bonds_without_couponsget_all_bonds_with_couponsget_ifb_equally_weighted_total_index_historical_dataget_ifb_equally_weighted_price_index_historical_dataget_ifb_price_index_historical_dataget_ifb_total_index_historical_dataget_ifb_total_sukuk_index_historical_dataget_sukuk_daily_trades_based_on_bsget_sukuk_daily_trades_based_on_ctget_all_crowdfunding_plansget_all_crowdfunding_platformsget_all_standard_financing_instrumentsget_all_special_financing_instrumentsget_ticker_info
fima.IME
get_all_ime_physical_tradesget_all_ime_futures_tradesget_all_ime_option_tradesget_all_physical_producer_productsget_producer_physical_tradesget_all_ime_export_tradesget_all_ime_cd_tradesget_all_export_producer_productsget_producer_export_tradesget_all_ime_salaf_tradesget_gold_and_silver_cd_trades
fima.TSETMC
get_share_changesget_price_adjustmentsget_supervision_listsget_ticker_historical_shareholdersget_ticker_historical_trades_client_typeget_ticker_historical_market_capsget_ticker_historical_dataget_ticker_intraday_tradesget_indexes_statusget_index_historical_dataget_index_last_intraday_dataget_index_companiesget_tickers
fima.TSEInstitutions
get_all_institutions
پارامترهایی که با _ شروع میشوند برای کنترل داخلی و آزمون هستند و بخشی از API پایدار عمومی محسوب نمیشوند.
توسعه و آزمون
py -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install --upgrade pip
python -m pip install --editable ".[test]"
python -m pytest -m "not integration"
python -m pytest
دستور اول آزمونهای قطعی و بدون شبکه را اجرا میکند. دستور دوم کل مجموعه، شامل آزمونهای اتصال به منابع زنده، را اجرا میکند.
بخش قابلتوجهی از آزمونها به سرویسهای آنلاین متصل میشوند. خطای شبکه یا تغییر API منبع داده باید از خطای منطقی کتابخانه تفکیک شود، اما انتشار نسخه در صورت شکست هر آزمون متوقف میشود.
پیوندها
مجوز
این پروژه تحت مجوز MIT منتشر میشود. متن کامل در فایل LICENSE قرار دارد.
تماس
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 fima-0.4.0.tar.gz.
File metadata
- Download URL: fima-0.4.0.tar.gz
- Upload date:
- Size: 33.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
deca8f291ecaec132057cf4f7074dbdfafb592d84e52942b094e00291b4d7875
|
|
| MD5 |
16870fb063688cc2a70bce9bf1d47cc3
|
|
| BLAKE2b-256 |
9c1bbaf7ec7eae064ad96c159bd4a1d0cabe8bdc897d2e14d48121d008f2c361
|
Provenance
The following attestation bundles were made for fima-0.4.0.tar.gz:
Publisher:
publish.yml on hemoboghosian/fima
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fima-0.4.0.tar.gz -
Subject digest:
deca8f291ecaec132057cf4f7074dbdfafb592d84e52942b094e00291b4d7875 - Sigstore transparency entry: 2143643754
- Sigstore integration time:
-
Permalink:
hemoboghosian/fima@c564d970affbd3d07c5de2b711de18fbf00dfde8 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/hemoboghosian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c564d970affbd3d07c5de2b711de18fbf00dfde8 -
Trigger Event:
release
-
Statement type:
File details
Details for the file fima-0.4.0-py3-none-any.whl.
File metadata
- Download URL: fima-0.4.0-py3-none-any.whl
- Upload date:
- Size: 32.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bee656273cb559550825fdb267af26fbed7bd33c845f88d07318d109341433ee
|
|
| MD5 |
ec2b050e18a5660129114b46acdb758b
|
|
| BLAKE2b-256 |
2ebfbea9f335dde9a2437c7057aa6e465a7072cf2569f630aa171e4e0c365a53
|
Provenance
The following attestation bundles were made for fima-0.4.0-py3-none-any.whl:
Publisher:
publish.yml on hemoboghosian/fima
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
fima-0.4.0-py3-none-any.whl -
Subject digest:
bee656273cb559550825fdb267af26fbed7bd33c845f88d07318d109341433ee - Sigstore transparency entry: 2143644206
- Sigstore integration time:
-
Permalink:
hemoboghosian/fima@c564d970affbd3d07c5de2b711de18fbf00dfde8 -
Branch / Tag:
refs/tags/v0.4.0 - Owner: https://github.com/hemoboghosian
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@c564d970affbd3d07c5de2b711de18fbf00dfde8 -
Trigger Event:
release
-
Statement type: