Files
OpenBB/openbb_terminal/reports/templates/equity.ipynb
Theodore Aptekarev 8b95d19b43 OpenBB Platform v4 (#5225)
* change location

* check something

* add cache

* fixed auth w/@IgorWounds and @montezdesousa

* fixes for econometrics

* include Darren auth suggestions

* some routers included if dev + chg hub backend var

* coverage router should not be here

* update docker readme

* forgot to check auth here

* Change extension imports

* update docstrings and readme

* headers function wasnt being called, just referenced

* relative import

* econometrics add headers everywhere

* Fix QA

* Fix TA

* Fix test

* Fix python interface QA and TA

* Lint

* Cleanup

* Change path

* make the changes and some etf models

* tests for command_runner

* ruff

* solving naming issues on pytest

* Update some docstrings, fix typos and lint

* solving econometrics instantiating wrong openbb

* chaging the way pytest runs

* messing around with the imports

* ruff

* Change template to add platform considerations (#5533)

* change template to add platform considerations

* @the-praxs suggestions

* solving __pycache__ issue

* removing typo

* ci yml

* making linters happy (i guess)

* Improve Omega Ratio and docstrings

* chaging pro validation hash

* ruff

* Fix OLS Summary and lint

* Add OECD Provider for economy extension (#5534)

* Add record to docs

* update a couple of cboe models

* Fix econometrics bugs. Make tests pass. Lint.

* black

* ruff

* pydantic v2: remove deprecated Extra

* pydantic v2: self.dict -> self.model_dump

* revert pydantic

* revert the revert

* try 1: pin urllib3 < 2

* Revert "try 1: pin urllib3 < 2"

This reverts commit 3736c311cb.

* Revert dep

* Fix

* re-lock

* Skip all tests when doing cspell in pre-commit

* Resolve linter errors

* Add OECD to install script

* Add OECD

* Resolve more linter errors

* Exclude static files of v4 python from ruff

* More linting

* Another attempt to resolve even more linting errors

* Change how Literal is used

* ticker. symbol. consistent. @piiq

* change ticker field in Stock Search to is_symbol

* Update Cboe model for stocks_search -> is_symbol parameter.

* Fix issue

* Lint

* Small QA to rename SDK to Platform (#5544)

* SDK -> Platform in docs

* renamed in core

* renamed in openbb `init`

* `sdk` variable renamed as `platform`

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>

* `validator` -> `field_validator` in standard models

* Standard convention for multi-ticker symbols  (#5549)

* standardize symbol input param in forex and crypto historical data

* static

* linting

* Fix stock_search integration test params

* Update dependencies and linting on the CI (#5550)

* Remove ruff and black from platform dependencies

* Update codespell configuration

* Lint python code

* Add toml and tomli to root dev dependencies

* Update requirements.txt files

* Fix buggy docstring in python package methods (#5548)

* fix buggy docstring for methods

* remove space

* fix typing

* avoid name collision with validator

* Revert "avoid name collision with validator"

This reverts commit 8a30a44555.

* typing

* rebuild

* python 3.8, ParamSpec not available

* lint

* ruff noqa

* Merge with develop (#5551)

* Charting extension integration tests (#5547)

* initial proposal for integration tests on the charting extension

* int tests for charting generation

* python generator

* ruff

* boilerplate templates

* python tests

* tests for the api

* using body instead so data don't get redefined

* unit tests for coverage

* ruff

* docstrings

* unnecessary access to keys()

* Add trading economics economic calendar

* dev install

* Data Models disposition on the website (#5538)

* pydantic v4

* flat structure

* md files

* Revert "md files"

This reverts commit bd2170e2ad.

* improve command descriptions

* nice title and description

* human readble data model names on left panel

* implementation details section

* content markdown files

* markdown versioned files

* showcase page

* updates

---------

Co-authored-by: tehcoderer <me@tehcoderer.com>

* everything except tests

* fix `datetime.date` import in fetcher test

* modified url to remove `api_key` placeholder

* record test

* api key is called c here

* fixed fetcher test for api key

* recorded tests

* refactor

* life is ruff

* codespell

* Make Intrinio options chains great again (#5540)

* add multithreading

* cleanup

* linting

* use dateutil.parser

* removed `TICKER_EXCEPTIONS`

* modified `date` and `type` fields in standard model

* set alias for `date` and `type` to match standards

* static

* static

* Hotfix/fix post tests (#5555)

* Fix econometrics

* Fix ta

* Fix qa. Remove intrinio to not be rate limited

* Lint

* Fix typo

* obbject tests (#5558)

* obbject tests

* ruff

* fix dev_install

* fix unittests

* black on nox

* black on nox

* nox

* fix fetcher test so it can compare dates

* fix intrinio tests

* ruff

* change to model_dum() instead (#5561)

* Passing tests (#5560)

* Passing tests

* fix options

* Fix most tests and bugs

* fix forex missing params

* make symbol upper in polygon fx pairs

* fix fixedincome integration tests (#5564)

* Fixing charting api integration tests (#5562)

* fixing charting api integration tests

* black

* fix stocks less five API fails

* fix the 5 failing stocks integration tests

* recapture fmp stock news unit test

* fix fmp forex api test

* couple more forex integration fixes

* changing the request to always use the legacy session. @jmaslek this is was broken for 3.8 and 3.9; with this change apparently all versions work - lemme know if you see any issue with this change

* ruff

* fix ta

* add missing param

* fix testers for the api

* fix globalnews to use images instead of image

* remove unncessary pandas import

* econcal int tests

* update gitignore

* fix get_querystring to support lists

* add missing parameters

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt>

* Stock Historical standardization and UX improvements (#5457)

* polygon add interval standard param

* attempt at standardization

* Alpha Vantage params standardization

* rename `get_intervals` and fixed bug for extracting wrong value

* missed changing it in `extract_data`

* linting

* polygon cleanup

* modified `start_date` & `end_date` type to `datetime` from `dateType`

* standardized intrinio stock historical params

* fixed yfinance

* linting

* revert start and end date to dateType from datetime

* fix alpha vantage

* changed param

* fix intrinio infinite loop

* `validator` is `field_validator`

* revert time params and fixed intervals

* `outputsize` alias set in `Field`

* set interval description using in-build dict

* yfinance stock param standardization

* static

* intrinio cleanup

* Polygon add api params as `PrivateAttr`

* modified yfinance params to `PrivateAttr`

* intrinio remove overriding date params

* fixed description for AV adjusted param

* fix alpha vantage intraday not working

* re-record and pass unit tests

* pass integration tests

* Update test

---------

Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>

* Fix econcal endpoint (#5567)

* fix econcal for python interface

* fix econcal tests

* fix non supported json output

* Fixes FMP index endpoint to get 1 day interval data (#5535)

* fix FMP endpoint for getting index data for `1day` interval

* fix `open` type to prevent validation error

* modifed `validator` to `field_validator`

* type of fields is `StrictFloat`

* re-record and pass test

* linting

* `validator` -> `field_validator`, a3'd everything

* Fix regression in tests. Lint

* updating the integration test actions

* Fix typo

* Fix typo

* Fix import

* Publish versions `a3` to Pypi (#5568)

* bump versions and script to publish

* small improvements

* uncomment exception

* openbb

* publishing guidelines

* improve docs

* add providers to economy api

* make symbol required in stock_quote

* Fix keys

* Fix oecd

* add comma

* revert

* Add quotes

* Sleep

* Improve tests

* Improve

* Feature/query transform (#5566)

* inject query into transform_data

* swap query and data

* update missing fetchers

* last test failing

* sig test fetcher

* black

* av add `query` to `transform_data` call

* transform_data: missing refactoring

* fix uvicorn command in the doc

* Automated examples (#5576)

* Automated examples

* Fix bug

* Lint

* static assets built on 3.8

* Revert "static assets built on 3.8"

This reverts commit fb82ff7bd9.

* remove assets

* static assets on 3.8

* static assets on 3.8

* Wrap in quotes

* Improve wrap

* minor fix

* rebuild 3.8

* Fix bug

* Fix edge case

* Lint

* rebuild

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>

* use SecretStr for sensitive fields (#5578)

* use SecretStr for sensitive fields

* fix

* docstring

* Add tests for provider (#5583)

* Add tests for provider

* Test standard models

* Lint

* Fix standard model issues.

Co-authored-by: @the-praxs

* linting

* `symbol` -> `is_symbol` in `economy.index_search`

* static

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>

* feature/v4-biztoc-provider: Adds Biztoc provider and GlobalNews (#5546)

* add biztoc provider

* duplicate field

* black

* request headers

* recapture test

* move stuff around

* add integration tests

* duplicate OECD entry in dev_install

* duplicate entry for oecd in pyproject.toml

* Add Biztoc to workflow

* update readme: credentials

* Add Preferences to README

* improve tests

* fix biztoc

* obbject pylint

* Bug fix: serializ SecretStr before dumping to json

* export credentials as json (#5592)

* Check for wrong, changed, or outdated params. (#5597)

* Improving `economy.cpi` for the FRED data (#5602)

* remove multiindex using coding magic

* Update field descriptions

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Improve error message.

* Improve

* Test tests (#5607)

* Test tests

* Add test

* 4.0.0a4 PyPI publishing (#5608)

* changes to publish

* fix mini conflict

* typo

* cleaned `descriptions.py`

* fix description in `cpi.py`

* Add ETF extension to v4 (#5609)

* Add etf extension with search data model

* Add FMP ETF search

* Add fetcher tests

* Add ETF historical price from yfinance (#5610)

* Add etf extension with search data model

* Add FMP ETF search

* Add fetcher tests

* Add etf historical price standard model and route

* Add etf historical data from yfinance

* Add unit tests

* Fix linter error. Organize imports

* Update test data

* Revert common descriptions erased by CPI PR

* remove `symbol` from data for `stocks.ca.peers`

* Test docstrings (#5613)

* Test docstrings

* fix minor bugs w/@IgorWounds

* static only w/@IgorWounds

* fix `importance` param in `economy.econcal`

* right static only w/@IgorWounds

* Fix econcal and add tests to noxfile

* fix econcal static

* re-record

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>

* Clean up the newly created ETF extension (#5611)

* Add ETF to dev_install bundle

* Add integration tests for openbb-etf

* Patch integration test generator scripts to produce lintable code

* Add py.typed markers for extensions

* user preferences descriptions (#5593)

* user preferences descriptions

* typo

* Feature/v4-sec-provider: Add SEC provider to V4 (#5556)

* coerce string type, add default=None

* add sec provider and FTD function

* update description

* ruff

* data model definitions in standard model already

* duplicate oecd entries in dev_install and pyproject

* actually commit

* integration test

* add stock search to SEC

* add company filings for SEC provider

* integration tests

* remove duplicated line

* ruff

* **kwargs in Transform Data

* some helper functions for later

* black

* add helper for mutual fund and etf lookup

* add some SEC lookup helpers to a new regulators extension

* black

* ruff

* fix test param

* take institution filter out of sec stock_search

* ruff

* remove URL that codespell doesn't like

* add cik-to-ticker map

* add litigations rss feed

* make openbb-regulators a dependency of openbb-sec

* add SIC search

* improve ftd and remove BeautifulSoup from SEC dependencies

* fix parsing the zip files pre-2009

* ruff

* update descriptions

* recapture ftd test

* tests params

* typo

* change limit param to 1 in test_sec_stock_ftd

* Add didiers to_records method (#5588)

* Add didiers to_records

* unused import

* Bring back polars + do what igor suggested

* Make the output consistent with what it was.

* Black ?

* spelling.  oops.  almost like we have a pre commit or something

* Feature/v4-price-performance: % returns for various horizons, comparable across multiple tickers. (#5618)

* coerce string type, add default=None

* add price_performance endpoint from FMP

* black

* extra period in docstring

* ruff

* forgot one file

* Feature/ipo-calendar: V4 IPO Calendar (#5605)

* coerce string type, add default=None

* add intrinio ipo calendar

* fix typo

* sort __init__

* fix description

* make requested changes

* update test params

* black

* test updates

* etf integration

* Add disc router and WSJ provider

* OBBject extensions (#5612)

* changes to core

* bug?

* docstring

* doc

* Update credentials.py

* fix model_dump

* create extensions

* fix docstring

* doc

* revert change query_exc

* doc

* fix container test

* redirect obbject test patch

* doc

* rename method

* move decorator to extension file

* rename method extend_obbject

* changes in creds model

* avoid credential racing

* doc

* rename prop

* doc

* doc

* remove comment

* comment some code

* free extension names

* docstring

* doc

* docs

* Hotfix/fix-v4-economic-calendar: Add FMP to Econ Calendar and fix some TE bugs (#5580)

* coerce string type, add default=None

* adds fmp to economic calendar and fixes some things with TE

* ruff

* etf integration test

* missing provider for test

* rename te cassette to economic_calendar

* fix test

* rename tests

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>

* Add stocks disc endpoints (#5630)

* Add stocks disc endpoints

* Explicit

* Lint

* Add tests

* Bump timeout

* Feature/disc router (#5616)

* Add disc router and WSJ provider

* Lint

* Lint

* Move endpoints under ETF router

* Update etf_performance.py

* Add ETF info and sector exposure from FMP (#5620)

* Add ETF info from FMP

* Add integration tests

* Add unit tests

* Add etf sectors endpoint

* Add etf sectors fmp endpoint

* Omit nested sector list from fmp info data

* Update tests and test data

* Update test data

* Specify provider explicitly in integration tests

* Update tests

* Skip yfinance etf historical test

* Fix linter errors after the merge

* Fix more linter errors

* Fix failing and add missing tests

* Fix integration tests

* Fix calendar ipo tests

* Add ETF holdings and holding report dates from FMP (#5629)

* Add ETF info from FMP

* Add integration tests

* Add unit tests

* Add etf sectors endpoint

* Add etf sectors fmp endpoint

* Omit nested sector list from fmp info data

* Update tests and test data

* Update test data

* Specify provider explicitly in integration tests

* Update tests

* Skip yfinance etf historical test

* Add etf holdings and holdings date routes and standard models

* Add fmp holdings and holding dates fetchers

* Update holdings fetcher to properly handle date object inputs

* Add unit tests

* Add integration tests

* Black after merge

* Fix test input data format

* Disc router for equities. (#5640)

* Disc router for equities.

* add tests

* Bug fixes in financial statements (#5537)

* `validator` to `field_validator` in standard models

* Polygon add `ttm` to `period` param

* Revert "Polygon add `ttm` to `period` param"

* Polygon add `ttm` to param `period`

* `EarningsCallTranscript` standard model removed `quarter` param

* use `tag` instead of `name` for correct field name

* fix url for intrinio income statement

* modified intrinio cash flow `transform_data` function

* set optional data fields and validate dates

* fix insider trading not fetching recent data

* linting

* refactoring

* refactoring

* set param alias in fmp stock insider provider model

* get all quarter data for intrinio

* add `limit` param to `stocks.fa.ins`

* refactoring and linting

* removed additional comment

* linting

* re-recorded and fix tests

* cash flow standard model field type to `StrictFloat`

* Intrinio cash flow model fixed to get all quarters' data

* linting

* refactoring

* financial statement standard model field type to `StrictFloat`

* Intrinio financial statement model get all quarter data

* set `period` type to `Optional[str]`

* add `period` param to balance sheet provider models

* add `period` param to cash flow provider models

* use alias in model dump

* remove `ttm` from `period` param

* revamped intrinio financials

* fixed incorrect description for `limit` param

* modified tests for `balance`, `cash` and `income`

* re-recorded tests

* skipped intrinio financial statement fetcher tests

* Add ETF county weighting command with FMP data (#5645)

* Remove code that wrongfully infers the filing date as end of quarter

* Add etf countries command with fmp data

* Add countries command to etf router

* Update sector and country weighting fmp models

* Fix docstring typo

* Add unit tests and update mock data

* Add integration tests for etf.countries

* Bring back missing integration tests

* Fix economic calendar integration tests

* fix missing data in intrinio financials

* removed inutile params from Polygon financial statement models

* Intrinio IPO overhaul

* tests fixed and re-recorded

* Add ETF holdings performance with FMP data (#5659)

* Add etf holdings performance endpoint

* Add tests

* Fix failing polygon fetcher tests

* Split long holdings lists into chunks and update test data

* Change chunk length to 500 tickers

* Add stock search from FMP (#5642)

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Feature/v4 pypi (#5579)

* improvements to the publish script

* move scripts

* initial script that builds the package

* adjustments on the docs

* test pypi workflow

* add hour and minute to version

* black

* ruff

* duplicate file

* moving files instead

* build throught the script instead

* update nox file

* integration tests workflow

* change workflow

* fix dev_install

* fix in sed cmd

* testing the platform only

* commenting out the publishing

* fix run commands

* improvements to the publish script and doc

* fix publish script

* updating the script and the workflow

* feature/v4-pypi nightly (#5589)

* init

* Update nightly.py

* cleanup

* init file

* not referencing dev_utils

* updating obb platform key

* revert

* Increase warmup time

* project name on pyproject and adding the --pre flag on readme

* moving to the build folder

* fix noxfile

* reflecting the moves on the import statements

* fix pyproject path

* ruff

* fix paths

* fix super typo

* update workflows

* moving the pypi terminal files into its folder

---------

Co-authored-by: teh_coderer <me@tehcoderer.com>
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* economy.calendar nasdaq (#5628)

* add quandl econcal

* unittest

* add integration tests

* replace &nbsp

* fix bug TE importance

* small fix

* remove stuff from quandl

* add nasdaq provider

* add nasdaq to install files

* Update test_economy_api.py

* test

* quandl leftovers

* remove quandl econcal test

* lint

* replace &nbsp

* ruff

* lint

* update nasdaq gmt

* validate countries

* here

* no need for this

* fix calendar tests

* static

* static

* remove error

* static

* readme + website

* readme

* remove changes TE

* typo

* fix unittest

* fix tests

* Update __init__.py

* Update economic_calendar.py

* revamped model and added helpers for date range

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>

* Feature/v4-dividend-calendar: Adds Nasdaq dividend calendar and moves the command out of fundamental_analysis (#5672)

* add nasdaq dividend calendar and move out of fundamental_analysis

* black

* ruff

* add random-user-agent to pyproject.toml

* add nasdaq ipo calendar

* add nasdaq flag for SPO to IPO calendar

* add spo test param

* black

* dividend test

* fix transform_query - nasdaq_calendar_ipo

* bring back different headers for ipo calendar

* remove references to test

* Add disc endpoints (#5660)

* Add Quandl top retail

* Add tests

* Add Seeking Alpha

* Add Filings

* Change Provider

* Fix test

* Add dev_install

* static

* static correct

* y u forget me

* updated deps

* static

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>

* using dev install (#5673)

* Expanding the `fixedincome` menu (#5655)

* models and fetcher

* making the fetcher visible

* std model

* adding the command

* improvements to the models

* typo

* adding the command

* imrpovements to dwpcr

* standard model for ecb int rates

* adding the fetcher for fred

* standard model of ice bofa

* add ice_bofa command

* ruff

* ice bofa fetcher

* moody std model

* moody

* std model

* add cp command

* unused import

* cp

* spot

* ruff

* hqm

* tmc

* ffrmc

* tbffr

* ruff

* typing fixes

* buggy dates

* fred fetcher tests

* ruff

* adding ecb as a provider

* adding new provider related stuff

* adding the new command eu_ycvr

* models

* test for ecb fetcher

* Feature/v4 fixedincome int tests (#5661)

* integration tests

* happy ruff

* mini adjustment

* ruff

* typo

* verbose type

* fix tests

* docstrings everywhere and an happy pydocstyle

* fix tests

* Feature/user-cache-dir: Add User Preference for the Cache Directory (#5621)

* add user preference for storing cached data

* ruff

* fix tests?

* fix test key error..?

* etf integration test fix

* add cache dir to SEC

* black

* improve docs structure for V4 (#5586)

* improve docs structure for V4

* moving over changes

* Add Docs to the navbar

* add some, re-order sidebar

* fix sentence

* add docs install to source instructions

* insert a couple of links, fix a typo

* big terminal docs usage revamps

* improve toggle component for tutorials

* get rid of TOCs for all terminal docs for consistency and simplicity

* improve platform docs

* improve bot docs content structure

* remove index from bot docs

* improve ON THIS PAGE to only display TOC if at least 1 element

* make edit this page text and icon on same line

* add author and date to docs

* add basic syntax page to usage

* sidebar order for usage section

* move api start command to the top with the import python import

* some install page additions

* small improvement

* refactor routines section

* Update introduction-to-routines.md

* Update pipeline-of-commands.md

* Update introduction-to-routines.md

* Update routines-for-power-users.md

* Update community-routines.md

* update keyboard hotkey macros

* askobb page

* Update askobb-feature.md

* Update index.md

* Update index.md

* Update index.md

* Update index.md

* fix images

* remove HeadTitle from all files where it exist

* get rid of extra spacing in markdown

* small update

* small edit

* need index at the start because of main path when homepage of docs

* use openAI to create SEO for front matter on my behalf

* remove table of content from sdk page

* finish improving metadata SEO for SDK docs

* update duplicate header

* update HeadTitle to be more specific on product

* remove index from bot telegram reference

* delete duplicated title for platform reference

* another update

* Hotfix/econometrics export filename fix (#5508)

* fix: Modify 'load' behavior to append data to existing sheet

Details:
- Added logic to detect existing sheet and append data if present.
- There is no direct way to append on the sheet, so I am reading the sheet to get the last row number and then writing after that row number.

Resolves: #5472

* Added --export option for exporting to a desired file in /econometrics menu

* Added a -f/--file option to provide the filename for export.
Made -t/--type and -f/--file mutually exclusive.
If -f is not given, -t is required and the filename will be generated based on the time and module.

* Revert `helper_funcs.py` to original state

* Made some arguments not required.

* Minor changes asked by @deeleeramone

* No sheet name

* black

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>

* FIX #5600 Updated the Twitter logo to X logo (#5601)

* Change Ultima paragraph (#5624)

* change ultima paragraph

* remove old paragraph

* Update CONTRIBUTING.md (#5623)

* mobile line-brake fixed (#5604)

In the mobile view (media max 400px ), the text line "Installation >>" appears broken into smaller segments.

Co-authored-by: James Maslek <jmaslek11@gmail.com>

* start PR so screenshots can get attached via GitHub website

* Update qa.md

* Docs/terminalpro and improvement (#5622)

* add first iteration of content for Terminal Pro

* Update index.md

* Update dashboards.md

* Update folders.md

* Update grouping.md

* Update report.md

* Update templates.md

* Update quick-start.md

* Update index.md

* Update index.md

* Update home.md

* Update news.md

* Update index.md

* Update index.md

* Update index.md

* Update data-provider.md

* Update chat-with-widget.md

* Update data-manipulation.md

* Update forecasting.md

* fix: images self closing tags

* fix: only pro visitors can see pro

* inter font

* improve SEO content and restructuring

* add new package for toggle on tutorials

* move folder around

* improve main page of each prod

* small updates and improvements

* fix logo above

* small improvement in headtitle for portfolio funcs

* fix typos from OpenAI's GPT-4

* fix _category_ json

* remove generic SEO words

* add script that generates SEO for documentation

* add missing file

* remove sdk warning message

* fix links for andrew

---------

Co-authored-by: jose-donato <zmcdonato@gmail.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>

* Add light blue banner, blue when clicking sidebar + fix link in docusaurus.config.js (#5627)

* typo

* pro docs tab coloring

* sidebar selection blue

* redirecting missing

* Update crypto introduction.md

* titles

* another title

* Update crypto dd.md

* Update defi.md

* Update disc.md

* Update nft.md

* Update onchain.md

* Update ov.md

* Update introduction.md

updates URL

* Update introduction.md

add HeadTitle

* Update ba.md

* Update comparison.md

* Update dark-pool-shorts.md

* Update disc.md

* fix docs (#5646)

* Update fa.md

* Update gov.md

* Update ins.md

* Update tradinghours.md

* Delete website/content/terminal/menus/stocks/options/screener.md

* Update Options introduction.md

* Update screener head title

* Update screener TOC

* Update econometrics.md

* Update economy head title

* Update etf.md

* codespell

* Fix the redirect for intro to the correct url for docs (#5658)

* fix the redirect for intro to the correct url for docs

* fix code linting

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>

* Contributing guidelines (#5615)

* intro section

* what's expected sections

* improve sections

* improve sections and move how to add a data point

* moving qa under contributor

* better intro

* moving the sharing section

* better expectations

* small intro to the contributor guidelines

* moving things under the contributor section

* there is no pre commits on the platform yet

* dependency management

* best practices for extensions

* typo

* collapse options subfolder

* codespell

* Improve Pro documentation further (#5641)

* small improvement

* Fix TutorialVideo for mobile view

* main page terminal pro docs

* jose whelp

* placeholder index file that needs to be removed

* fix: fixes sidebar, removes unused index.md

* update link to api keys

* update api keys link

* fix hyperlinks in terminal helper

* fix a few more links

* fix some more links

* linter

* black linter

* improve main docs page for each product

* small refactor

* header to take to main page of product

* run OpenAI script to generate SEO for pro content

---------

Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>

* Update folders.md

* Update integrate-your-own-backend.md

* Update index.md

* Update fixedincome.md

* url

* Update forecast.md

* Update settings.md (#5665)

* Update forex.md

* fix front matter (#5667)

* Fix conflict markers that got into markdown during previous merges

* Fix front matter list formatting

* Fix typo

* small thing

* fix hyperlinks

* Update .codespell.ignore

* output_type options

* Architectural considerations

* Update sidebar to hide pro section by default

* Minor copy changes

* TET pattern

* import statements

* clarification on preferences

* Minor copy changes

* Lint markdown and python

* fix: open index on collapsible root elements

* remove old content

* options title

* Fix linting errors

* Refactor sidebar label to url mapping condition

---------

Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Sandip Saha <sandipsmoto@gmail.com>
Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: professssor <62937125+professssor@users.noreply.github.com>
Co-authored-by: Farookh Zaheer Siddiqui <129654632+FarukhS52@users.noreply.github.com>
Co-authored-by: MAX SHESTOV <57421753+maxxsh@users.noreply.github.com>
Co-authored-by: jose-donato <zmcdonato@gmail.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
Co-authored-by: Mohamad Fadil <fadil.parves@gmail.com>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Add multi-ticker support to etf_countries (#5670)

* add multi-ticker support to etf_countries

* remove commented-out lines

* normalized percent points

* percent -> percentage

* Fix Nasdaq Econ Calendar Fetcher (#5668)

* fix nasdaq econ cal request

* more html tags

* add random-user-agent to pyproject

* another edge case - 24H -> 00:00

* Feature/v4-unusual-options: Adds unusual options endpoint. (#5677)

* add unusual options fro Intrinio

* test params

* move sorting

* Change type

* update FMP fetcher to use the V4 endpoint (#5681)

* Fix price performance not parsed correctly when there is only 1 ticker (#5678)

* Add crypto search standard model and FMP data for it (#5679)

* Apply renaming to news data (#5684)

* inegration complete

* reformatted for black

* fix ruff issues

* revised integration

* changes to versions in pyproject.toml and updated lock files

* Rename models

* Update tests

* Fix typos here and there

* Update routers

* Apply rename to ultima

* Properly mock api key

* Mock ultima api key

---------

Co-authored-by: Adi Sai <adithya.sairam1@gmail.com>

* Feature/v4-market-snapshots: Adds full market snapshots (#5473)

* add stocks market snapshots from fmp

* add fmp fetcher test

* unused imports

* add polygon to market_snapshots

* update fmp market_snapshots

* black

* pydantic2 things

* updates

* change validate_obj to model_validate

* polygon cleanup

* tests

* descriptions

* black

* data description

* minor adjustments, using less local variables, improving readability and removing pandas

* better structure

* minor adjustments

* lint

* fix int tests

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>

* Add NBBO Quotes, with historical, to `obb.stocks.quote()` (#5617)

* coerce string type, add default=None

* add polygon stock quote

* limit cleanup

* add greater/less than to params

* limit param

* black

* tests

* fix tests

* test_etf

* rename model and function to NBBO

* add standard model for nbbo

* improve standardization

* not redifining builtin max

* fix input params

* integration test params

* removing unused import

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>

* revamped code

* re-recorded nbbo test

* added symbol validator

* added alias in field

* Stock news -> Company news

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* hotfix/update-quandl-to-nasdaq: Merge Quandl + Nasdaq (#5682)

* merge quandl nd nasdaq

* dev_install.py

* test param name

* economy python integration test

* Add more input types to data processing commands (#5453)

* adding more supported types to data processing commands

* ruff

* removing unused import

* docstrings

* data processing types covertion

* data description

* test filters

* ruff

* fix package builder tests

* ruff

* removing print

* Add stocks/dps module (#5638)

* short volume

* pyproject missed

* add sec short interest with days to cover

* Add FINRA OTC endopoint

* some tests

* rest of unit tests

* Integratin test scripts

* dev install

* linters caught by pre commit

* lines too long

* Last test files

* maybe it needs a lock file?

* thanks pratty

* Maybe ill actually listen to pratty next time

* sec test date freeze

* I cant hit buttons

* re record tests

* tests 3

* Stockgrid test

* regen int test

* more testing

* lint

* moved these fns

* dis killing me

* one more test

* last one

* Update integration tests

* Fix tests picking up wrong dps route

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Rename Forex to Currency (#5687)

* restore fields as optional (#5686)

* Rename Crypto (#5689)

* added `crypto.price.historical`

* static

* fix tests

* fix incorrect label

* Move model from sec to finra (#5692)

* Update toml

* fixed deps

* add openbb-etf lock file

* cleanup

* cleanup (#5694)

* Rename Fixed Income (#5695)

* Rename Fixed Income

* Add routers

* Rename stocks to equity (#5688)

* Rename stocks folder

* Rename openbb_stocks package

* Rename routers

* Reroute equity menu

* Update routes based on feedback

* StockNews -> EquityNews

* StockInfo -> EquityProfile

* Rename Equity calendars

* Equity peers rename

* Rename discovery

* Rename fundamental

* Rename price command models

* Rename shorts

* Update charting router

* Fix seeking alpha upcoming release date

* Fix linting errors

* Update tests

* Fix tests

* Skip econometrics api tests because it's python only

* Update integration tests and test data

* Historical analyst estimates

* Skip cboe options chain test. Unable to record vcr cassette

* re-record cboe cassettes

* Document CBOE unit test creation caveats

---------

Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>

* Feature/files-for-igor: Adding a few standard models for Igor (#5699)

* add some standard models for Igor

* codespell

* update descriptions

* Add devtools metapackage (#5703)

* Add openbb-devtools metapackage

* adding devtools to the dev_install script

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>

* Rename econometrics commands to be more verbose (#5702)

* Expose command to model map (#5706)

* Rename ta qa (#5708)

* Rename ta folder

* Rename ta to technical

* Rename qa folder

* Rename qa to quantitative

* Rename the actual routes in quantitative

* Equity cleanup (#5707)

* cleanup

* static

* renaming to equity cc @the-praxs

* Proof reading

---------

Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Don't enforce imperative for first word of the docstring

* Remove ultima from default extensions

* Rename `economy` and create `index` extension (#5705)

* renamed economy and re-recorded tests

* static

* market indices

* european indices

* fred indices

* index constituents

* tests

* correct package name

* oops

* static

* linting

* Move COT commands to regulators

* Rename economy.list to available_indices

* Rename GDP models and clean up

* Fix charting tests

* Drop _indices from available_indices command

* Fix obbject to_dict test

---------

Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Rename etf/disc (#5715)

* Docs/v4-working-docs: PR to Work on V4 Docs (#5693)

* Revert changes related to pydantic2 made into v3 code

* Revert fred model changes in v3

* Revert pydantic2 databento model changes in v2

* Update some names and v3 lock file

* Clean up openbb/package before the beta release

* Platform publishing procedure (#5701)

* update instructions

* introducing the version script

* publish message

* fix platform path

* reflecting version changes

* getting version from installed packages instead

* removing toml from dependencies

* Changes to get `a7` out (#5697)

* changes to get a7 out

* etf menu on the pyproject.toml

* poetry lock

* bump `openbb-etf` to `a5` to match version

* updated deps

* removing ultima

* removing references to a4 cc @the-praxs

* Bump index menu version

* poetry lock

---------

Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
Co-authored-by: Theodore Aptekarev <aptekarev@gmail.com>

* Update publishing instructions

* Bump core dependencies in extensions and providers

* Add changes to the publish script following the beta release

* Update the versions in static extension map and openbb metapackage

---------

Co-authored-by: James Maslek <jmaslek11@gmail.com>
Co-authored-by: Pratyush Shukla <ps4534@nyu.edu>
Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt>
Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
Co-authored-by: Igor Radovanovic <74266147+IgorWounds@users.noreply.github.com>
Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com>
Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com>
Co-authored-by: tehcoderer <me@tehcoderer.com>
Co-authored-by: DidierRLopes <dro.lopes@campus.fct.unl.pt>
Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com>
Co-authored-by: Sandip Saha <sandipsmoto@gmail.com>
Co-authored-by: professssor <62937125+professssor@users.noreply.github.com>
Co-authored-by: Farookh Zaheer Siddiqui <129654632+FarukhS52@users.noreply.github.com>
Co-authored-by: MAX SHESTOV <57421753+maxxsh@users.noreply.github.com>
Co-authored-by: jose-donato <zmcdonato@gmail.com>
Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com>
Co-authored-by: Mohamad Fadil <fadil.parves@gmail.com>
Co-authored-by: Adi Sai <adithya.sairam1@gmail.com>
2023-11-13 15:03:31 +00:00

1411 lines
39 KiB
Plaintext
Vendored

{
"cells": [
{
"attachments": {},
"cell_type": "markdown",
"id": "70ba2c8a",
"metadata": {},
"source": [
"## Notebook setup\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "driven-billion",
"metadata": {},
"outputs": [],
"source": [
"import warnings\n",
"import datetime\n",
"import numpy as np\n",
"import pandas as pd\n",
"\n",
"from IPython.display import HTML\n",
"\n",
"from openbb_terminal import config_terminal as cfg\n",
"from openbb_terminal.helper_classes import TerminalStyle\n",
"from openbb_terminal import OpenBBFigure\n",
"from openbb_terminal.core.plots.plotly_ta.ta_class import PlotlyTA\n",
"\n",
"warnings.filterwarnings(\"ignore\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "150e5103",
"metadata": {},
"outputs": [],
"source": [
"# Suppressing sdk logs\n",
"from openbb_terminal.core.session.current_system import set_system_variable\n",
"\n",
"set_system_variable(\"LOGGING_SUPPRESS\", True)\n",
"\n",
"# Import the OpenBB SDK\n",
"from openbb_terminal.sdk import openbb, widgets"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "cf31bcc7",
"metadata": {},
"outputs": [],
"source": [
"from openbb_terminal.core.session.current_user import get_current_user\n",
"\n",
"user = get_current_user()\n",
"\n",
"from openbb_terminal import theme\n",
"\n",
"cfg.theme = TerminalStyle(\n",
" user.preferences.MPL_STYLE,\n",
" user.preferences.PMF_STYLE,\n",
" user.preferences.RICH_STYLE,\n",
")\n",
"theme.apply_style(\"light\")"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c3fe7db5-ec6a-42cf-9e66-52dc1de22370",
"metadata": {},
"outputs": [],
"source": [
"stylesheet = widgets.html_report_stylesheet()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "807fda4e",
"metadata": {},
"source": [
"## Select symbol\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "intended-sherman",
"metadata": {
"tags": [
"parameters"
]
},
"outputs": [],
"source": [
"# Parameters that will be replaced when calling this notebook\n",
"# Do not leave parameters blank as notebook will not run otherwise\n",
"symbol = \"MSFT\"\n",
"report_name = f\"Equity report for {symbol}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "a441ddbc-d75b-4a18-84d4-e01b677674d3",
"metadata": {},
"outputs": [],
"source": [
"if \".\" in symbol:\n",
" import sys\n",
"\n",
" sys.exit(0)\n",
"symbol = symbol.upper()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1be26dae-cafe-4a22-80aa-eff296fc1a9b",
"metadata": {},
"outputs": [],
"source": [
"ticker_data = openbb.stocks.load(\n",
" symbol=symbol, start_date=datetime.datetime.now() - datetime.timedelta(days=18 * 30)\n",
")\n",
"ticker_data = openbb.stocks.process_candle(data=ticker_data)\n",
"\n",
"author = \"\"\n",
"report_title = f\"Investment Research Report on {symbol.upper()}\"\n",
"report_date = datetime.datetime.now().strftime(\"%d %B, %Y\")\n",
"report_time = datetime.datetime.now().strftime(\"%H:%M\")\n",
"report_timezone = datetime.datetime.now(datetime.timezone.utc).astimezone().tzinfo\n",
"report_title, report_date, report_time, report_timezone"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e3b15d6f-dc9e-4f97-aa07-37d949a4e4bb",
"metadata": {},
"outputs": [],
"source": [
"info = openbb.stocks.fa.overview(symbol=symbol, source=\"Finviz\").transpose()\n",
"\n",
"info\n",
"try:\n",
" company_name = info[\"Company\"][0]\n",
"except:\n",
" company_name = \"N/A\"\n",
"try:\n",
" company_sector = info[\"Sector\"][0]\n",
"except:\n",
" company_sector = \"N/A\"\n",
"\n",
"try:\n",
" company_industry = info[\"Industry\"][0]\n",
"except:\n",
" company_industry = \"N/A\"\n",
"\n",
"\n",
"overview = [company_name, company_sector, company_industry]"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "f8a0d747",
"metadata": {},
"source": [
"## Data\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "aca4b6ef",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" (\n",
" df_year_estimates,\n",
" df_quarter_earnings,\n",
" df_quarter_revenues,\n",
" ) = openbb.stocks.fa.est(symbol=symbol)\n",
" df_quarter_revenues.transpose()\n",
"except Exception as e:\n",
" print(e)\n",
" df_year_estimates = pd.DataFrame()\n",
" df_quarter_earnings = pd.DataFrame()\n",
" df_quarter_revenues = pd.DataFrame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c0f0a1ca",
"metadata": {},
"outputs": [],
"source": [
"display_year = sorted(df_year_estimates.columns.tolist())[:3]\n",
"df_year_estimates = df_year_estimates[display_year].head(5)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6976c1d5",
"metadata": {},
"outputs": [],
"source": [
"tables = openbb.stocks.news(symbol)\n",
"\n",
"for table in tables:\n",
" if not isinstance(table, pd.DataFrame):\n",
" continue\n",
"\n",
" table[0].loc[\"URL\"] = table[0].loc[\"URL\"].apply(lambda x: f'<a href=\"{x}\">{x}</a>')"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "38e38d7c",
"metadata": {},
"outputs": [],
"source": [
"quote_data = info[[\"Price\", \"Prev Close\", \"Change\", \"Volume\", \"52W Range\", \"Perf YTD\"]]\n",
"quote_data"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "fde46353",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" df_institutional_shareholders = openbb.stocks.fa.shrs(\n",
" symbol, holder=\"institutional\"\n",
" )\n",
" df_institutional_shareholders.index += 1\n",
" df_institutional_shareholders\n",
"except Exception as e:\n",
" print(e)\n",
" df_institutional_shareholders = pd.DataFrame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3022130e",
"metadata": {},
"outputs": [],
"source": [
"# this command works 1/2 the time - really need to fix this - but this will catch the errors and stop it from breaking the report\n",
"try:\n",
" df_sec_filings = openbb.stocks.fa.sec(symbol)[\n",
" [\"Company Name\", \"Reporting Owner\", \"Form Type\", \"Period\", \"View\"]\n",
" ].head(5)\n",
" df_sec_filings\n",
"except:\n",
" df_sec_filings = \"Error with Nasdaq API\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4662b1ac",
"metadata": {},
"outputs": [],
"source": [
"df_analyst = openbb.stocks.fa.pt(symbol=symbol).sort_index(ascending=False)\n",
"# print(df_analyst)\n",
"# if not df_analyst.empty:\n",
"# if \"target\" in df_analyst.columns:\n",
"# if \"target_to\" in df_analyst.columns:\n",
"# df_analyst[\"target\"] = df_analyst[\"target_to\"].combine_first(\n",
"# df_analyst[\"target\"]\n",
"# )\n",
"# else:\n",
"# df_analyst[\"target\"] = df_analyst[\"target\"]\n",
"# df_analyst = df_analyst[[\"category\", \"analyst\", \"rating\", \"target\"]].rename(\n",
"# columns={\n",
"# \"category\": \"Category\",\n",
"# \"analyst\": \"Analyst\",\n",
"# \"rating\": \"Rating\",\n",
"# \"target\": \"Price Target\",\n",
"# }\n",
"# )\n",
"df_analyst.head(10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "df8bdb7d",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" df_rating = openbb.stocks.fa.rating(symbol)\n",
" df_rating\n",
"except Exception as e:\n",
" print(e)\n",
" df_rating = pd.DataFrame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d0df953b",
"metadata": {},
"outputs": [],
"source": [
"pcr_chart = openbb.stocks.options.pcr_chart(symbol, window=30, external_axes=True)\n",
"\n",
"if pcr_chart:\n",
" pcr_chart = pcr_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bd79195c",
"metadata": {},
"outputs": [],
"source": [
"current_price = 0\n",
"try:\n",
" current_price = float(ticker_data[\"Adj Close\"][-1])\n",
" expiry_dates = openbb.stocks.options.expirations(symbol)\n",
"\n",
" if expiry_dates:\n",
" exp = expiry_dates[0]\n",
" option_chain = openbb.stocks.options.chains(symbol, expiration=exp)\n",
"except Exception as e:\n",
" print(e)\n",
" expiry_dates = []\n",
" option_chain = pd.DataFrame()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ad6d0c24",
"metadata": {},
"outputs": [],
"source": [
"if expiry_dates:\n",
" vol_chart = openbb.stocks.options.vol(\n",
" option_chain, current_price, symbol, exp, external_axes=True\n",
" )\n",
"\n",
" if vol_chart:\n",
" vol_chart = vol_chart.to_html()\n",
"\n",
" voi_chart = openbb.stocks.options.voi(\n",
" option_chain, current_price, symbol, exp, external_axes=True\n",
" )\n",
"\n",
" if voi_chart:\n",
" voi_chart = voi_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "324e2d4b-b2f6-4da3-bac4-ef785ad4e436",
"metadata": {},
"outputs": [],
"source": [
"net_short_position = openbb.stocks.dps.spos_chart(\n",
" symbol=symbol,\n",
" limit=84,\n",
" raw=False,\n",
" export=\"\",\n",
" external_axes=True,\n",
")\n",
"\n",
"if net_short_position:\n",
" net_short_position = net_short_position.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "ac0bfbda-e4b8-4b3b-b8e7-c02639fdb971",
"metadata": {},
"outputs": [],
"source": [
"dark_pools = openbb.stocks.dps.dpotc_chart(symbol=symbol, external_axes=True)\n",
"\n",
"if dark_pools:\n",
" dark_pools = dark_pools.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "22a7266f",
"metadata": {},
"outputs": [],
"source": [
"gtrades_chart = openbb.stocks.gov.gtrades_chart(\n",
" symbol,\n",
" past_transactions_months=12,\n",
" external_axes=True,\n",
")\n",
"\n",
"if gtrades_chart:\n",
" gtrades_chart = gtrades_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4c670ba3",
"metadata": {},
"outputs": [],
"source": [
"gov_contracts_chart = openbb.stocks.gov.contracts_chart(\n",
" symbol,\n",
" past_transaction_days=365,\n",
" external_axes=True,\n",
")\n",
"\n",
"if gov_contracts_chart:\n",
" gov_contracts_chart = gov_contracts_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "caa3dae2",
"metadata": {},
"outputs": [],
"source": [
"google_mentions_chart = openbb.stocks.ba.mentions_chart(\n",
" symbol,\n",
" external_axes=True,\n",
")\n",
"\n",
"if google_mentions_chart:\n",
" google_mentions_chart = google_mentions_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b77e60d8",
"metadata": {},
"outputs": [],
"source": [
"google_regions_chart = openbb.stocks.ba.regions_chart(\n",
" symbol,\n",
" limit=10,\n",
" external_axes=True,\n",
")\n",
"\n",
"if google_regions_chart:\n",
" google_regions_chart = google_regions_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "78593369",
"metadata": {},
"outputs": [],
"source": [
"similar_companies = openbb.stocks.ca.similar(symbol, source=\"Finviz\")[0:5]\n",
"if similar_companies:\n",
" similar_companies.append(symbol)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4639665b",
"metadata": {},
"outputs": [],
"source": [
"historical_similar = openbb.stocks.ca.hist_chart(\n",
" similar_companies,\n",
" external_axes=True,\n",
" normalize=False,\n",
")\n",
"\n",
"if historical_similar:\n",
" historical_similar = historical_similar.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "74565e53",
"metadata": {},
"outputs": [],
"source": [
"hcorr_similar = openbb.stocks.ca.hcorr_chart(\n",
" similar_companies,\n",
" external_axes=True,\n",
")\n",
"\n",
"if hcorr_similar:\n",
" hcorr_similar = hcorr_similar.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "936babfd",
"metadata": {},
"outputs": [],
"source": [
"vol_similar = openbb.stocks.ca.volume_chart(\n",
" similar_companies,\n",
" external_axes=True,\n",
")\n",
"\n",
"if vol_similar:\n",
" vol_similar = vol_similar.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "99388d4e",
"metadata": {},
"outputs": [],
"source": [
"scorr_similar = openbb.stocks.ca.scorr_chart(\n",
" similar_companies,\n",
" external_axes=True,\n",
")\n",
"\n",
"if scorr_similar:\n",
" scorr_similar = scorr_similar.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "eaa67343",
"metadata": {},
"outputs": [],
"source": [
"income_comparison = openbb.stocks.ca.income(similar_companies)\n",
"income_comparison"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "13ad71cf",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" df_related_queries = openbb.stocks.ba.queries(symbol)\n",
" df_related_queries.index += 1\n",
" df_related_queries.index\n",
"except:\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "58c06129",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" df_rising_queries = openbb.stocks.ba.rise(symbol)\n",
" df_rising_queries.index += 1\n",
" df_rising_queries\n",
"except:\n",
" pass"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "0a467f1a",
"metadata": {},
"outputs": [],
"source": [
"gov_histcont_chart = openbb.stocks.gov.histcont_chart(\n",
" symbol,\n",
" external_axes=True,\n",
")\n",
"\n",
"if gov_histcont_chart:\n",
" gov_histcont_chart = gov_histcont_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "730cae26",
"metadata": {},
"outputs": [],
"source": [
"df_lobbying = openbb.stocks.gov.lobbying(symbol, limit=5)\n",
"df_lobbying"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "d8bb53c1-147e-4342-af61-0d0a9cc56e59",
"metadata": {},
"outputs": [],
"source": [
"price_vs_short_interest = openbb.stocks.dps.psi_sg_chart(\n",
" symbol=symbol, external_axes=True\n",
")\n",
"\n",
"if price_vs_short_interest:\n",
" price_vs_short_interest = price_vs_short_interest.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "394668e1-1158-4a2b-8a38-04c72a6abdd6",
"metadata": {},
"outputs": [],
"source": [
"price_chart = openbb.stocks.candle(\n",
" symbol=symbol,\n",
" data=ticker_data,\n",
" external_axes=True,\n",
")\n",
"\n",
"if price_chart:\n",
" price_chart = price_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "900686a3",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" price_target_chart = openbb.stocks.fa.pt_chart(\n",
" symbol=symbol,\n",
" start_date=\"2022-01-01\",\n",
" data=ticker_data,\n",
" limit=10,\n",
" raw=False,\n",
" external_axes=True,\n",
" )\n",
"\n",
" if price_target_chart:\n",
" price_target_chart = price_target_chart.to_html()\n",
"except Exception:\n",
" price_target_chart = OpenBBFigure()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "61d62e1a-199e-481d-b57d-38ab486951be",
"metadata": {},
"outputs": [],
"source": [
"df = df_analyst.copy()\n",
"avg_ratings_last_30_days = 0\n",
"days = 0\n",
"if not df.empty:\n",
" df_ratings = df[datetime.datetime.now() - datetime.timedelta(days=days) :]\n",
" while df_ratings.empty:\n",
" days += 30\n",
" df_ratings = df[datetime.datetime.now() - datetime.timedelta(days=days) :]\n",
"\n",
" if days > 100:\n",
" break\n",
"\n",
" if not df_ratings.empty:\n",
" avg_ratings_last_30_days = round(np.mean(df_ratings[\"Price Target\"].values), 2)\n",
" else:\n",
" avg_ratings = 0\n",
"\n",
"last_price = round(ticker_data[\"Close\"][-1], 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "f3733ff2",
"metadata": {},
"outputs": [],
"source": [
"ratings_over_time_chart = openbb.stocks.fa.rot_chart(\n",
" symbol=symbol,\n",
" limit=10,\n",
" raw=False,\n",
" export=\"\",\n",
" external_axes=True,\n",
")\n",
"\n",
"if ratings_over_time_chart:\n",
" ratings_over_time_chart = ratings_over_time_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "924f8042-e58a-449c-91a3-7923158ff714",
"metadata": {},
"outputs": [],
"source": [
"ta_rsi = openbb.ta.rsi_chart(ticker_data[\"Close\"], external_axes=True)\n",
"\n",
"if ta_rsi:\n",
" ta_rsi = ta_rsi.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "953a340e-7ea1-4aa3-ae1d-872683dced41",
"metadata": {},
"outputs": [],
"source": [
"df = openbb.ta.rsi(ticker_data[\"Close\"])\n",
"rsi_value = round(df.values[-1][0], 2)\n",
"rsi_value"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "dce71711-20b3-4c69-af52-e0f9a69991f8",
"metadata": {},
"outputs": [],
"source": [
"from sklearn.linear_model import LinearRegression\n",
"\n",
"model = LinearRegression().fit(\n",
" np.array(range(len(ticker_data[\"Close\"][-30:].index))).reshape(-1, 1),\n",
" ticker_data[\"Close\"][-30:].values,\n",
")\n",
"regression_slope = round(model.coef_[0], 2)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6272e34b-9511-4b48-9eea-ea882ce9846a",
"metadata": {},
"outputs": [],
"source": [
"df_insider = pd.DataFrame.from_dict(openbb.stocks.ins.lins(symbol=symbol)).head(10)\n",
"if not df_insider.empty:\n",
" df_insider[\"Val ($)\"] = df_insider[\"Value ($)\"].replace({\",\": \"\"}, regex=True)\n",
" df_insider[\"Trade\"] = df_insider.apply(\n",
" lambda row: (-1 * float(row[\"Val ($)\"]))\n",
" if row[\"Transaction\"] == \"Sale\"\n",
" else (float(row[\"Val ($)\"]) if row[\"Transaction\"] == \"Buy\" else 0),\n",
" axis=1,\n",
" )\n",
" last_10_insider_trading = round(sum(df_insider[\"Trade\"]) / 1_000_000, 2)\n",
" df_insider = df_insider.drop(columns=[\"Val ($)\", \"Trade\"])\n",
" df_insider"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29254666-58c6-4686-87e6-2635ad8387e2",
"metadata": {},
"outputs": [],
"source": [
"finbrain_sentiment = openbb.stocks.ba.headlines_chart(symbol=symbol, external_axes=True)\n",
"\n",
"if finbrain_sentiment:\n",
" finbrain_sentiment = finbrain_sentiment.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "b8251b47-8ecc-47be-83f3-d9f108596898",
"metadata": {},
"outputs": [],
"source": [
"try:\n",
" df_sentiment_finbrain = openbb.stocks.ca.sentiment(symbols=[symbol])\n",
" finbrain_sentiment_val = float(df_sentiment_finbrain.values[-1][0])\n",
"except Exception as e:\n",
" finbrain_sentiment_val = \"N/A\""
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6fe6e513-d568-41b4-8aa0-37cc578c9dc3",
"metadata": {},
"outputs": [],
"source": [
"(\n",
" watchlist_count,\n",
" n_cases,\n",
" n_bull,\n",
" n_bear,\n",
") = openbb.stocks.ba.bullbear(symbol=symbol)\n",
"stocktwits_sentiment = f\"Watchlist count: {watchlist_count}</br>\"\n",
"if n_cases > 0:\n",
" stocktwits_sentiment += f\"\\nLast {n_cases} sentiment messages:</br>\"\n",
" stocktwits_sentiment += f\"Bullish {round(100*n_bull/n_cases, 2)}%</br>\"\n",
" stocktwits_sentiment += f\"Bearish {round(100*n_bear/n_cases, 2)}%\"\n",
"else:\n",
" stocktwits_sentiment += \"No messages found\"\n",
"stocktwits_sentiment"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "bfb75909-b877-4b3a-82a7-21ce174a7bb4",
"metadata": {},
"outputs": [],
"source": [
"snews = openbb.stocks.ba.snews_chart(symbol, external_axes=True)\n",
"\n",
"if snews:\n",
" snews = snews.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "329c9e1b-e1de-4836-91fd-656cc87f7111",
"metadata": {},
"outputs": [],
"source": [
"ticker_data_all = openbb.stocks.load(\n",
" symbol=symbol,\n",
" start_date=datetime.datetime.now() - datetime.timedelta(days=5 * 12 * 21),\n",
" verbose=False,\n",
")\n",
"ticker_data_all[\"Returns\"] = ticker_data_all[\"Adj Close\"].pct_change()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "37743ef3-2f16-4166-bfcc-a0fe3eb959bc",
"metadata": {},
"outputs": [],
"source": [
"bw_month = openbb.qa.bw(\n",
" ticker_data_all,\n",
" \"Returns\",\n",
" symbol,\n",
" yearly=False,\n",
" external_axes=True,\n",
")\n",
"\n",
"if bw_month:\n",
" bw_month = bw_month.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "16b33868-23dc-4c77-ac00-acb452da386c",
"metadata": {},
"outputs": [],
"source": [
"bw_year = openbb.qa.bw(\n",
" ticker_data_all,\n",
" \"Returns\",\n",
" symbol,\n",
" yearly=True,\n",
" external_axes=True,\n",
")\n",
"\n",
"if bw_year:\n",
" bw_year = bw_year.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "28ce0827",
"metadata": {},
"outputs": [],
"source": [
"income_df = openbb.stocks.fa.income(symbol, source=\"FinancialModelingPrep\")\n",
"data_df = openbb.stocks.fa.overview(symbol, source=\"FinancialModelingPrep\")\n",
"mgmt_df = openbb.stocks.fa.mgmt(symbol)\n",
"try:\n",
" if not mgmt_df.empty:\n",
" mgmt_df[\"Info\"] = mgmt_df[\"Info\"].apply(lambda x: f'<a href=\"{x}\">{x}</a>')\n",
" mgmt_df[\"Insider Activity\"] = mgmt_df[\"Insider Activity\"].apply(\n",
" lambda x: f'<a href=\"{x}\">{x}</a>' if x != \"-\" else x\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" hist_dcf = openbb.stocks.fa.dcfc(symbol)\n",
"except:\n",
" pass\n",
"\n",
"enterprise_df = openbb.stocks.fa.enterprise(symbol)\n",
"score = openbb.stocks.fa.score(symbol, years=10)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "42e289ab",
"metadata": {},
"outputs": [],
"source": [
"indicators = dict(\n",
" ema=dict(length=[50]),\n",
" sma=dict(length=[50]),\n",
" wma=dict(length=[50]),\n",
")\n",
"\n",
"ma_chart = PlotlyTA.plot(ticker_data, indicators, symbol, candles=False, volume=False)\n",
"\n",
"if ma_chart:\n",
" ma_chart = ma_chart.show(external=True)\n",
" ma_chart = ma_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "e8846a6f",
"metadata": {},
"outputs": [],
"source": [
"macd_chart = openbb.ta.macd_chart(\n",
" ticker_data[\"Close\"], symbol=symbol, external_axes=True\n",
")\n",
"\n",
"if macd_chart:\n",
" macd_chart = macd_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "48a7a427",
"metadata": {},
"outputs": [],
"source": [
"cci_chart = openbb.ta.cci_chart(ticker_data, symbol=symbol, external_axes=True)\n",
"\n",
"if cci_chart:\n",
" cci_chart = cci_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6a1bd2c6",
"metadata": {},
"outputs": [],
"source": [
"stoch_chart = openbb.ta.stoch_chart(ticker_data, symbol=symbol, external_axes=True)\n",
"\n",
"if stoch_chart:\n",
" stoch_chart = stoch_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "2611d3c6",
"metadata": {},
"outputs": [],
"source": [
"adx_chart = openbb.ta.adx_chart(ticker_data, symbol=symbol, external_axes=True)\n",
"\n",
"if adx_chart:\n",
" adx_chart = adx_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "6ecb6e17",
"metadata": {},
"outputs": [],
"source": [
"bbands_chart = openbb.ta.bbands_chart(ticker_data, symbol=symbol, external_axes=True)\n",
"\n",
"if bbands_chart:\n",
" bbands_chart = bbands_chart.to_html()"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "07e42fdb",
"metadata": {},
"outputs": [],
"source": [
"ad_chart = openbb.ta.ad_chart(ticker_data, symbol=symbol, external_axes=True)\n",
"\n",
"if ad_chart:\n",
" ad_chart = ad_chart.to_html()"
]
},
{
"attachments": {},
"cell_type": "markdown",
"id": "ac501a32-124d-4d21-aae1-a8d147bb1071",
"metadata": {},
"source": [
"## Render the report template to a file\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "abfe37e4-ea38-42c3-8fb5-7cceb233fb12",
"metadata": {},
"outputs": [],
"source": [
"body = \"\"\n",
"\n",
"\n",
"body += widgets.header(\n",
" author,\n",
" report_date,\n",
" report_time,\n",
" report_timezone,\n",
" report_title,\n",
" plotly_js=True,\n",
")\n",
"\n",
"body += widgets.tablinks(\n",
" [\n",
" \"SUMMARY\",\n",
" \"Overview\",\n",
" \"Fundamental Analysis\",\n",
" \"Technical Analysis\",\n",
" \"Behavioural Analysis\",\n",
" \"Government Menu\",\n",
" \"Comparison Menu\",\n",
" \"Options\",\n",
" \"Dark Pool and Shorts\",\n",
" \"Quantitative Analysis\",\n",
" \"Analyst Opinions\",\n",
" \"Insider Trading\",\n",
" # \"Prediction Techniques\",\n",
" ]\n",
")\n",
"\n",
"htmlcode = widgets.h(3, \"KPIs\")\n",
"htmlcode += widgets.kpi(\n",
" [last_price],\n",
" [\n",
" \"Last closing price is above the average price ratings of last 30 days\",\n",
" \"Average price ratings of last 30 day is above last closing price\",\n",
" ],\n",
" avg_ratings_last_30_days,\n",
")\n",
"htmlcode += widgets.kpi(\n",
" [30, 70],\n",
" [\"RSI level is oversold\", \"RSI level is normal\", \"RSI level is overbought\"],\n",
" rsi_value,\n",
")\n",
"try:\n",
" htmlcode += widgets.kpi(\n",
" [0],\n",
" [\n",
" \"The sum of last 10 insider trading (in millions) was negative\",\n",
" \"The sum of last 10 insider trading (in millions) was positive\",\n",
" ],\n",
" last_10_insider_trading,\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.kpi(\n",
" [-0.1, 0.1],\n",
" [\n",
" \"Last FinBrain sentiment is bearish\",\n",
" \" Last FinBrain sentiment is neutral\",\n",
" \"Last FinBrain sentiment is bullish\",\n",
" ],\n",
" finbrain_sentiment_val,\n",
" )\n",
"except:\n",
" pass\n",
"if score and score[\"Total Score\"]:\n",
" htmlcode += widgets.kpi(\n",
" [25, 75],\n",
" [\n",
" \"Buffet Score is not favourable\",\n",
" \"Buffet Score is neutral\",\n",
" \"Buffet Score is favourable\",\n",
" ],\n",
" float(score[\"Total Score\"]),\n",
" )\n",
"body += widgets.add_tab(\"SUMMARY\", htmlcode)\n",
"\n",
"htmlcode = \"\"\n",
"if overview:\n",
" titles = [\"Company\", \"Sector\", \"Industry\"]\n",
" m = 0\n",
" for x in overview:\n",
" print(x)\n",
" htmlcode += widgets.row([widgets.h(3, titles[m]) + widgets.p(x)])\n",
" m += 1\n",
"htmlcode += widgets.row([widgets.h(3, \"Price Chart\") + (price_chart or \"\")])\n",
"\n",
"try:\n",
" htmlcode += widgets.row([widgets.h(3, \"Quote\") + quote_data.to_html()])\n",
"except:\n",
" pass\n",
"\n",
"htmlcode += widgets.row([widgets.h(3, \"Latest News for \" + symbol)])\n",
"try:\n",
" for table in tables:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(4, table[1][\"title\"]) + table[0].to_html(escape=False)]\n",
" )\n",
"except:\n",
" pass\n",
"\n",
"if not mgmt_df.empty:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, f\"Management team of {symbol}\") + mgmt_df.to_html(escape=False)]\n",
" )\n",
"body += widgets.add_tab(\"Overview\", htmlcode)\n",
"\n",
"htmlcode = widgets.row(\n",
" [widgets.h(3, \"Price Target Chart\") + (price_target_chart or \"\")]\n",
")\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, \"Analyst Ratings over time\") + (ratings_over_time_chart or \"\")]\n",
")\n",
"try:\n",
" htmlcode += widgets.row([widgets.h(3, \"Analyst Ratings\") + df_analyst.to_html()])\n",
"except:\n",
" pass\n",
"# try:\n",
"# htmlcode += widgets.row(\n",
"# [widgets.h(3, \"Analyst Recommendations\") + df_rating.to_html()]\n",
"# )\n",
"# except:\n",
"# pass\n",
"\n",
"body += widgets.add_tab(\"Analyst Opinions\", htmlcode)\n",
"\n",
"try:\n",
" htmlcode = widgets.row(\n",
" [widgets.h(3, \"Estimates\") + df_year_estimates.head().to_html()]\n",
" )\n",
"except:\n",
" pass\n",
"\n",
"if not df_quarter_earnings.empty:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, \"Earnings\") + df_quarter_earnings.head().to_html()]\n",
" )\n",
"if not df_quarter_revenues.empty:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, \"Revenues\") + df_quarter_revenues.head().to_html()]\n",
" )\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, \"Major Institutional Shareholders\")\n",
" + df_institutional_shareholders.head().to_html()\n",
" ]\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, f\"Historical DCF for {symbol}\") + hist_dcf.to_html()]\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, f\"Enterprise data for {symbol}\") + enterprise_df.to_html()]\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, f\"Income Statement for {symbol}\") + income_df.to_html()]\n",
" )\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.row([widgets.h(3, f\"Data for {symbol}\") + data_df.to_html()])\n",
"except:\n",
" pass\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, \"SEC filings\") + df_sec_filings.to_html(escape=False)]\n",
" )\n",
"except:\n",
" pass\n",
"\n",
"body += widgets.add_tab(\"Fundamental Analysis\", htmlcode)\n",
"\n",
"htmlcode = widgets.row([widgets.h(3, \"Put to call ratio\") + (pcr_chart or \"\")])\n",
"\n",
"if expiry_dates:\n",
" htmlcode += widgets.row(\n",
" [widgets.h(3, \"Option Volume for closest expiry date\") + (vol_chart or \"\")]\n",
" )\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, \"Volume and Open Interest for closest expiry date\")\n",
" + (voi_chart or \"\")\n",
" ]\n",
" )\n",
"\n",
"body += widgets.add_tab(\"Options\", htmlcode)\n",
"\n",
"htmlcode = widgets.row([net_short_position or \"\"])\n",
"htmlcode += widgets.row([price_vs_short_interest or \"\"])\n",
"# htmlcode += widgets.row([dark_pools])\n",
"body += widgets.add_tab(\"Dark Pool and Shorts\", htmlcode)\n",
"\n",
"htmlcode = widgets.row(\n",
" [\n",
" widgets.h(3, \"Congress trading in the past 12 months for \" + symbol)\n",
" + (gtrades_chart or \"\")\n",
" ]\n",
")\n",
"htmlcode += widgets.row([gov_histcont_chart or \"\"])\n",
"htmlcode += widgets.row([gov_contracts_chart or \"\"])\n",
"htmlcode += widgets.row([widgets.h(3, \"Recent Corporate Lobbying by \" + symbol)])\n",
"try:\n",
" for _, row in df_lobbying.iterrows():\n",
" amount = (\n",
" \"$\" + str(int(float(row[\"Amount\"]))) if row[\"Amount\"] is not None else \"N/A\"\n",
" )\n",
" htmlcode += widgets.row([widgets.p(f\"{row['Date']}: {row['Client']} {amount}\")])\n",
" if (row[\"Amount\"] is not None) and (row[\"Specific_Issue\"] is not None):\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.p(\n",
" \"\\t\"\n",
" + row[\"Specific_Issue\"].replace(\"\\n\", \" \").replace(\"\\r\", \"\")\n",
" )\n",
" ]\n",
" )\n",
"except:\n",
" pass\n",
"\n",
"body += widgets.add_tab(\"Government Menu\", htmlcode)\n",
"\n",
"htmlcode = widgets.row(\n",
" [\n",
" widgets.h(3, f\"Price over the past year for companies similar to {symbol}\")\n",
" + (historical_similar or \"\")\n",
" ]\n",
")\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Price correlation with similar companies for {symbol}\")\n",
" + (hcorr_similar or \"\")\n",
" ]\n",
")\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Volume over the past year for companies similar to {symbol}\")\n",
" + (vol_similar or \"\")\n",
" ]\n",
")\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Sentiment correlation with similar companies for {symbol}\")\n",
" + (scorr_similar or \"\")\n",
" ]\n",
")\n",
"if isinstance(income_comparison, pd.DataFrame):\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Income data for similar companies to {symbol}\")\n",
" + income_comparison.to_html()\n",
" ]\n",
" )\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.p(\n",
" \"Note that similar companies have been found using openbb.stocks.ca.similar\"\n",
" )\n",
" ]\n",
")\n",
"body += widgets.add_tab(\"Comparison Menu\", htmlcode)\n",
"\n",
"htmlcode = widgets.row([widgets.h(3, f\"Moving Averages for {symbol}\") + ma_chart])\n",
"htmlcode += widgets.row([macd_chart or \"\"])\n",
"htmlcode += widgets.row([ta_rsi or \"\"])\n",
"htmlcode += widgets.row([stoch_chart or \"\"])\n",
"htmlcode += widgets.row([cci_chart or \"\"])\n",
"htmlcode += widgets.row([ad_chart or \"\"])\n",
"htmlcode += widgets.row([bbands_chart or \"\"])\n",
"htmlcode += widgets.row([adx_chart or \"\"])\n",
"body += widgets.add_tab(\"Technical Analysis\", htmlcode)\n",
"\n",
"if not df_insider.empty:\n",
" htmlcode = widgets.row(\n",
" [widgets.h(3, \"Last Activity\") + df_insider.head(10).to_html(col_space=\"75px\")]\n",
" )\n",
"else:\n",
" htmlcode = widgets.row(\n",
" [widgets.h(3, \"Last Activity\") + widgets.p(\"No insider trading data found.\")]\n",
" )\n",
"\n",
"body += widgets.add_tab(\"Insider Trading\", htmlcode)\n",
"\n",
"\n",
"htmlcode = widgets.row([bw_year or \"\"])\n",
"htmlcode += widgets.row([bw_month or \"\"])\n",
"body += widgets.add_tab(\"Quantitative Analysis\", htmlcode)\n",
"\n",
"\n",
"htmlcode = widgets.row([finbrain_sentiment or \"\"])\n",
"htmlcode += widgets.row([snews or \"\"])\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, \"Interest in \" + symbol + \" based on google analytics\")\n",
" + (google_mentions_chart or \"\")\n",
" ]\n",
")\n",
"htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Regions with highest interest in {symbol}\")\n",
" + (google_regions_chart or \"\")\n",
" ]\n",
")\n",
"try:\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Top queries related to {symbol}\")\n",
" + df_related_queries.to_html()\n",
" ]\n",
" )\n",
" htmlcode += widgets.row(\n",
" [\n",
" widgets.h(3, f\"Top rising queries related to {symbol}\")\n",
" + df_rising_queries.to_html()\n",
" ]\n",
" )\n",
"except:\n",
" pass\n",
"htmlcode += widgets.row(\n",
" [widgets.h(3, f\"Stocktwits sentiment for {symbol}\") + stocktwits_sentiment]\n",
")\n",
"body += widgets.add_tab(\"Behavioural Analysis\", htmlcode)\n",
"\n",
"body += widgets.tab_clickable_and_save_evt()\n",
"\n",
"report = widgets.html_report(\n",
" title=report_name, stylesheet=widgets.html_report_stylesheet(), body=body\n",
")\n",
"\n",
"# to save the results\n",
"with open(report_name + \".html\", \"w\", encoding=\"utf-8\") as fh:\n",
" fh.write(report)"
]
}
],
"metadata": {
"celltoolbar": "Tags",
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.11"
},
"vscode": {
"interpreter": {
"hash": "af870c0f9615f5bb08692efcc9bf540319fe60e6793056508a4dab09c9fa8dda"
}
}
},
"nbformat": 4,
"nbformat_minor": 5
}