{"id":13683056,"url":"https://github.com/quantbelt/ib_fundamental","last_synced_at":"2026-01-08T08:53:24.109Z","repository":{"id":241360718,"uuid":"806518844","full_name":"quantbelt/ib_fundamental","owner":"quantbelt","description":" Interactive Brokers Fundamental data for humans","archived":false,"fork":false,"pushed_at":"2024-09-09T13:47:28.000Z","size":119,"stargazers_count":34,"open_issues_count":0,"forks_count":7,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-17T13:46:36.171Z","etag":null,"topics":["algorithmic-trading","factor-models","ibkr","python3","quant","tws-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/quantbelt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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}},"created_at":"2024-05-27T10:57:23.000Z","updated_at":"2024-10-16T19:41:20.000Z","dependencies_parsed_at":"2024-05-29T14:21:27.343Z","dependency_job_id":"1b8e5450-9e36-44f1-803b-5ad5cefe4c8c","html_url":"https://github.com/quantbelt/ib_fundamental","commit_stats":null,"previous_names":["quantbelt/ib_fundamental"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantbelt%2Fib_fundamental","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantbelt%2Fib_fundamental/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantbelt%2Fib_fundamental/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/quantbelt%2Fib_fundamental/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/quantbelt","download_url":"https://codeload.github.com/quantbelt/ib_fundamental/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224211907,"owners_count":17274342,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["algorithmic-trading","factor-models","ibkr","python3","quant","tws-api"],"created_at":"2024-08-02T13:01:58.817Z","updated_at":"2026-01-08T08:53:24.048Z","avatar_url":"https://github.com/quantbelt.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# IB Fundamental\n\nInteractive Brokers Fundamental data for humans.\n\nThis package will bring all fundamental data available through IBKR TWS API\ninto ready-to-use pandas data frames.\n\n## Installation\n\nYou can install ib_fundamental using pip\n\n```bash\npip install ib-fundamental\n```\n\n## Usage\n\nYou will need a TWS API port available\n\n```python\nimport ib_async\nfrom ib_fundamental import CompanyFinancials\n\n# ib_async.util.startLoop() # if you are in a notebook\n\n# connect to TWS API for ex on localhost:7497\nib = ib_async.IB().connect('localhost',7497)\n\n# create your company financials instance\naapl = CompanyFinancials(ib=ib,symbol=\"AAPL\")\n\n# or specify exchange and currency\n# aapl = CompanyFinancials(ib=ib,symbol=\"AAPL\",exchange='SMART',currency='USD)\n\n# get company info\naapl.company_information\n                        0\nticker               AAPL\ncompany_name    Apple Inc\ncik            0000320193\nexchange_code        NASD\nexchange           NASDAQ\nirs             942404110\n\n# Annual income statement, while aapl.income_quarter will pull the quarterly report\naapl.income_annual\n\n                                       map_item  2018-09-29  2019-09-28  2020-09-26  2021-09-25  2022-09-24  2023-09-30    statement_type\nline_id\n0                                        period      Annual      Annual      Annual      Annual      Annual      Annual  Income Statement\n1                                      end_date  2018-09-29  2019-09-28  2020-09-26  2021-09-25  2022-09-24  2023-09-30  Income Statement\n2                                   fiscal_year        2018        2019        2020        2021        2022        2023  Income Statement\n4                                      date_10Q                                                                          Income Statement\n5                                      date_10K  2018-11-05  2019-10-31  2020-10-30  2021-10-29  2022-10-28  2023-11-03  Income Statement\n100                                     Revenue    265595.0    260174.0    274515.0    365817.0    394328.0    383285.0  Income Statement\n310                               Total Revenue    265595.0    260174.0    274515.0    365817.0    394328.0    383285.0  Income Statement\n360                      Cost of Revenue, Total    163756.0    161782.0    169559.0    212981.0    223546.0    214137.0  Income Statement\n370                                Gross Profit    101839.0     98392.0    104956.0    152836.0    170782.0    169148.0  Income Statement\n550      Selling/General/Admin. Expenses, Total     16705.0     18245.0     19916.0     21973.0     25094.0     24932.0  Income Statement\n560                      Research \u0026 Development     14236.0     16217.0     18752.0     21914.0     26251.0     29915.0  Income Statement\n830                     Total Operating Expense    194697.0    196244.0    208227.0    256868.0    274891.0    268984.0  Income Statement\n840                            Operating Income     70898.0     63930.0     66288.0    108949.0    119437.0    114301.0  Income Statement\n911      Interest Inc.(Exp.),Net-Non-Op., Total      2446.0      1385.0       890.0       198.0      -106.0      -183.0  Income Statement\n1270                                 Other, Net      -441.0       422.0       -87.0        60.0      -228.0      -382.0  Income Statement\n1280                    Net Income Before Taxes     72903.0     65737.0     67091.0    109207.0    119103.0    113736.0  Income Statement\n1290                 Provision for Income Taxes     11872.0     10481.0      9680.0     14527.0     19300.0     16741.0  Income Statement\n1300                     Net Income After Taxes     61031.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1340             Net Income Before Extra. Items     61031.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1400                                 Net Income     59531.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1470      Income Available to Com Excl ExtraOrd     61031.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1480      Income Available to Com Incl ExtraOrd     59531.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1530                         Diluted Net Income     59531.0     55256.0     57411.0     94680.0     99803.0     96995.0  Income Statement\n1540            Diluted Weighted Average Shares   20000.436   18595.652   17528.214   16864.919   16325.819   15812.547  Income Statement\n1550       Diluted EPS Excluding ExtraOrd Items     3.05148     2.97145     3.27535     5.61402      6.1132     6.13405  Income Statement\n1570           DPS - Common Stock Primary Issue        0.68        0.75       0.795        0.85         0.9        0.94  Income Statement\n1770                     Diluted Normalized EPS     3.05148     2.97145     3.27535     5.61402      6.1132     6.13405  Income Statement\n\n# get earnings per share, appl.eps_ttm will pull trailing twelve months eps\naapl.eps_ttm\n\n           report_type period     eps\nas_of_date\n2017-06-30         TTM    12M   8.870\n2017-09-30         TTM    12M   9.270\n2017-12-31         TTM    12M   9.810\n2018-03-31         TTM    12M  10.460\n2018-06-30         TTM    12M  11.160\n2018-09-30         TTM    12M  12.010\n2018-12-31         TTM    12M  12.310\n2019-03-31         TTM    12M  12.020\n2019-06-30         TTM    12M  11.860\n2019-09-30         TTM    12M  11.970\n2019-12-31         TTM    12M  12.790\n2020-03-31         TTM    12M  12.900\n2020-06-30         TTM    12M   3.325\n2020-09-30         TTM    12M   3.310\n2020-12-31         TTM    12M   3.750\n2021-03-31         TTM    12M   4.510\n2021-06-30         TTM    12M   5.170\n2021-09-30         TTM    12M   5.670\n2021-12-31         TTM    12M   6.080\n2022-03-31         TTM    12M   6.210\n2022-06-30         TTM    12M   6.110\n2022-09-30         TTM    12M   6.150\n2022-12-31         TTM    12M   5.930\n2023-03-31         TTM    12M   5.920\n2023-06-30         TTM    12M   5.980\n2023-09-30         TTM    12M   6.160\n2023-12-31         TTM    12M   6.460\n2024-03-31         TTM    12M   6.460\n\n# get data in json format\n\nfrom ib_fundamental.utils import to_json\n\n# CompanyFinancials.data property contains all data in dataclass format\nto_json(aapl.data.eps_ttm)\n'[{\"as_of_date\": \"2024-03-31T00:00:00\", \"report_type\": \"TTM\", \"period\": \"12M\", \"eps\": 6.46}, {\"as_of_date\": \"2023-12-31T00:00:00\", \"report_type\": \"TTM\", \"period\": \"12M\", \"eps\": 6.46}, ...'\n\n# and much more\n```\n\n## What fundamental data is available?\n\n`ib_fundamental` is a wrapper around IBKR TWS API. It will connect to a running TWS or\nibgateway instance and request fundamental data through\n[reqFundamentalData][reqFundamental] method and ticker `258`. TWS API will return a set of XML\nfiles with all the fundamental data. `ib_fundamental` will parse and transform\nall those XMLs into python dataclasses and pandas data frames.\n\nAvailable data includes:\n\n- Financial Statements\n  - Balance sheet, annual/quarter\n  - Income Statement, annual/quarter\n  - Cash flow, annual/quarter\n- Financial ratios\n  - earnings per share, quarterly and trailing twelve months (ttm)\n  - revenue, quarterly and trailing twelve months(ttm)\n  - dividends and dividends per share,  quarterly and trailing twelve months(ttm)\n  - financial ratios like ROE, ROC, EV, BVPS, CSHPS, etc\n  - full list of [financial ratios][fin_ratios]\n  - analyst forecast\n  - forward year estimates and actuals\n- Company ownership\n\nThis is the full list of methods of `CompanyFinancials` class\n\n- analyst_forecast\n- balance_annual\n- balance_quarter\n- cashflow_annual\n- cashflow_quarter\n- company_information\n- dividends\n- dividends_ps_q\n- dividends_ps_ttm\n- eps_q\n- eps_ttm\n- fundamental_ratios\n- fy_actuals\n- fy_estimates\n- income_annual\n- income_quarter\n- ownership\n- ratios\n- revenue_q\n- revenue_tt\n\nYou can use `FundamentalData` class that will return company fundamental\ninformation in `dataclass` format. Each instance of `CompanyFinancials`\ncontains an instance of `FundamentalData` in its `data` property.\n\n```python\nfrom ib_fundamental.fundamental import FundamentalData\n\n[_m for _m in dir(FundamentalData) if _m[:1] != \"_\"]\n\n['analyst_forecast',\n 'balance_annual',\n 'balance_quarter',\n 'cashflow_annual',\n 'cashflow_quarter',\n 'company_info',\n 'div_ps_q',\n 'div_ps_ttm',\n 'dividend',\n 'dividend_summary',\n 'eps_q',\n 'eps_ttm',\n 'fundamental_ratios',\n 'fy_actuals',\n 'fy_estimates',\n 'income_annual',\n 'income_quarter',\n 'ownership_report',\n 'ratios',\n 'revenue_q',\n 'revenue_ttm']\n\n# get quarterly revenue\naapl.data.revenue_q\n\n[Revenue(as_of_date=datetime.datetime(2024, 3, 31, 0, 0), report_type='R', period='3M', revenue=90753000000.0),\n Revenue(as_of_date=datetime.datetime(2023, 12, 31, 0, 0), report_type='R', period='3M', revenue=119575000000.0),\n Revenue(as_of_date=datetime.datetime(2023, 9, 30, 0, 0), report_type='R', period='3M', revenue=89498000000.0),\n Revenue(as_of_date=datetime.datetime(2023, 6, 30, 0, 0), report_type='R', period='3M', revenue=81797000000.0),\n Revenue(as_of_date=datetime.datetime(2023, 3, 31, 0, 0), report_type='R', period='3M', revenue=94836000000.0),\n Revenue(as_of_date=datetime.datetime(2022, 12, 31, 0, 0), report_type='R', period='3M', revenue=117154000000.0),\n Revenue(as_of_date=datetime.datetime(2022, 9, 30, 0, 0), report_type='R', period='3M', revenue=90146000000.0),\n Revenue(as_of_date=datetime.datetime(2022, 6, 30, 0, 0), report_type='R', period='3M', revenue=82959000000.0),\n Revenue(as_of_date=datetime.datetime(2022, 3, 31, 0, 0), report_type='R', period='3M', revenue=97278000000.0),\n Revenue(as_of_date=datetime.datetime(2021, 12, 31, 0, 0), report_type='R', period='3M', revenue=123945000000.0),\n Revenue(as_of_date=datetime.datetime(2021, 9, 30, 0, 0), report_type='R', period='3M', revenue=83360000000.0),\n Revenue(as_of_date=datetime.datetime(2021, 6, 30, 0, 0), report_type='R', period='3M', revenue=81434000000.0),\n Revenue(as_of_date=datetime.datetime(2021, 3, 31, 0, 0), report_type='R', period='3M', revenue=89584000000.0),\n Revenue(as_of_date=datetime.datetime(2020, 12, 31, 0, 0), report_type='R', period='3M', revenue=111439000000.0),\n Revenue(as_of_date=datetime.datetime(2020, 9, 30, 0, 0), report_type='R', period='3M', revenue=64698000000.0),\n Revenue(as_of_date=datetime.datetime(2020, 6, 30, 0, 0), report_type='R', period='3M', revenue=59685000000.0),\n Revenue(as_of_date=datetime.datetime(2020, 3, 31, 0, 0), report_type='R', period='3M', revenue=58313000000.0),\n Revenue(as_of_date=datetime.datetime(2019, 12, 31, 0, 0), report_type='R', period='3M', revenue=91819000000.0),\n Revenue(as_of_date=datetime.datetime(2019, 9, 30, 0, 0), report_type='R', period='3M', revenue=64040000000.0),\n Revenue(as_of_date=datetime.datetime(2019, 6, 30, 0, 0), report_type='R', period='3M', revenue=53809000000.0),\n Revenue(as_of_date=datetime.datetime(2019, 3, 31, 0, 0), report_type='R', period='3M', revenue=58015000000.0),\n Revenue(as_of_date=datetime.datetime(2018, 12, 31, 0, 0), report_type='R', period='3M', revenue=84310000000.0),\n Revenue(as_of_date=datetime.datetime(2018, 9, 30, 0, 0), report_type='R', period='3M', revenue=62900000000.0),\n Revenue(as_of_date=datetime.datetime(2018, 6, 30, 0, 0), report_type='R', period='3M', revenue=53265000000.0),\n Revenue(as_of_date=datetime.datetime(2018, 3, 31, 0, 0), report_type='R', period='3M', revenue=61137000000.0),\n Revenue(as_of_date=datetime.datetime(2017, 12, 31, 0, 0), report_type='R', period='3M', revenue=88293000000.0),\n Revenue(as_of_date=datetime.datetime(2017, 9, 30, 0, 0), report_type='R', period='3M', revenue=52579000000.0),\n Revenue(as_of_date=datetime.datetime(2017, 6, 30, 0, 0), report_type='R', period='3M', revenue=45408000000.0)]\n\n````\n\n## Contributing\n\nIf you find a bug please open an issue, pull requests are always welcome.\n\nTo develop with `ib_fundamental` please follow these steps\n\n```bash\ngit clone https://github.com/quantbelt/ib_fundamental.git\ncd ib_fundamental\n# install development dependencies\npip install .[dev]\n# do your things\n# run linters and code quality checks\npre-commit\n# run tests with tox, requires pypy310,py{310,311,312}\ntox\n```\n\n[reqFundamental]: https://ib-api-reloaded.github.io/ib_async/api.html#ib_async.ib.IB.reqFundamentalData\n[fin_ratios]: http://web.archive.org/web/20200725010343/https://interactivebrokers.github.io/tws-api/fundamental_ratios_tags.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantbelt%2Fib_fundamental","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fquantbelt%2Fib_fundamental","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fquantbelt%2Fib_fundamental/lists"}