{ "info": { "author": "Dainis Gorbunovs", "author_email": "dgdev@protonmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 2 - Pre-Alpha", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Topic :: Software Development :: Libraries :: Python Modules" ], "description": "# FreeTrade API\nThis is an attempt to make an unofficial Python package for [FreeTrade](https://freetrade.io).\nThere is no official API released, yet. FreeTrade is a zero-fee UK-regulated stockbroker.\n\n## What is supported\n* Find list of `tradable securities` with information on the asset class, market, currency, country.\n* Create a list of tickers for `Trading View`'s watch list. \n* `Historical prices`\n* Logging into Freetrade account and saving the session into `ft-session.json` file.\n\n## Install\nInstall through `pip` package manger:\n```bash\npip install freetrade\n```\n\nAlternatively, for developing this package:\n```bash\nconda create -n myenv python=3.7\nconda activate myenv\npip install -r requirements.txt\n```\n\n## Prerequisites\nBefore running this, it is necessary to set the API keys. Edit `ft-keys.json` to include the necessary API keys. \nThese keys can be found using a tool, which can extract StringCare secrets, e.g. [DeStringCare](https://github.com/DainisGorbunovs/DeStringCare).\n\n## API\n### Creating `ft` FreeTrade object\n#### Without authentication\n```python\nfrom freetrade import FreeTrade\n\nft = FreeTrade()\n```\nThe only thing which will work is `Index` class, i.e. getting the list of supported stock tickers.\n\n#### With authentication\n```python\nfrom freetrade import FreeTrade\n\nemail = '...' # Email to use for the login\nft = FreeTrade(email)\n```\n\nBy default when creating the object, it will try to load an older authenticated session from `ft-session.json` file.\nOtherwise it logs in again, and requests a one time password (OTP), which is sent to the email.\n\nThe code parses OTP from the standard user input. Alternatively specify `otp_parser` parameter in `FreeTrade` object\n to a function which can fetch the email and parse the OTP itself.\n\n### `Index` - no authentication needed\n#### Ticker history\nAssuming `ft` object is created, here is how one month of historical price for a stock.\n```python\nprices = ft.index.get_ticker_history('TSLA', 'XNAS')\n\nfor history_date, price in prices.items():\n print(f'{history_date}: ${price:.2f}')\n```\n\n#### Get assets\n```python\nassets = ft.index.get_assets()\n```\n\nReturns a dictionary of different categories, which have subcategories.\nThese subcategories contain a list of stock assets.\n* `currency`\n * `GBP` / `USD`: list of assets\n* `exchange`\n * `XLON` / `XNYS` / `XNAS`: list of assets\n* `asset_class`\n * `ETF` / `EQUITY` / `ADR`: list of assets\n* `country_of_incorporation`\n * `IE` / `GB` / `US` / `KY` / ... : list of assets\n* `all`: list of assets\n\nSample asset for an ETF `LSE:ERNU`:\n```json\n{\n \"asset_class\": \"ETF\",\n \"symbol\": \"ERNU\",\n \"isin\": \"IE00BCRY6227\",\n \"exchange\": \"XLON\",\n \"currency\": \"GBP\",\n \"country_of_incorporation\": \"IE\",\n \"long_title\": \"iShares $ Ultrashort Bond UCITS ETF (Dist.)\",\n \"short_title\": \"$ Ultrashort\",\n \"subtitle\": \"Very short maturity $ debt\",\n \"logo_4x\": \"//a.storyblok.com/f/41481/640x640/7ec0a292de/ishares-symbol-4x.png\",\n \"isa_eligible\": true,\n \"coming_soon\": false,\n \"required_version\": \"1.0\",\n \"objectID\": \"IE00BCRY6227\",\n ...\n}\n```\n\n#### Get tickers\n```python\ntickers = ft.index.get_tickers()\n```\n\nReturns a dictionary, where:\n* key is an exchange symbol FreeTrade uses, and\n* value is a list of ticker symbols \n\n```python\ntickers = {\n 'XLON': ['ERNU', 'III', '3IN', ...],\n 'XNYS': ['MMM', 'ABBV', 'BABA', ...],\n 'XNAS': ['ATVI', 'ADBE', 'AMD', 'GOOGL', 'AMZN', ...]\n}\n```\n\n#### Get list of tickers for Trading View watch list\n```python\ntickers_union = ft.index.get_tradingview_tickers(join_exchanges=True)\n```\n\nReturns a string formatted for importing into Trading View watch list.\n\nWith `join_exchanges = True`:\n```python\ntickers_union = 'LSE:ERNU,LSE:III,LSE:3IN,LSE:ABF,LSE:ACA,LSE:ADM,...'\n```\n\nDefault (when `join_exchanges = False`):\n```python\ntickers_union = {\n 'XLON': 'LSE:ERNU,LSE:III,LSE:3IN,LSE:ABF,LSE:ACA,LSE:ADM,...',\n 'XNYS': 'NYSE:MMM,NYSE:ABBV,NYSE:BABA,NYSE:AXP,NYSE:APA,NYSE:T,...',\n 'XNAS': 'NASDAQ:ATVI,NASDAQ:ADBE,NASDAQ:AMD,NASDAQ:GOOGL,NASDAQ:AMZN,...'\n}\n```\n\n### `API` - requires authentication\n#### Finding the address for a post code\n```python\npostcode = 'E15JL'\naddress = ft.api.get_address_by_postcode(postcode)\n```\n\nReturns a list of addresses, e.g. sample address:\n```json\n[{\n \"summaryline\": \"Freetrade, 68-80 Hanbury Street, London, Greater London, E1 5JL\",\n \"organisation\": \"Freetrade\",\n \"number\": \"68-80\",\n \"premise\": \"68-80\",\n \"street\": \"Hanbury Street\",\n \"posttown\": \"London\",\n \"county\": \"Greater London\",\n \"postcode\": \"E1 5JL\"\n}]\n```\n\n#### Verifying bank number\n```python\nbank = ft.api.validate_bank('308012', '15887060')\n```\n\nReturns a lot of information on the account number, e.g. sample values:\n```json\n{\n \"result\": \"VALID\",\n \"sortcode\": \"308012\",\n \"bicbank\": \"LOYDGB21\",\n \"bankname\": \"CITY OFFICE (308012)\",\n \"owningbank\": \"LLOYDS BANK PLC\",\n \"chapssrbicbank\": \"LOYDGB2L\",\n \"chapssrbicbr\": \"XXX\",\n ...\n}\n```\n\n### Get price history\n```python\ntesla = ft.api.get_ticker_history('TSLA', 'XNAS', duration='1m')\nnational_grid = ft.api.get_ticker_history('NG.', 'XLON', duration='1m')\n```\n\nThe possible duration values, where `1m` is default: \n* `5y`, `2y`, `1y`, `ytd`, `6m`, `3m`, `1m`, `1d`\n\nReturns an `OrderedDict` of data points `(date, adjusted closing price)` sorted by date in ascending order.\n\nSample output:\n```python\ntesla = OrderedDict([\n ('2019-04-04', 267.78),\n ('2019-04-05', 274.96),\n ('2019-04-08', 273.2),\n ('2019-04-09', 272.31),\n ('2019-04-10', 276.06),\n ...\n])\n``` \n\nNotes:\n* use `Quandl` for UK securities;\n* uses `IEXTrading` for other securities.\n\n### `DataStore` - requires authentication\n#### Download or update historical prices\n```python\nft.datastore.update_historical_prices()\n```\n\nSaves the adjusted historical closing prices for the assets into `history` directory. If it does not exist, it is created.\n\nThe file name is the ticker's symbol, and each the prices are saved in ascending order.\n\nSample in `history/TSLA.csv`:\n```csv\n2014-05-05,216.61\n2014-05-06,207.28\n2014-05-07,201.35\n2014-05-08,178.59\n2014-05-09,182.26\n2014-05-12,184.67\n2014-05-13,190.16\n...\n```\n\n#### Load the historical data as `pd.DataFrame`\nThis function loads the historical data from `history` directory.\n\nNote that some assets have missing prices as they were not traded during that day, thus they show up as `nan`.\n\n```python\ndf = ft.datastore.load_historical_data_as_dataframe()\nprint(df.head(), df.shape)\n```\n\n\nSample output:\n```text\n CSCO SVT ... WTB NXT\nDate ... \n2014-05-05 19.5875 1486.452691 ... 3650.414898 5184.507159\n2014-05-06 19.3870 1489.696450 ... 3659.383977 5137.446580\n2014-05-07 19.5150 1509.159006 ... 3645.033451 5094.307715\n2014-05-08 19.6413 1510.780885 ... 3677.322133 5082.542570\n2014-05-09 19.6430 1512.402765 ... 3676.425226 5070.777425\n\n[5 rows x 341 columns] (1305, 341)\n```\n\n## Anything else?\n* Feel free to make a `GitHub issue`, if you find any issues or have enhancement ideas.\n\n* `Pull requests` are welcome, if you have made improvements to this code.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/DainisGorbunovs/freetrade", "keywords": "Freetrade,API,stock", "license": "", "maintainer": "", "maintainer_email": "", "name": "freetrade", "package_url": "https://pypi.org/project/freetrade/", "platform": "", "project_url": "https://pypi.org/project/freetrade/", "project_urls": { "Homepage": "https://github.com/DainisGorbunovs/freetrade" }, "release_url": "https://pypi.org/project/freetrade/0.0.6/", "requires_dist": [ "requests", "pandas", "PyJWT", "python-dateutil" ], "requires_python": "", "summary": "API for Freetrade app", "version": "0.0.6" }, "last_serial": 5616125, "releases": { "0.0.2": [ { "comment_text": "", "digests": { "md5": "6666207a57d834c69e50a6df1f949b4b", "sha256": "d763faacff96483d5e2681520568d84edbd7fcefcc0ae210036b95ae949daf3a" }, "downloads": -1, "filename": "freetrade-0.0.2-py3-none-any.whl", "has_sig": false, "md5_digest": "6666207a57d834c69e50a6df1f949b4b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 5225, "upload_time": "2019-04-29T00:25:52", "url": "https://files.pythonhosted.org/packages/a2/db/72fc5b54ed0222e82c097fdced4798360d176cefcbf0e545ae3cdae4cabc/freetrade-0.0.2-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "658958662864217ad261611b9c1a401b", "sha256": "10381ebdf43b6bcb94befd210c03f1c8b260e2b28a8b4f3ad0b99e5577ddfc42" }, "downloads": -1, "filename": "freetrade-0.0.2.tar.gz", "has_sig": false, "md5_digest": "658958662864217ad261611b9c1a401b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 4355, "upload_time": "2019-04-29T00:25:56", "url": "https://files.pythonhosted.org/packages/3c/a6/3d52b0fce1566ed96e7816099c09b2bc32b250a46cbb30a0c6158d349392/freetrade-0.0.2.tar.gz" } ], "0.0.3": [ { "comment_text": "", "digests": { "md5": "36f682cf6843021584eadc5249902f56", "sha256": "8d966ef07d2fe70636aea6d6e625b34141afb4b22383aee3a1a9197f7f183c48" }, "downloads": -1, "filename": "freetrade-0.0.3-py3-none-any.whl", "has_sig": false, "md5_digest": "36f682cf6843021584eadc5249902f56", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 6642, "upload_time": "2019-05-04T17:17:18", "url": "https://files.pythonhosted.org/packages/48/85/ac25569f4b61eb823c89729f698c65da5265f77089575e346e0de8eac65e/freetrade-0.0.3-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "cb0cda9517fea58c8286fa20ce917752", "sha256": "ad2d960080566e9bbfc0ff6167669c915e7f0765620c66ae95680e666ecc90c3" }, "downloads": -1, "filename": "freetrade-0.0.3.tar.gz", "has_sig": false, "md5_digest": "cb0cda9517fea58c8286fa20ce917752", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5755, "upload_time": "2019-05-04T17:17:20", "url": "https://files.pythonhosted.org/packages/05/f3/e0c156fabc5192d6eb477a64c5fc5e5e3aa1c300946d2fcac20a8c050a34/freetrade-0.0.3.tar.gz" } ], "0.0.4": [ { "comment_text": "", "digests": { "md5": "9a62e7f039122e4d2a62fe168383bfd0", "sha256": "f3c245a9c5141b3e4f71eae27b914088d625c1e6ebec9ed7023901f3467d1af2" }, "downloads": -1, "filename": "freetrade-0.0.4-py3-none-any.whl", "has_sig": false, "md5_digest": "9a62e7f039122e4d2a62fe168383bfd0", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 7262, "upload_time": "2019-05-04T21:58:38", "url": "https://files.pythonhosted.org/packages/9d/83/70a51a4617a737b142caa1bdbd4d6ccfcbb7cd04b5ec310eb4cf1bf9c88b/freetrade-0.0.4-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "e330c908df3c78bf2c64ae1c7c606bbd", "sha256": "35e9e45f3e246ac30ee32b79b9b64bf2a85e8922cb6b4c157ebcbd17264691d4" }, "downloads": -1, "filename": "freetrade-0.0.4.tar.gz", "has_sig": false, "md5_digest": "e330c908df3c78bf2c64ae1c7c606bbd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6510, "upload_time": "2019-05-04T21:58:40", "url": "https://files.pythonhosted.org/packages/b7/bc/405032a9ef85e6210e4de259b675d5cf250e4e43654c334cafbeb06f0c23/freetrade-0.0.4.tar.gz" } ], "0.0.5": [ { "comment_text": "", "digests": { "md5": "712a4269dd332b8832dd138c3ce8aebc", "sha256": "043cadb833ceb1b761a0301825e7cf9bd910e8493a4281d42617929b26e6f30e" }, "downloads": -1, "filename": "freetrade-0.0.5-py3-none-any.whl", "has_sig": false, "md5_digest": "712a4269dd332b8832dd138c3ce8aebc", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10722, "upload_time": "2019-07-05T00:40:21", "url": "https://files.pythonhosted.org/packages/0a/1b/15d70b8939e284e384ebe245cbfaa3fadfbef7685105f0843920a76b0d63/freetrade-0.0.5-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5d438d526f4f56806991393d5fb0fe68", "sha256": "0f768f877c8be6f368693991b918a0f61f849aaa1884e3a36eb6b304eedfe27e" }, "downloads": -1, "filename": "freetrade-0.0.5.tar.gz", "has_sig": false, "md5_digest": "5d438d526f4f56806991393d5fb0fe68", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9643, "upload_time": "2019-07-05T00:40:24", "url": "https://files.pythonhosted.org/packages/bf/09/21ecd6bd595a9db2556a52b812f234862083b447d21be510cb448feafe29/freetrade-0.0.5.tar.gz" } ], "0.0.6": [ { "comment_text": "", "digests": { "md5": "213205a758b3411d020c70bf444f21d7", "sha256": "022bd9ebb5090478330eb5c410dd59910d5084b59122ae71e432dac128fedeaf" }, "downloads": -1, "filename": "freetrade-0.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "213205a758b3411d020c70bf444f21d7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12831, "upload_time": "2019-08-01T00:19:51", "url": "https://files.pythonhosted.org/packages/23/b2/455d3933e71ed13eadcc40372f176439afcbbbe185363ae926ca02082df6/freetrade-0.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5820b1f654246b2ce022f3ce8f17c570", "sha256": "ed65f0b9ac025d1f449fa565f5336fee21796f6732ad9f7a0b05c3c828fcba8a" }, "downloads": -1, "filename": "freetrade-0.0.6.tar.gz", "has_sig": false, "md5_digest": "5820b1f654246b2ce022f3ce8f17c570", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13420, "upload_time": "2019-08-01T00:19:53", "url": "https://files.pythonhosted.org/packages/dc/26/6b2790e1714b6303712da8536d0c3200332f93d051e889dc9537e15173d9/freetrade-0.0.6.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "213205a758b3411d020c70bf444f21d7", "sha256": "022bd9ebb5090478330eb5c410dd59910d5084b59122ae71e432dac128fedeaf" }, "downloads": -1, "filename": "freetrade-0.0.6-py3-none-any.whl", "has_sig": false, "md5_digest": "213205a758b3411d020c70bf444f21d7", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12831, "upload_time": "2019-08-01T00:19:51", "url": "https://files.pythonhosted.org/packages/23/b2/455d3933e71ed13eadcc40372f176439afcbbbe185363ae926ca02082df6/freetrade-0.0.6-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "5820b1f654246b2ce022f3ce8f17c570", "sha256": "ed65f0b9ac025d1f449fa565f5336fee21796f6732ad9f7a0b05c3c828fcba8a" }, "downloads": -1, "filename": "freetrade-0.0.6.tar.gz", "has_sig": false, "md5_digest": "5820b1f654246b2ce022f3ce8f17c570", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13420, "upload_time": "2019-08-01T00:19:53", "url": "https://files.pythonhosted.org/packages/dc/26/6b2790e1714b6303712da8536d0c3200332f93d051e889dc9537e15173d9/freetrade-0.0.6.tar.gz" } ] }