Skip to main content

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 Pandas data frame
  • Calculate SMA and EMA
  • Create line charts with matplotlib

Install:

pip install tse_dataloader

Functions:

  • Loading data with get_data(ticker)
>>> from tse_dataloader import download
>>> MELT= download.get_data('ظˆط¨ظ…ظ„طھ')
>>> MELT

	TICKER	FIRST	HIGH	LOW	CLOSE	VALUE	VOL	OPENINT	PER	OPEN	LAST	date_shamsi
Date												
2009-02-18	S*Mellat.Bank	1050.0	1050.0	1050.0	1050.0	347393807250	330851245	800	D	1000.0	1050.0	1387/11/30
2009-02-21	S*Mellat.Bank	1051.0	1076.0	1042.0	1050.0	352194689892	335334212	6457	D	1050.0	1057.0	1387/12/03
2009-02-22	S*Mellat.Bank	1065.0	1074.0	1055.0	1065.0	8981292784	8435464	603	D	1050.0	1055.0	1387/12/04
2009-02-23	S*Mellat.Bank	1066.0	1067.0	1059.0	1061.0	9090532333	8570222	937	D	1065.0	1060.0	1387/12/05
2009-02-25	S*Mellat.Bank	1061.0	1064.0	1050.0	1058.0	7863032258	7434309	616	D	1061.0	1060.0	1387/12/07
...	...	...	...	...	...	...	...	...	...	...	...	...
2020-06-30	S*Mellat.Bank	25900.0	26170.0	25000.0	26110.0	3841979105490	147166333	38097	D	24930.0	26170.0	1399/04/10
2020-07-01	S*Mellat.Bank	27350.0	27370.0	26500.0	26940.0	4531902777600	168219804	56583	D	26110.0	26690.0	1399/04/11
2020-07-04	S*Mellat.Bank	26940.0	27000.0	25600.0	25760.0	5958222319060	231283534	65195	D	26940.0	25600.0	1399/04/14
2020-07-05	S*Mellat.Bank	24560.0	27040.0	24480.0	25670.0	5766735541640	224649840	65488	D	25760.0	25860.0	1399/04/15
2020-07-06	S*Mellat.Bank	26200.0	26950.0	26200.0	26860.0	6812022224090	253566140	52045	D	25670.0	26950.0	1399/04/16
2377 rows أ— 12 columns
  • 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()
>>> 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


Download files

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

Source Distribution

tse_dataloader-0.1.1.tar.gz (5.3 kB view details)

Uploaded Source

Built Distribution

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

tse_dataloader-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file tse_dataloader-0.1.1.tar.gz.

File metadata

  • Download URL: tse_dataloader-0.1.1.tar.gz
  • Upload date:
  • Size: 5.3 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

Hashes for tse_dataloader-0.1.1.tar.gz
Algorithm Hash digest
SHA256 94934d28b28388f4e5bbe2d27de59c114bdb1fabd87d99b26984a10a7e8684a9
MD5 d24a9ac584ef6a0c7bb906c715acc411
BLAKE2b-256 f59bd3aa8ce657309c7cb96abe7951d16edb823b72b80a5e45fc8d806de47c0e

See more details on using hashes here.

File details

Details for the file tse_dataloader-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: tse_dataloader-0.1.1-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

Hashes for tse_dataloader-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 98a848a06c3cf03dfaf9344303f26a886ed273daa95fc4ae9af150201a089dbf
MD5 38e7abded4af4fd5b5a4f9efdec5f896
BLAKE2b-256 b8fe170bd52e881dbf98f2eaf57bc94c0be296f23955bb27839caed49e2b1fa2

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