Python package for downloading Tehran Stock Exchange data and analysing
Project description
tse_dataloader
tse_dataloader is a python package for extracting stock historical data from Tehran Stock Exchange.
- Extract data and load them in
Pandasdata frame - Calculate SMA and EMA
- Create line charts with
matplotlib
Install:
pip install tse_dataloader
Functions:
- Loading data with get_data(ticker) or getcode_data(code)
>>> from tse_dataloader import download
>>> MELT= download.get_data('ظˆط¨ظ…ظ„طھ')
>>> print(MELT)
TICKER FIRST HIGH ... OPEN LAST date_shamsi
Date ...
2009-02-18 S*Mellat.Bank 1050.0 1050.0 ... 1000.0 1050.0 1387/11/30
2009-02-21 S*Mellat.Bank 1051.0 1076.0 ... 1050.0 1057.0 1387/12/03
2009-02-22 S*Mellat.Bank 1065.0 1074.0 ... 1050.0 1055.0 1387/12/04
2009-02-23 S*Mellat.Bank 1066.0 1067.0 ... 1065.0 1060.0 1387/12/05
2009-02-25 S*Mellat.Bank 1061.0 1064.0 ... 1061.0 1060.0 1387/12/07
... ... ... ... ... ... ... ...
2020-07-01 S*Mellat.Bank 27350.0 27370.0 ... 26110.0 26690.0 1399/04/11
2020-07-04 S*Mellat.Bank 26940.0 27000.0 ... 26940.0 25600.0 1399/04/14
2020-07-05 S*Mellat.Bank 24560.0 27040.0 ... 25760.0 25860.0 1399/04/15
2020-07-06 S*Mellat.Bank 26200.0 26950.0 ... 25670.0 26950.0 1399/04/16
2020-07-07 S*Mellat.Bank 27320.0 28200.0 ... 26860.0 26040.0 1399/04/17
[2374 rows x 12 columns]
>>> MELT= download.getcode_data(778253364357513)
- Plot Close price and Volume line chart with close_vol()
>>> from tse_dataloader import analysis
>>> analysis.close_vol(MELT)
# to create a chart without gaps you can use df.reset_index()
>>> analysis.close_vol(MELT.reset_index())
- Calculate short and long term Simple Moving Average, Exponential Moving Average, add them to your data frame and plot chart line with sma() and ema()
>>> from tse_dataloader import analysis
>>> analysis.sma(MELT, 20, 50)
>>> analysis.ema(MELT, 20, 50)
- For your convenience, I create a list of tickers and attached it to the package to load data faster. In order to update your symbol list, you can use stock_list.update(). it takes a few minutes to update data from tsetmc.
>>> import tse_dataloader
>>> stock_list.update()
Database has updated!
- In some cases, if you couldn't find your specific symbol in the list, you can add it to the list manually with the stock_list.add() function.
>>> import tse_dataloader
>>> stock_list.add(2400322364771558, 'ط´ط³طھط§')
Symbol added to the list!
You can find every symbol's code at the end of its URL:
http://www.tsetmc.com/loader.aspx?ParTree=151311&i=2400322364771558
Thanks to tehran-stock
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 tse_dataloader-0.1.2.tar.gz.
File metadata
- Download URL: tse_dataloader-0.1.2.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1efa16aebe17bdab545168ad39d4e81edce2dad4c4f887f672f916a6c22c3c8d
|
|
| MD5 |
f2026506490fb65c5d541114417f7685
|
|
| BLAKE2b-256 |
82ec84537be6228d25f8007b5c0e09393400d2e436a163160337fbdfd9616ab9
|
File details
Details for the file tse_dataloader-0.1.2-py3-none-any.whl.
File metadata
- Download URL: tse_dataloader-0.1.2-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.7.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8d7c8566f47dc342f32c786e3411ea50628190c91a4242b60d85a7868b60050d
|
|
| MD5 |
fdbe8cbbca35858f4c97c61dda83a402
|
|
| BLAKE2b-256 |
a248dab9c075ee0e06b8c3f6e8a5a1d7581ddb5838f1a2b21f61051fb2cfb1b0
|