{"id":22647768,"url":"https://github.com/davidhintelmann/datareader_tmx","last_synced_at":"2026-02-14T05:35:08.621Z","repository":{"id":156030356,"uuid":"304792145","full_name":"davidhintelmann/Datareader_TMX","owner":"davidhintelmann","description":"Get Stock Option Prices from TMX (Montreal Exchange)","archived":false,"fork":false,"pushed_at":"2025-02-20T05:57:09.000Z","size":3204,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-11T12:12:18.154Z","etag":null,"topics":["montreal","options","python","tmx"],"latest_commit_sha":null,"homepage":"","language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidhintelmann.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-10-17T03:52:54.000Z","updated_at":"2024-09-28T20:19:24.000Z","dependencies_parsed_at":null,"dependency_job_id":"efc15cfb-8978-4786-b229-babefed23084","html_url":"https://github.com/davidhintelmann/Datareader_TMX","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/davidhintelmann/Datareader_TMX","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FDatareader_TMX","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FDatareader_TMX/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FDatareader_TMX/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FDatareader_TMX/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidhintelmann","download_url":"https://codeload.github.com/davidhintelmann/Datareader_TMX/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidhintelmann%2FDatareader_TMX/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29438609,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-14T05:24:35.651Z","status":"ssl_error","status_checked_at":"2026-02-14T05:24:34.830Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["montreal","options","python","tmx"],"created_at":"2024-12-09T07:34:33.225Z","updated_at":"2026-02-14T05:35:08.607Z","avatar_url":"https://github.com/davidhintelmann.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"If you are looking for the original repo please checkout `og` branch.\n\n# Montreal Exchange (TMX) \n\nThe [Montreal Exchange](https://www.m-x.ca/accueil_en.php) is the oldest exchange in Canada and has a very important history to Canada's economy. Taken from Wikipedia,  \n\n\u003eThe Montreal Exchange, formerly the Montreal Stock Exchange (MSE), is a derivatives exchange, located in Montreal, Quebec, Canada that trades futures contracts and options on equities, indices, currencies, ETFs, energy and interest rates. Since 1965, it has been located in the Tour de la Bourse (Stock Exchange Tower), Montreal's third-tallest building. It is owned by the Toronto-based TMX Group.\n\nThis README file is to showcase the functionality of this small web scraping module. It can be used to get options prices, both calls and puts for index and ETF options, equity options, currency options, and weekly options.\n\nThese prices are then displayed in a Pandas Dataframe for further analysis. This could include simple plots for visualizing the data or creating machine learning model or neural network to predict future prices. One could also use [Black-Scholes](https://en.wikipedia.org/wiki/Black–Scholes_model) model to gain further insight.\n\n---\n\n# Requirements  \n1. Python **3.11.5**\n2. Pandas **2.1.0** (older version will probably work)  \n3. Requests **2.31.0** (older version will probably work)  \n4. bs4 **4.12.2** (for BeautifulSoup)\n   - lxml **5.3.0** used with bs4 to process xml and html\n\n---\n\nWe start by showing a list of options available from [TMX](https://m-x.ca/nego_liste_en.php). There is one parameter for the function `get_list()` and it can take one of four stings:  \n\n'Index'/'ETF', 'Equity', 'Currency', or 'Weekly'.\n\nThe webpage looks like: ![Options list from Montreal Exchance (TMX)](img/a.png)  \n\n\n```python\nget_list('equity')\n```\n\n\n\n\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eName of underlying instrument\u003c/th\u003e\n      \u003cth\u003eOption symbol\u003c/th\u003e\n      \u003cth\u003eUnderlying symbol\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003eAecon Group Inc.\u003c/td\u003e\n      \u003ctd\u003eARE\u003c/td\u003e\n      \u003ctd\u003eARE\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003eAGF Management Ltd., Cl. B\u003c/td\u003e\n      \u003ctd\u003eAGF\u003c/td\u003e\n      \u003ctd\u003eAGF.B\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003eAgnico Eagle Mines Limited\u003c/td\u003e\n      \u003ctd\u003eAEM\u003c/td\u003e\n      \u003ctd\u003eAEM\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003eAir Canada\u003c/td\u003e\n      \u003ctd\u003eAC\u003c/td\u003e\n      \u003ctd\u003eAC\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003eAlamos Gold Inc.\u003c/td\u003e\n      \u003ctd\u003eAGI\u003c/td\u003e\n      \u003ctd\u003eAGI\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e...\u003c/th\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e264\u003c/th\u003e\n      \u003ctd\u003eWheaton Precious Metals Corp.\u003c/td\u003e\n      \u003ctd\u003eWPM\u003c/td\u003e\n      \u003ctd\u003eWPM\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e265\u003c/th\u003e\n      \u003ctd\u003eWhitecap Resources Inc.\u003c/td\u003e\n      \u003ctd\u003eWCP\u003c/td\u003e\n      \u003ctd\u003eWCP\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e266\u003c/th\u003e\n      \u003ctd\u003eWinpak Ltd.\u003c/td\u003e\n      \u003ctd\u003eWPK\u003c/td\u003e\n      \u003ctd\u003eWPK\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e267\u003c/th\u003e\n      \u003ctd\u003eWSP Global Inc.\u003c/td\u003e\n      \u003ctd\u003eWSP\u003c/td\u003e\n      \u003ctd\u003eWSP\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e268\u003c/th\u003e\n      \u003ctd\u003eYamana Gold Inc.\u003c/td\u003e\n      \u003ctd\u003eYRI\u003c/td\u003e\n      \u003ctd\u003eYRI\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003e269 rows × 3 columns\u003c/p\u003e\n\u003c/div\u003e\n\n\n\nThe above DataFrame that we get with `get_list('equity')` is from:\n![Equity Options list from Montreal Exchance (TMX)](img/b.png)  \n\nNow we can grab stock prices for Air Canada (ticker symbol AC) so we can compare them to the stock options:\n\n\n```python\nget_stock('AC')\n```\n\n\n\n\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eTICKER\u003c/th\u003e\n      \u003cth\u003eLast price\u003c/th\u003e\n      \u003cth\u003eNet change\u003c/th\u003e\n      \u003cth\u003eBid price\u003c/th\u003e\n      \u003cth\u003eAsk price\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003eAC\u003c/td\u003e\n      \u003ctd\u003e15.520\u003c/td\u003e\n      \u003ctd\u003e0.000\u003c/td\u003e\n      \u003ctd\u003e15.520\u003c/td\u003e\n      \u003ctd\u003e15.550\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\nWe can also input a list of stock symbols to get a Pandas DataFrame of said stocks:\n\n\n```python\nget_stock(['AC','ARE'])\n```\n\n\n\n\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eTICKER\u003c/th\u003e\n      \u003cth\u003eLast price\u003c/th\u003e\n      \u003cth\u003eNet change\u003c/th\u003e\n      \u003cth\u003eBid price\u003c/th\u003e\n      \u003cth\u003eAsk price\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003eAC\u003c/td\u003e\n      \u003ctd\u003e15.520\u003c/td\u003e\n      \u003ctd\u003e0.000\u003c/td\u003e\n      \u003ctd\u003e15.520\u003c/td\u003e\n      \u003ctd\u003e15.550\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003eARE\u003c/td\u003e\n      \u003ctd\u003e14.220\u003c/td\u003e\n      \u003ctd\u003e0.100\u003c/td\u003e\n      \u003ctd\u003e14.200\u003c/td\u003e\n      \u003ctd\u003e14.250\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\n\n\nFinally, we obtain the a Pandas Dataframe of TMX stock options for [Air Canada](https://m-x.ca/nego_cotes_en.php?symbol=AC*) which comes from:\n\n![Equity Options list from Montreal Exchance (TMX)](img/c.png) \n\n\n```python\nget('AC')\n```\n\n\n\n\n\u003cdiv\u003e\n\u003ctable border=\"1\" class=\"dataframe\"\u003e\n  \u003cthead\u003e\n    \u003ctr style=\"text-align: right;\"\u003e\n      \u003cth\u003e\u003c/th\u003e\n      \u003cth\u003eCall\u003c/th\u003e\n      \u003cth\u003eBid price\u003c/th\u003e\n      \u003cth\u003eAsk price\u003c/th\u003e\n      \u003cth\u003eLast price\u003c/th\u003e\n      \u003cth\u003eImpl. vol.\u003c/th\u003e\n      \u003cth\u003eOpen int.\u003c/th\u003e\n      \u003cth\u003eVol.\u003c/th\u003e\n      \u003cth\u003eStrike\u003c/th\u003e\n      \u003cth\u003ePut\u003c/th\u003e\n      \u003cth\u003eBid price_\u003c/th\u003e\n      \u003cth\u003eAsk price_\u003c/th\u003e\n      \u003cth\u003eLast price.1\u003c/th\u003e\n      \u003cth\u003eImpl. vol_\u003c/th\u003e\n      \u003cth\u003eOpen int_\u003c/th\u003e\n      \u003cth\u003eVol_\u003c/th\u003e\n    \u003c/tr\u003e\n  \u003c/thead\u003e\n  \u003ctbody\u003e\n    \u003ctr\u003e\n      \u003cth\u003e0\u003c/th\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e2.05\u003c/td\u003e\n      \u003ctd\u003e2.20\u003c/td\u003e\n      \u003ctd\u003e2.20\u003c/td\u003e\n      \u003ctd\u003e86.5%\u003c/td\u003e\n      \u003ctd\u003e10\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e13.5\u003c/td\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.01\u003c/td\u003e\n      \u003ctd\u003e0.12\u003c/td\u003e\n      \u003ctd\u003e0.12\u003c/td\u003e\n      \u003ctd\u003e75.8%\u003c/td\u003e\n      \u003ctd\u003e17\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e1\u003c/th\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e1.57\u003c/td\u003e\n      \u003ctd\u003e1.77\u003c/td\u003e\n      \u003ctd\u003e1.77\u003c/td\u003e\n      \u003ctd\u003e79.0%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e14.0\u003c/td\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.08\u003c/td\u003e\n      \u003ctd\u003e0.14\u003c/td\u003e\n      \u003ctd\u003e0.14\u003c/td\u003e\n      \u003ctd\u003e71.0%\u003c/td\u003e\n      \u003ctd\u003e30\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e2\u003c/th\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e1.12\u003c/td\u003e\n      \u003ctd\u003e1.24\u003c/td\u003e\n      \u003ctd\u003e1.24\u003c/td\u003e\n      \u003ctd\u003e62.5%\u003c/td\u003e\n      \u003ctd\u003e10\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e14.5\u003c/td\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.10\u003c/td\u003e\n      \u003ctd\u003e0.18\u003c/td\u003e\n      \u003ctd\u003e0.18\u003c/td\u003e\n      \u003ctd\u003e59.2%\u003c/td\u003e\n      \u003ctd\u003e23\u003c/td\u003e\n      \u003ctd\u003e10\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e3\u003c/th\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.73\u003c/td\u003e\n      \u003ctd\u003e0.84\u003c/td\u003e\n      \u003ctd\u003e0.84\u003c/td\u003e\n      \u003ctd\u003e57.0%\u003c/td\u003e\n      \u003ctd\u003e7\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e15.0\u003c/td\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.19\u003c/td\u003e\n      \u003ctd\u003e0.29\u003c/td\u003e\n      \u003ctd\u003e0.29\u003c/td\u003e\n      \u003ctd\u003e53.8%\u003c/td\u003e\n      \u003ctd\u003e57\u003c/td\u003e\n      \u003ctd\u003e7\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e4\u003c/th\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.44\u003c/td\u003e\n      \u003ctd\u003e0.54\u003c/td\u003e\n      \u003ctd\u003e0.54\u003c/td\u003e\n      \u003ctd\u003e56.0%\u003c/td\u003e\n      \u003ctd\u003e47\u003c/td\u003e\n      \u003ctd\u003e141\u003c/td\u003e\n      \u003ctd\u003e15.5\u003c/td\u003e\n      \u003ctd\u003eOct 23, 2020-W\u003c/td\u003e\n      \u003ctd\u003e0.37\u003c/td\u003e\n      \u003ctd\u003e0.53\u003c/td\u003e\n      \u003ctd\u003e0.53\u003c/td\u003e\n      \u003ctd\u003e53.7%\u003c/td\u003e\n      \u003ctd\u003e46\u003c/td\u003e\n      \u003ctd\u003e1\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e...\u003c/th\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n      \u003ctd\u003e...\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e153\u003c/th\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e3.55\u003c/td\u003e\n      \u003ctd\u003e7.35\u003c/td\u003e\n      \u003ctd\u003e7.35\u003c/td\u003e\n      \u003ctd\u003e76.4%\u003c/td\u003e\n      \u003ctd\u003e2\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e21.0\u003c/td\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e8.85\u003c/td\u003e\n      \u003ctd\u003e12.50\u003c/td\u003e\n      \u003ctd\u003e12.50\u003c/td\u003e\n      \u003ctd\u003e74.4%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e154\u003c/th\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e3.30\u003c/td\u003e\n      \u003ctd\u003e7.20\u003c/td\u003e\n      \u003ctd\u003e7.20\u003c/td\u003e\n      \u003ctd\u003e76.3%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e22.0\u003c/td\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e9.60\u003c/td\u003e\n      \u003ctd\u003e13.30\u003c/td\u003e\n      \u003ctd\u003e13.30\u003c/td\u003e\n      \u003ctd\u003e74.2%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e155\u003c/th\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e3.10\u003c/td\u003e\n      \u003ctd\u003e7.00\u003c/td\u003e\n      \u003ctd\u003e7.00\u003c/td\u003e\n      \u003ctd\u003e76.2%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e23.0\u003c/td\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e10.35\u003c/td\u003e\n      \u003ctd\u003e14.10\u003c/td\u003e\n      \u003ctd\u003e14.10\u003c/td\u003e\n      \u003ctd\u003e73.8%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e156\u003c/th\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e2.84\u003c/td\u003e\n      \u003ctd\u003e6.80\u003c/td\u003e\n      \u003ctd\u003e6.80\u003c/td\u003e\n      \u003ctd\u003e75.6%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e24.0\u003c/td\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e11.10\u003c/td\u003e\n      \u003ctd\u003e14.85\u003c/td\u003e\n      \u003ctd\u003e14.85\u003c/td\u003e\n      \u003ctd\u003e73.0%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n    \u003ctr\u003e\n      \u003cth\u003e157\u003c/th\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e3.15\u003c/td\u003e\n      \u003ctd\u003e5.00\u003c/td\u003e\n      \u003ctd\u003e5.00\u003c/td\u003e\n      \u003ctd\u003e69.3%\u003c/td\u003e\n      \u003ctd\u003e32\u003c/td\u003e\n      \u003ctd\u003e7\u003c/td\u003e\n      \u003ctd\u003e25.0\u003c/td\u003e\n      \u003ctd\u003eJan 20, 2023\u003c/td\u003e\n      \u003ctd\u003e11.90\u003c/td\u003e\n      \u003ctd\u003e15.75\u003c/td\u003e\n      \u003ctd\u003e15.75\u003c/td\u003e\n      \u003ctd\u003e73.3%\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n      \u003ctd\u003e0\u003c/td\u003e\n    \u003c/tr\u003e\n  \u003c/tbody\u003e\n\u003c/table\u003e\n\u003cp\u003e158 rows × 15 columns\u003c/p\u003e\n\u003c/div\u003e\n\n\n\n\n```python\nimport pandas as pd\nimport requests\nfrom bs4 import BeautifulSoup\n```\n\n\n```python\n\"\"\"\nGet a list of options from https://m-x.ca/nego_liste_en.php\nTMX website\n\nIndex and ETF options\nEquity options\nCurrency options\nWeekly options\n\"\"\"\ndef get_list(market=str) -\u003e pd.DataFrame:\n    tmx = \"https://m-x.ca/nego_liste_en.php\" # TMX website, where data is taken from\n    \n    #check that parameter is of type string\n    is_str1 = isinstance(market, str)\n    if not is_str1:\n        raise TypeError(\"market parameter must be of type string\")\n        \n    try:\n        market = market.lower()\n    except Exception as e:\n        print(e)\n    else:\n        if market == 'index' or market == 'etf':\n            market = 0\n        elif market == 'equity':\n            market = 1\n        elif market == 'currency':\n            market = 2\n        elif market == 'weekly':\n            market = 3\n        else:\n            raise Exception(\"Did not enter market type, choose from Index or ETF, Equity, Currency, Weekly.\")\n        df = pd.read_html(tmx)\n        return df[market]\n```\n\n\n```python\n\"\"\"\nGet options prices at predetermined dates from TMX website\nCall/Puts\nstrike price\nBid/Ask spreads\nopen interest\nimplied volatility\nvolume\n\"\"\"\ndef get(ticker_symbol=str) -\u003e pd.DataFrame:\n    tmx = \"https://m-x.ca/nego_cotes_en.php\" # TMX website, where data is taken from\n\n    is_str1 = isinstance(ticker_symbol, str)\n    if not is_str1:\n        raise TypeError(\"ticker_symbol parameter must be of type string\")\n        \n    try:\n        ticker_symbol = ticker_symbol.upper()\n    except Exception as e:\n        print(e)\n    else:\n        url = tmx + '?symbol=' + ticker_symbol + '*'\n        df = pd.read_html(url)\n        df[0].rename(columns={'Bid price.1':'Bid price_', 'Ask price.1':'Ask price_', 'Last Price.1':'Last Price_',\n                             'Impl. vol..1':'Impl. vol_', 'Open int..1':'Open int_', 'Vol..1':'Vol_'}, inplace=True)\n        return df[0].iloc[:-1] #do not include last row, rubbish information\n```\n\n\n```python\n\"\"\"\nGet stock price from TMX to compare to strike price\ncan accept string or list of strings\n\"\"\"\ndef get_stock(ticker_symbol=str) -\u003e pd.DataFrame:\n    tmx = \"https://m-x.ca/nego_cotes_en.php\" # TMX website, where data is taken from\n    \n    #check that parameter is of type string\n    is_str1 = checktype(ticker_symbol)\n    if not is_str1:\n        raise TypeError(\"market parameter must be of type string\")\n\n    #download stock price, remember it is 15 minutes delayed\n    try:\n        symbols = []\n        for n in ticker_symbol: \n            symbols.append(n.upper())\n\n    except Exception as e:\n        print(e)\n    else:\n        price_dict = {}\n        is_list = isinstance(ticker_symbol, list)\n        if is_list:\n            df_list = []\n            for m in symbols:\n                URL = tmx + '?symbol=' + m + '*'\n                response = requests.get(URL)\n                soup = BeautifulSoup(response.text, 'html.parser')\n                x = soup.find('div', class_ = 'quote-info', attrs = 'ul')\n                y = x.ul.text.split('\\n')[1:-2]\n                \n                price_dict['TICKER'] = m\n                for z in y:\n                    key, value = z.split(':')\n                    price_dict[key] = value\n                tmp_df = pd.DataFrame.from_dict(price_dict, orient='index').T\n                df_list.append(tmp_df)\n            return pd.concat(df_list, ignore_index=True)\n        else:\n            ticker_symbol = ticker_symbol.upper()\n            URL = tmx + '?symbol=' + ticker_symbol + '*'\n            response = requests.get(URL)\n            soup = BeautifulSoup(response.text, 'html.parser')\n            x = soup.find('div', class_ = 'quote-info', attrs = 'ul')\n            y = x.ul.text.split('\\n')[1:-2]\n\n            price_dict['TICKER'] = ticker_symbol\n            for z in y:\n                key, value = z.split(':')\n                price_dict[key] = value\n            tmp_df = pd.DataFrame.from_dict(price_dict, orient='index').T\n            return tmp_df\n            \n```\n\n\n```python\ndef checktype(obj):\n        return bool(obj) and all(isinstance(elem, str) for elem in obj)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhintelmann%2Fdatareader_tmx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidhintelmann%2Fdatareader_tmx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidhintelmann%2Fdatareader_tmx/lists"}