* Added github actions for gitflow * Minor changes * Fix plot look when using eval and add query to choices (#3881) (#3898) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Testing Gitflow (#3899) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * Feature/gitflow (#3900) * Fix plot look when using eval and add query to choices (#3881) (#3901) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Gitflow Implementations (#3902) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Gitflow Implementations (#3904) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Main --> develop (#3906) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * GItflow Implementations (#3909) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Feature/gitflow (#3911) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * Update develop (#3913) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Feature/gitflow (#3914) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Feature/gitflow (#3921) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Feature/gitflow (#3914) (#3915) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Nightly build feature * Added branch name docs * poetry add ccxt@latest (#3920) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * poetry add ccxt@latest Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Add crypto dd functions to sdk (#3888) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Add crypto dd functions to sdk * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Fixes currency and trailmap Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Integration tests refactor (#3781) * generate integration tests report * new console report * simple run_scripts * move tests script to folder * add skipping * always display skips * func name * allow running from relative path * rename some vars and time * typo * change portfolio supress and warning * uncomment economy test * rename test controller * multiprocessing * display test progress and available * rename func * mypy * should not be here * small changes * type hinting and docstrings * new subprocesses default * forget context and chunksize * clean len skipt * small comment * fix subproc default with v * minor change * fix path * better this way * make output visible * allow only sequential run with verbose mode * change message * detail * include andrew idea * limit multiprocessing to clone version * fix for package application * must be up here * allow verbose with multiprocessing but warn * update readme * move tests to core * Update README.md * Update README.md * move readme outside * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * parse subproc arg * Update README.md * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Delete glossary base command * move scripts * ruff * update pyproject.toml * update yfinance * fix futures and economy test, rewrite * rewrite stocks test yfinance dependent * refactor sia to yfinance 0.2... * fix last failing sia tests * black * update reqs Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> * Gitflow - Autodoc (#3922) * Hotfix/dots sources (#3928) * fix: wordwrap * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fix: str Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Update dependency: grpcio (#3937) * Update grpcio * Revert "Update grpcio" This reverts commit 676c50a2bdde5ca64614bddd3eaebbccd68c5994. * Update dependencies * Rebase develop? (#3935) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Update installation guides with videos (#3903) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Update installation guides with videos * Add fix for Ruff crashing * Me no longer do what James said * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * broken link (#3889) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * broken link due to quandl.com redirecting to nasdaq.com, for the link to work and get the appropiate API key you need to remove the period at the end of this link... Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: james <jmaslek11@gmail.com> * Issue #3882 Fixed (#3885) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Issue #3882 Fixed * 2 files reformatted by black * tests added * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fixed mypy errors Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * GitFlow - improve check for changes (#3948) Gitflow Implementation * Rewrite and skip yfinance tests (#3953) * economy * fix futures * fix stocks tests * skip unfixable tests * fix ark * Fixed failing badge not used anymore (#3932) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Fix portfolio returns (#3931) * fix inception bug and clean some useless attributes * reorder attributes * add returns and cumulative returns * fix cumulative returns * fix cumulative returns * remove cumulative ret * add some doc and encapsule methods * order detail * add more details on docstrings * wrong docstring * add commnet * Update portfolio_engine.py * fix bug with unsupported type * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fix table header * fix portfolio integration test * ruff * fix tests * rewrite yfinance call * fix test_draw * test_stocks_helper * bt model * fix comp analysis * fix ftd * fix dd * fix screener Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> * Put yf.info behind an exchange flag on `load` (#3951) * Put yf.info behind an exchange flag * Guides Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Last Price Bug into Previous Close #3865 (#3949) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add multiple countries option to events (#3938) * allow multiple countries in events cmd * fix test * fix last test * black Co-authored-by: James Maslek <jmaslek11@gmail.com> * Minor Fix for branch name check (#3979) * Gitflow - Added manual trigger to Linting (#3981) * Minor Fix for branch name check * added manual trigger to linting * Linting fix (#3984) Linting fix * Feature/macro convert (#3924) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Issue #3882 Fixed * 2 files reformatted by black * tests added * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fixed mypy errors * Fixed parser options for currency conversion Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update sma.md (#3956) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update sma.md Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update overlap_model.py (#3955) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update overlap_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update vwap.md (#3971) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update overlap_model.py - wrong typehint (#3970) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update overlap_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Bump yfinance to 0.2.4 and fix tests (#3977) * upgrade yfinance to 0.2.4 * fix some tests failing bc yfinance new date format * fix remaining tests * fix tests * rewrite failing test * black * rerecord test * fix get_1y_sp500 test * missing import here Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add extra error handling for yf in etf (#3985) * Fix the news command and making it more stable (#3965) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Hotfix/bug #3945 (#3963) * Add exception to http requests made by ftd * Formatting Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Fix #3787 (#3966) Make the get_equal_weights handle portfolio's with stock's filtered out, due to the stocks having to many NaNs. Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add ticker to the load export file (#3997) * bump * Change export name to have the ticker * revert yaml * Feature/release branch gitflow (#3998) * release branch gitflow implentation * Fix integration tests bugs (#3993) * fix tk * fix newsletters * fix lt * exception on pir * fix attrib bug and remove warning * fix earnings * fix ins, lt, whatif * fillna * fix vis Co-authored-by: James Maslek <jmaslek11@gmail.com> * change .env loading priority (#4005) * [FIX] Pytorch-lightning trainer conflict with TQDM progress bar (#4002) * fix for tqdm progress bar conflict * fix tests Co-authored-by: James Maslek <jmaslek11@gmail.com> * bump * Fix historical futures plot axes (#4006) * change start date to model * rewrite test * ruff * add end date * move futures and update test * return if wrong dates * fix controller test * record mode rewrite model and view Co-authored-by: James Maslek <jmaslek11@gmail.com> * Fix M1 build (#4010) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * adding xgboost explicitly * testing juan sugestion * removing unncessary stuff that the hook deals with Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * merge the release changes into develop (#4016) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * bump * Update release branch * revert conda yaml * logging hash * Update version number * Added scipy to intel * Add xgboost to intel * add scipy libs to windows only * add scipy sparse * update scipy and pywin * update tests * UPdate installation.md to reflect 2.2 * fix yf unit tests * Try to get futures tests working * Ignore tz in yf download * Found another end date needed * delelte yf cache Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: luqazino@gmail.com <luqazino@gmail.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> * Adds filings function to the Stocks menu (#3910) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * adds filings function * Updates test_print_help.txt * Adds new filings function to SDK documentation. * updates Stocks Menu screenshot to include `filings` * updating unit testing * requested changes * more changes * black * removed a trail here that should have stayed local * adds export flag * correction Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Feature - Added Integration Test Automation (#4019) Added integration test to release branch Nightly build on develop branch * Feature/excel sheets (#4023) * bump * Add sheet name to export for base load function * Disable pylint due to known issue with pylint and pandas * Add robust option if file already exists * Abstract the sheet name argument into the export data helper * Feature flag for auto overwrite * add to featflag menu * Add featflag to builds * Remove safety check * Fix test * Quantile Anomaly Detection on Timeseries (#3980) * init commit * model + view * fixes plus doc strings * tests * trail map * remove ) * linting? * fix * refactor * renaming * rename v2 * final chart * linting Co-authored-by: James Maslek <jmaslek11@gmail.com> * Hotfix --> develop (#4027) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Release/2.2.0 (#4008) * Added github actions for gitflow * Minor changes * Fix plot look when using eval and add query to choices (#3881) (#3898) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Testing Gitflow (#3899) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * Feature/gitflow (#3900) * Fix plot look when using eval and add query to choices (#3881) (#3901) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Gitflow Implementations (#3902) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Gitflow Implementations (#3904) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Main --> develop (#3906) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * GItflow Implementations (#3909) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Feature/gitflow (#3911) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * Update develop (#3913) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Feature/gitflow (#3914) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Feature/gitflow (#3921) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Feature/gitflow (#3914) (#3915) * testing gitflow * Name changes * Testing python changes * Added Checkout to Base test * More minor fixes for merge * Minor fix * Added nightly build * Testing Merge * Merge error fix * Merge fix * merge fix * Merge fix * Merge fix * Merge fix * merge fix * [Gitflow] - Minor fix * Nightly build feature * Added branch name docs * poetry add ccxt@latest (#3920) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * poetry add ccxt@latest Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Add crypto dd functions to sdk (#3888) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Add crypto dd functions to sdk * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Fixes currency and trailmap Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Integration tests refactor (#3781) * generate integration tests report * new console report * simple run_scripts * move tests script to folder * add skipping * always display skips * func name * allow running from relative path * rename some vars and time * typo * change portfolio supress and warning * uncomment economy test * rename test controller * multiprocessing * display test progress and available * rename func * mypy * should not be here * small changes * type hinting and docstrings * new subprocesses default * forget context and chunksize * clean len skipt * small comment * fix subproc default with v * minor change * fix path * better this way * make output visible * allow only sequential run with verbose mode * change message * detail * include andrew idea * limit multiprocessing to clone version * fix for package application * must be up here * allow verbose with multiprocessing but warn * update readme * move tests to core * Update README.md * Update README.md * move readme outside * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * Update README.md * parse subproc arg * Update README.md * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Delete glossary base command * move scripts * ruff * update pyproject.toml * update yfinance * fix futures and economy test, rewrite * rewrite stocks test yfinance dependent * refactor sia to yfinance 0.2... * fix last failing sia tests * black * update reqs Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> * Gitflow - Autodoc (#3922) * Hotfix/dots sources (#3928) * fix: wordwrap * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fix: str Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Update dependency: grpcio (#3937) * Update grpcio * Revert "Update grpcio" This reverts commit 676c50a2bdde5ca64614bddd3eaebbccd68c5994. * Update dependencies * Rebase develop? (#3935) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Update installation guides with videos (#3903) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Update installation guides with videos * Add fix for Ruff crashing * Me no longer do what James said * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * broken link (#3889) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * broken link due to quandl.com redirecting to nasdaq.com, for the link to work and get the appropiate API key you need to remove the period at the end of this link... Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: james <jmaslek11@gmail.com> * Issue #3882 Fixed (#3885) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Issue #3882 Fixed * 2 files reformatted by black * tests added * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fixed mypy errors Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * GitFlow - improve check for changes (#3948) Gitflow Implementation * Rewrite and skip yfinance tests (#3953) * economy * fix futures * fix stocks tests * skip unfixable tests * fix ark * Fixed failing badge not used anymore (#3932) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Fix portfolio returns (#3931) * fix inception bug and clean some useless attributes * reorder attributes * add returns and cumulative returns * fix cumulative returns * fix cumulative returns * remove cumulative ret * add some doc and encapsule methods * order detail * add more details on docstrings * wrong docstring * add commnet * Update portfolio_engine.py * fix bug with unsupported type * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fix table header * fix portfolio integration test * ruff * fix tests * rewrite yfinance call * fix test_draw * test_stocks_helper * bt model * fix comp analysis * fix ftd * fix dd * fix screener Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> * Put yf.info behind an exchange flag on `load` (#3951) * Put yf.info behind an exchange flag * Guides Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> * Last Price Bug into Previous Close #3865 (#3949) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add multiple countries option to events (#3938) * allow multiple countries in events cmd * fix test * fix last test * black Co-authored-by: James Maslek <jmaslek11@gmail.com> * Minor Fix for branch name check (#3979) * Gitflow - Added manual trigger to Linting (#3981) * Minor Fix for branch name check * added manual trigger to linting * Linting fix (#3984) Linting fix * Feature/macro convert (#3924) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Issue #3882 Fixed * 2 files reformatted by black * tests added * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * fixed mypy errors * Fixed parser options for currency conversion Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update sma.md (#3956) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update sma.md Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update overlap_model.py (#3955) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update overlap_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update vwap.md (#3971) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update overlap_model.py - wrong typehint (#3970) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * Update overlap_model.py Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Bump yfinance to 0.2.4 and fix tests (#3977) * upgrade yfinance to 0.2.4 * fix some tests failing bc yfinance new date format * fix remaining tests * fix tests * rewrite failing test * black * rerecord test * fix get_1y_sp500 test * missing import here Co-authored-by: Henrique Joaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add extra error handling for yf in etf (#3985) * Fix the news command and making it more stable (#3965) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Hotfix/bug #3945 (#3963) * Add exception to http requests made by ftd * Formatting Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Fix #3787 (#3966) Make the get_equal_weights handle portfolio's with stock's filtered out, due to the stocks having to many NaNs. Co-authored-by: James Maslek <jmaslek11@gmail.com> * Add ticker to the load export file (#3997) * bump * Change export name to have the ticker * revert yaml * Feature/release branch gitflow (#3998) * release branch gitflow implentation * Fix integration tests bugs (#3993) * fix tk * fix newsletters * fix lt * exception on pir * fix attrib bug and remove warning * fix earnings * fix ins, lt, whatif * fillna * fix vis Co-authored-by: James Maslek <jmaslek11@gmail.com> * change .env loading priority (#4005) * [FIX] Pytorch-lightning trainer conflict with TQDM progress bar (#4002) * fix for tqdm progress bar conflict * fix tests Co-authored-by: James Maslek <jmaslek11@gmail.com> * bump * Update release branch * revert conda yaml * logging hash * Fix historical futures plot axes (#4006) * change start date to model * rewrite test * ruff * add end date * move futures and update test * return if wrong dates * fix controller test * record mode rewrite model and view Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update version number * Added scipy to intel * Fix M1 build (#4010) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * adding xgboost explicitly * testing juan sugestion * removing unncessary stuff that the hook deals with Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Add xgboost to intel * add scipy libs to windows only * add scipy sparse * update scipy and pywin * update tests * UPdate installation.md to reflect 2.2 * fix yf unit tests * Try to get futures tests working * Ignore tz in yf download * Found another end date needed * delelte yf cache Co-authored-by: luqazino@gmail.com <luqazino@gmail.com> Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com> Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: Rob-Rychs <Robrychel@gmail.com> Co-authored-by: Mert Nuhuz <mail@mertnuhuz.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Bongani Bendile <58882596+Bonganibendi@users.noreply.github.com> Co-authored-by: Sergio A. S <sergio-abu@proton.me> Co-authored-by: northern-64bit <75195383+northern-64bit@users.noreply.github.com> Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com> * GH Pages fix * Minor fix Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com> Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: Rob-Rychs <Robrychel@gmail.com> Co-authored-by: Mert Nuhuz <mail@mertnuhuz.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Bongani Bendile <58882596+Bonganibendi@users.noreply.github.com> Co-authored-by: Sergio A. S <sergio-abu@proton.me> Co-authored-by: northern-64bit <75195383+northern-64bit@users.noreply.github.com> Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com> * Add back pull request to linting action (#4032) * Fix terminal exit after `--sort p/e` (#4013) * fix scr sort exit * rewrite unit test output * rewind slash replace * rewind slash replace * fix regex * rewrite expected scr tests * black Co-authored-by: James Maslek <jmaslek11@gmail.com> * fix: small typo (#4036) * fix income comparison error (#4029) * Hotfix/fix integration tests (#4025) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * removing leftover test * fix forex test to use simple pairs * fix key error in portfolio test * fix pylint * fix stocks_bt test * fix ca tests * fixing condition * fixing int tests * skipping shroom tests * adding /red * linting * making pre commints happy * linting Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Deprecate reddit commands taking too long to connect to PushshiftAPI (#3999) * fix tk * fix newsletters * fix lt * exception on pir * fix attrib bug and remove warning * fix earnings * fix ins, lt, whatif * fillna * fix vis * timeout reddit func * fix interest * black * pylint * pylint again * back to timeout * rewind * deprecate pushshift api commands * rewrite expected Co-authored-by: James Maslek <jmaslek11@gmail.com> * Feature/release branch gitflow (#4034) * release branch gitflow * installer test * Revert intel build fix * poetry install * Mac build poetry fix * Poetry cache clear * Poetry fix * Added cancel * Minor fix * Github Pages fix * GH page fix * Added condition to docker publish * Fix nightly build * Added hotfix to integration test and build gh run * Minor fix * Edit trigger for integration test * minor corrections Co-authored-by: James Maslek <jmaslek11@gmail.com> * Remove hotfix branch from triggers (#4048) * Refactor `stocks/options/voi,vol,oi,chains` (#4017) * Copy paste all the sheet names (#4035) * bump * Update ALL the exports with sheet name option * Update contributing too * Add in sheet name to each docstring * Update tests * Fix the small things for tests * Converting CONTRIBUTING.md back since I put minimal changes in and it complains * Fix terminal exit after `--sort p/e` (#4013) * fix scr sort exit * rewrite unit test output * rewind slash replace * rewind slash replace * fix regex * rewrite expected scr tests * black Co-authored-by: James Maslek <jmaslek11@gmail.com> * fix: small typo (#4036) * fix income comparison error (#4029) * Update tests due to yfinance error * I broke tests and fixed them * Fix tests? * Missed a few sheet name additions * missed one more * Fix some missing sheet_name parameters * Fix a test I broke * Update tests due to changes with sheet_name * Update stocks and common * Mutual funds just because * Portfolio update * Update Forecast * Update Futures * Update ETF * Update Economy * Update Crypto * Update others * Update documentation to explain --sheet-name * It should be None test * Add None for sheet_name since empty string can result in errors * Formatting * Fix tests * Update documentation * Also update the image * Add back to options commands Co-authored-by: james <jmaslek11@gmail.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com> Co-authored-by: teh_coderer <me@tehcoderer.com> * Upgrade dependencies for bug and for security vulnerabilities. (#4031) * bump * Resolve multiple safety checks. Update thepassiveinvestor * fix conda yml * `openbb.economy.fred_ids` to always return dataframe (#4058) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * returning always a dataframe * Revert "returning always a dataframe" This reverts commitd5dbf3132f. * returning always a dataframe --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> * Refactor requests throughout (#4033) * bump * Initial function write * Delete this line from yaml * Changed all the main things - Need help on tests * pylint errors * Tests v0 * Tests v1 * Tests v2 --------- Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com> * Bumping yfinance to 0.2.9 and updating ruff (#4059) * Clarifies the Balance example by including, `timeframe = '2021'` (#4072) Companies have not finished reporting F/Y 2022 earnings, including `timeframe='2021'` ensures that results are returned. * Fix incorrect column label in nasdaq_model.py (#4063) * Fix incorrect column label in nasdaq_model.py 'Time (GMT)' changed to 'Time (ET)' * Update tests --------- Co-authored-by: petycomppety <30414255+petycomppety@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * fix uk daily data (#4078) Co-authored-by: James Maslek <jmaslek11@gmail.com> * Nightly Build Optimization (#4073) Optimize nightly build * Add keywords and descriptions (#4052) Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Update the routine, portfolio and screener files and adjust the documentation (#4021) * Remove undesired example files * Update the documentation for routines * Add in video * Add some additional text * Add in a routines example that can be activated with --example * Remove default old examples * Add portfolio example holdings file * Add portfolio optimization example allocation file * Add example files for the portfolio menus * Remove code that unintentionaly prints the home menu on every routine * Add home instead of / * Remove requirement to add file if you have an example * Ensure portfolio/po/params also talks about docs correctly * Move all routine, portfolio and screener presets to the correct folder * Remove presets since they are moved * Remove presets since they are moved * Same implementation as for file in po * Adjust code so it works with new folder * Adjust code so it works with new folder * Adjust code a little since I changed folder * Update screener documentation to include how to create a screener * Remove old readme * Update documentation to better reflect where to find the files * Also update SDK notes * Update exe with auto complete and more info * Add images * Update images and the last script * Update text to make it more apparent that it has an example attached * Add section for routine scripts on home menu * Make call_about more robust and add record and stop * Update the routine markdown with info about record/stop including video * Update scripts * Update portfolio report * Update tests and report * fix small load bug * rewrite help test * last fix was buggy * example by default * fix po integration test * keep example on arg * adapt integration test * fix portfolio integration test * fix more portfolio integration tests * pa is not an option anymore * portfolio report choices only holdings * update integration test for portfolio report * Small formatting improvements * Remove sleep and fix inconsistent return * Some spelling * oops * Fix tests --------- Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: James Maslek <jmaslek11@gmail.com> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com> * Improve the `stocks/search` command (#4084) * Improve search command * Make it more intuitive * Fix tests * Update the docs * Ok done * Ok done 2 * Ok done 3 * Git update tests that failed * Update commands with --sheet-name that didn't work (#4088) * Update commands with --sheet-name that didn't work * Fix test * oops * Adds auto completion to `news` (#4089) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * returning always a dataframe * Revert "returning always a dataframe" This reverts commitd5dbf3132f. * quick fix to auto complete args --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Hotfix/Windows-CLI (#4087) * init * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * Update windows10_build.yml * oops --------- Co-authored-by: James Maslek <jmaslek11@gmail.com> * Adds end date to `forex/load` (#4077) * Fix plot look when using eval and add query to choices (#3881) * convert index to datetime and update choices * uncomment economy integration test * fix treasury concat bug * fix datasets concat on duplciates * Lock ruff version so that new lints dont break our CI (#3905) * Lock ruff version so that new lints dont break our CI * Bumped pre-commit ruff version * returning always a dataframe * Revert "returning always a dataframe" This reverts commitd5dbf3132f. * adding end date to the forex load * added some tests * added example * always show msg * rewriting test * updating tests * updating tests * Redo load tests --------- Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: James Maslek <jmaslek11@gmail.com> * Lets release babyyyy * logging hash * Fix yf bug for options and update tests * update windows build to checkout code * switch order --------- Co-authored-by: luqazino@gmail.com <luqazino@gmail.com> Co-authored-by: montezdesousa <79287829+montezdesousa@users.noreply.github.com> Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> Co-authored-by: Chavithra PARANA <chavithra@gmail.com> Co-authored-by: jose-donato <43375532+jose-donato@users.noreply.github.com> Co-authored-by: Jeroen Bouma <jer.bouma@gmail.com> Co-authored-by: Jeroen Bouma <jeroenbouma@Jeroens-MacBook-Pro.local> Co-authored-by: Rob-Rychs <Robrychel@gmail.com> Co-authored-by: Mert Nuhuz <mail@mertnuhuz.com> Co-authored-by: hjoaquim <h.joaquim@campus.fct.unl.pt> Co-authored-by: Bongani Bendile <58882596+Bonganibendi@users.noreply.github.com> Co-authored-by: Sergio A. S <sergio-abu@proton.me> Co-authored-by: northern-64bit <75195383+northern-64bit@users.noreply.github.com> Co-authored-by: martinb-bb <105685594+martinb-bb@users.noreply.github.com> Co-authored-by: Danglewood <85772166+deeleeramone@users.noreply.github.com> Co-authored-by: teh_coderer <me@tehcoderer.com> Co-authored-by: andrewkenreich <andrew.kenreich@gmail.com> Co-authored-by: Peter Oroszvári <30414255+peter-oroszvari@users.noreply.github.com> Co-authored-by: petycomppety <30414255+petycomppety@users.noreply.github.com> Co-authored-by: Diogo Sousa <montezdesousa@gmail.com>
66 KiB
Vendored
CONTRIBUTING
First off, thanks for taking the time to contribute (or at least read the Contributing Guidelines)! 🚀
The following is a set of guidelines for contributing to OpenBB Terminal. These are mostly guidelines, not rules. Use your best judgment, and feel free to propose changes to this document in a pull request.
- CONTRIBUTING
- BASIC
- ADVANCED
BASIC
Adding a new command
Before implementing a new command we highly recommend that you go through Understand Code Structure and Follow Coding Guidelines. This will allow you to get your PR merged faster and keep consistency of our code base.
In the next sections we describe the process to add a new command. shorted command from category dark_pool_shorts and context stocks will be used as
example. Since this command uses data from Yahoo Finance, a yahoofinance_view.py and a yahoofinance_model.py files
will be implemented.
Select Feature
- Pick a feature you want to implement or a bug you want to fix from our issues.
- Feel free to discuss what you'll be working on either directly on the issue or on our Discord.
- This ensures someone from the team can help you and there isn't duplicated work.
Model
- Create a file with the source of data as the name followed by
_modelif it doesn't exist, e.g.yahoofinance_model - Add the documentation header
- Do the necessary imports to get the data
- Define a function starting with
get_ - In that function:
- Use typing hints
- Write a descriptive description where at the end the source is specified
- Utilizing a third party API, get and return the data.
""" Yahoo Finance Model """
__docformat__ = "numpy"
import logging
import pandas as pd
import requests
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import get_user_agent
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def get_most_shorted() -> pd.DataFrame:
"""Get most shorted stock screener [Source: Yahoo Finance]
Returns
-------
pd.DataFrame
Most Shorted Stocks
"""
url = "https://finance.yahoo.com/screener/predefined/most_shorted_stocks"
data = pd.read_html(
request(url, headers={"User-Agent": get_user_agent()}).text
)[0]
data = data.iloc[:, :-1]
return data
Note:
- As explained before, it is possible that this file needs to be created under
common/directory rather thanstocks/, which means that when that happens this function should be done in a generic way, i.e. not mentioning stocks or a specific context. - If the model require an API key, make sure to handle the error and output relevant message.
In the example below, you can see that we explicitly handle 4 important error types:
- Invalid API Keys
- API Keys not authorized for Premium feature
- Empty return payload
- Invalid arguments (Optional)
It's not always possible to distinguish error types using status_code. So depending on the API provider, you can use either error messages or exception.
def get_economy_calendar_events() -> pd.DataFrame:
"""Get economic calendar events
Returns
-------
pd.DataFrame
Get dataframe with economic calendar events
"""
response = request(
f"https://finnhub.io/api/v1/calendar/economic?token={cfg.API_FINNHUB_KEY}"
)
df = pd.DataFrame()
if response.status_code == 200:
d_data = response.json()
if "economicCalendar" in d_data:
df = pd.DataFrame(d_data["economicCalendar"])
else:
console.print("No latest economy calendar events found\n")
elif response.status_code == 401:
console.print("[red]Invalid API Key[/red]\n")
elif response.status_code == 403:
console.print("[red]API Key not authorized for Premium Feature[/red]\n")
else:
console.print(f"Error in request: {response.json()['error']}", "\n")
return df
View
- Create a file with the source of data as the name followed by
_viewif it doesn't exist, e.g.yahoofinance_view - Add the documentation header
- Do the necessary imports to display the data. One of these is the
_modelassociated with this_view. I.e. from same data source. - Define a function starting with
display_ - In this function:
- Use typing hints
- Write a descriptive description where at the end the source is specified
- Get the data from the
_modeland parse it to be output in a more meaningful way. - Ensure that the data that comes through is reasonable, i.e. at least that we aren't displaying an empty dataframe.
- Do not degrade the main data dataframe coming from model if there's an export flag. This is so that the export can
have all the data rather than the short amount of information we may show to the user. Thus, in order to do so
df_data = df.copy()can be useful as if you changedf_data,dfremains intact.
- If the source requires an API Key or some sort of tokens, add
check_api_keydecorator on that specific view. This will throw a warning if users forget to set their API Keys - Finally, call
export_datawhere the variables are export variable, current filename, command name, and dataframe.
""" Yahoo Finance View """
__docformat__ = "numpy"
import logging
import os
from openbb_terminal.decorators import log_start_end
from openbb_terminal.helper_funcs import export_data, print_rich_table
from openbb_terminal.rich_config import console
from openbb_terminal.stocks.dark_pool_shorts import yahoofinance_model
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def display_most_shorted(limit: int = 10, export: str = ""):
"""Display most shorted stocks screener. [Source: Yahoo Finance]
Parameters
----------
limit: int
Number of stocks to display
export : str
Export dataframe data to csv,json,xlsx file
"""
df = yahoofinance_model.get_most_shorted().head(limit)
df.dropna(how="all", axis=1, inplace=True)
df = df.replace(float("NaN"), "")
if df.empty:
console.print("No data found.")
else:
print_rich_table(
df, headers=list(df.columns), show_index=False, title="Most Shorted Stocks"
)
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"shorted",
df,
)
Note: As explained before, it is possible that this file needs to be created under common/ directory rather than
stocks/, which means that when that happens this function should be done in a generic way, i.e. not mentioning stocks
or a specific context. The arguments will need to be parsed by stocks_controller,py and the other controller this
function shares the data output with.
Controller
-
Import
_viewassociated with command we want to allow user to select. -
Add command name to variable
CHOICESfromDarkPoolShortsControllerclass. -
Add command and source to
print_help().def print_help(self): """Print help""" mt = MenuText("stocks/dps/") mt.add_cmd("load") mt.add_raw("\n") mt.add_cmd("shorted") -
If there is a condition to display or not the command, this is something that can be leveraged through this
add_cmdmethod, e.g.mt.add_cmd("shorted", self.ticker_is_loaded). -
Add command description to file
i18n/en.yml. Use the path and command name as key, e.g.stocks/dps/shortedand the value as description. Please fill in other languages if this is something that you know. -
Add a method to
DarkPoolShortsControllerclass with name:call_followed by command name.-
This method must start defining a parser with arguments
add_help=Falseandformatter_class=argparse.ArgumentDefaultsHelpFormatter. In additionprogmust have the same name as the command, anddescriptionshould be self-explanatory ending with a mention of the data source. -
Add parser arguments after defining parser. One important argument to add is the export capability. All commands should be able to export data.
-
If there is a single or even a main argument, a block of code must be used to insert a fake argument on the list of args provided by the user. This makes the terminal usage being faster.
if other_args and "-" not in other_args[0][0]: other_args.insert(0, "-l") -
Parse known args from list of arguments and values provided by the user.
-
Call the function contained in a
_view.pyfile with the arguments parsed by argparse.
-
def call_shorted(self, other_args: List[str]):
"""Process shorted command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="shorted",
description="Print up to 25 top ticker most shorted. [Source: Yahoo Finance]",
)
if other_args and "-" not in other_args[0]:
other_args.insert(0, "-l")
ns_parser = parse_known_args_and_warn(
parser,
other_args,
limit=10,
export=EXPORT_ONLY_RAW_DATA_ALLOWED
)
if ns_parser:
yahoofinance_view.display_most_shorted(
num_stocks=ns_parser.num,
export=ns_parser.export,
)
If a new menu is being added the code looks like this:
@log_start_end(log=logger)
def call_dps(self, _):
"""Process dps command"""
from openbb_terminal.stocks.dark_pool_shorts.dps_controller import (
DarkPoolShortsController,
)
self.queue = self.load_class(
DarkPoolShortsController, self.ticker, self.start, self.stock, self.queue
)
The import only occurs inside this menu call, this is so that the loading time only happens here and not at the terminal startup. This is to avoid slow loading times for users that are not interested in stocks/dps menu.
In addition, note the self.load_class which allows to not create a new DarkPoolShortsController instance but re-load the previous created one. Unless the arguments self.ticker, self.start, self.stock have changed since. The self.queue list of commands is passed around as it contains the commands that the terminal must perform.
Add SDK endpoint
In order to add a command to the SDK, follow these steps:
-
Go to the
sdk.pyfile and scroll to thefunctionsdictionary, it should look like this:functions = { "stocks.get_news": { "model": "openbb_terminal.common.newsapi_model.get_news", }, "stocks.load": { "model": "openbb_terminal.stocks.stocks_helper.load", }, "stocks.candle": { "model": "openbb_terminal.stocks.stocks_helper.load", "view": "openbb_terminal.stocks.stocks_helper.display_candle", }, ... -
Add a new key to the dictionary, which corresponds to the way the added command shall be accessed from the sdk. This is called the
virtual path. In this case it should bestocks.dps.shorted. -
Now it is time to add the value to the key. This key shall be another dictionary with a
modelkey and possibly aviewkey.- The model keys value should be the path from project root to the new commands model function as a string. This
case it is
openbb_terminal.stocks.dark_pool_shorts.yahoofinance_model.get_most_shorted. - If and only if the view function of the command displays a chart, then the
viewkey and its value is the view functions path from the project root as a string. In this example the view function of the only prints a table and thus this step can be ignored.
- The model keys value should be the path from project root to the new commands model function as a string. This
case it is
-
Done!!! The final new dictionary looks like this after the added example:
functions = { ... "stocks.dps.shorted": { "model": "openbb_terminal.stocks.dark_pool_shorts.yahoofinance_model.get_most_shorted", }, ...
Add Documentation
To check whether documentation is added correctly follow Hugo Server instructions.
This is the structure that the documentation follows:
website/content/_index.md
/stocks/_index.md
/load/_index.md
/candle/_index.md
/discovery/_index.md
/ipo/_index.md
/...
/...
/...
/cryptocurrency/_index.md
/chart/_index.md
/defi/_index.md
/borrow/_index.md
/...
/...
/...
/common/_index.md
/technical_analysis/_index.md
/ema/_index.md
/...
/...
Note that the common folder holds features that are common across contexts, e.g. technical analysis can be performed on both stocks or crytpo.
To add a new command, there are two main actions that need to be done:
-
Create a directory with the name of the command and a
_index.mdfile within. Examples:-
When adding
ipo, since this command belongs to contextstocksand categorydiscovery, we added aipofolder with a_index.mdfile within towebsite/content/stocks/discovery. -
When adding
candle, since this command belongs to contextstocks, we added acandlefolder with a_index.mdfile within towebsite/content/stocks/.
-
-
The
_index.mdfile should have the output of thecommand -hfollowed by a screenshot example of what the user can expect. Note that you can now drag and drop the images while editing the readme file on the remote web version of your PR branch. Github will create a link for it with format (https://user-images.githubusercontent.com/***/***.file_format).Example:
usage: ipo [--past PAST_DAYS] [--future FUTURE_DAYS]Past and future IPOs. [Source: https://finnhub.io]
- --past : Number of past days to look for IPOs. Default 0.
- --future : Number of future days to look for IPOs. Default 10.
<IMAGE HERE - Use drag and drop hint mentioned above>
-
Update the Navigation bar to match the content you've added. This is done by adding 2 lines of code to
website/data/menu/, i.e. anameand aref. Example:--- main: - name: stocks ref: "/stocks" sub: - name: load ref: "/stocks/load" - name: candle ref: "/stocks/candle" - name: discovery ref: "/stocks/discovery" sub: - name: ipo ref: "/stocks/discovery/ipo" - name: map ref: "/stocks/discovery/map"
Open a Pull Request
Once you're happy with what you have, push your branch to remote. E.g. git push origin feature/AmazingFeature
A user may create a Draft Pull Request when he/she wants to discuss implementation with the team.
The team will then assign your PR one of the following labels:
| Label name | Description | Example |
|---|---|---|
feat XS |
Extra small feature | Add a preset |
feat S |
Small T-Shirt size Feature | New single command added |
feat M |
Medium T-Shirt size feature | Multiple commands added from same data source |
feat L |
Large T-Shirt size Feature | New category added under context |
feat XL |
Extra Large feature | New context added |
enhancement |
Enhancement | Add new parameter to existing command |
bug |
Fix a bug | Fixes terminal crashing or warning message |
build |
Build-related work | Fix a github action that is breaking the build |
tests |
Test-related work | Add/improve tests |
docs |
Improvements on documentation | Add/improve documentation |
refactor |
Refactor code | Changing argparse location |
docker |
Docker-related work | Add/improve docker |
help wanted |
Extra attention is needed | When a contributor needs help |
do not merge |
Label to prevent pull request merge | When PR is not ready to be merged just yet |
Review Process
As soon as the Pull Request is opened, our repository has a specific set of github actions that will not only run linters on the branch just pushed, but also run pytest on it. This allows for another layer of safety on the code developed.
In addition, our team is known for performing diligent code reviews. This not only allows us to reduce the amount of
iterations on that code and have it to be more future proof, but also allows the developer to learn/improve his coding skills.
Often in the past the reviewers have suggested better coding practices, e.g. using 1_000_000 instead of 1000000 for
better visibility, or suggesting a speed optimization improvement.
Understand Code Structure
Backend
CLI 💻 → _controller.py 🤖 → _view.py 🎨 → _model.py 🧠
chart=True
chart=False
↑
sdk.py 🏭
↑
| File | Role | Description |
|---|---|---|
| _controller.py 🤖 | The router/input validator | The controller file should hold the least amount of logic possible. Its role is to be a stupid (no logic) router and redirect the command correctly while checking the input with argparser. |
| _view.py 🎨 | The artist | The view file should only output or visualise the data it gets from the _model file! The _view can limit the data coming from the _model, otherwise the data object should be identical in the _view and the _model files. |
| _model.py 🧠 | The brain | The model file is where everything fun happens. The data is gathered (external APIs), processed and returned here. |
| sdk.py 🏭 | The SDK Factory | The SDK file is where the callable functions are created for the SDK. There is only one SDK file in the openbb_terminal folder. |
Frontend
| Item | Description | Example |
|---|---|---|
| CONTEXT | Specific instrument world to analyse. | stocks, crypto, economy |
| CATEGORY | Group of similar COMMANDS to do on the instrument There are the specialized categories, specific to each CONTEXT and there are common categories which are not specific to one CONTEXT. |
due_diligence, technical_analysis, insider |
| COMMAND | Operation on one or no instrument that retrieves data in form of string, table or plot. | rating, supplier, sentiment |
The following layout is expected: /<context>/<category>/<command_files>
If there are sub-categories, the layout will be: /<context>/<category>/<sub-category>/<command_files>
Example:
openbb_terminal/stocks/stocks_controller.py
/stocks_helper.py
/due_diligence/dd_controller.py
/marketwatch_view.py
/marketwatch_model.py
/finviz_view.py
/finviz_model.py
/technical_analysis/ta_controller.py
/tradingview_view.py
/tradingview_model.py
/common/technical_analysis/overlap_view.py
/overlap_model.py
/crypto/crypto_controller.py
/crypto_helper.py
/due_diligence/dd_controller.py
/binance_view.py
/binance_model.py
/technical_analysis/ta_controller.py
With:
| Context | Category | File | Description |
|---|---|---|---|
stocks/ |
stocks_controller.py |
Manages stocks context from a user perspective, i.e. routing commands and arguments to output data, or, more importantly, redirecting to the selected category. | |
stocks/ |
stocks_helper.py |
Helper to stocks menu. This file is meant to hold generic purpose stocks functionalities. |
|
stocks/ |
due_diligence/ |
dd_controller.py |
Manages due_diligence category from stocks context from a user perspective, i.e. routing commands and arguments to output data. |
stocks/ |
due_diligence/ |
marketwatch_view.py |
This file contains functions that rely on Market Watch data. These functions represent commands that belong to due_diligence category from stocks context. These functions are called by dd_controller.py using the arguments given by the user and will output either a string, table or plot. |
stocks/ |
due_diligence/ |
marketwatch_model.py |
This file contains functions that rely on Market Watch data. These functions represent commands that belong to due_diligence category from stocks context. These functions are called by marketwatch_view.py and will return data to be processed in either a string, dictionary or dataframe format. |
stocks/ |
due_diligence/ |
finviz_view.py |
This file contains functions that rely on Finviz data. These functions represent commands that belong to due_diligence category from stocks context. These functions are called by dd_controller.py using the arguments given by the user and will output either a string, table or plot. |
stocks/ |
due_diligence/ |
finviz_model.py |
This file contains functions that rely on Finviz data. These functions represent commands that belong to due_diligence category from stocks context. These functions are called by finviz_view.py and will return data to be processed in either a string, dictionary or dataframe format. |
stocks/ |
technical_analysis/ |
ta_controller.py |
Manages technical_analysis category from stocks context from a user perspective, i.e. routing commands and arguments to output data. |
stocks/ |
technical_analysis/ |
tradingview_view.py |
This file contains functions that rely on TradingView data. These functions represent commands that belong to technical_analysis category from stocks context. These functions are called by ta_controller.py using the arguments given by the user and will output either a string, table or plot. |
stocks/ |
technical_analysis/ |
tradingview_model.py |
This file contains functions that rely on TradingView data. These functions represent commands that belong to technical_analysis category from stocks context. These functions are called by tradingview_view.py and will return data to be processed in either a string, dictionary or dataframe format. |
common/ |
technical_analysis/ |
overlap_view.py |
This file contains functions that rely on overlap data. In this case overlap is not a data source, but the type of technical analysis performed. These functions represent commands that belong to technical_analysis category from MULTIPLE contexts. These functions are called by ta_controller.py, from MULTIPLE contexts, using the arguments given by the user and will output either a string, table or plot. Due to the fact that this file is common to multiple contexts the functions need to be generic enough to accommodate for this. E.g. if we are providing a dataframe to these functions, we should make sure that stocks/ta_controller.py and crypto/ta_controller use the same formatting. |
common/ |
technical_analysis/ |
overlap_model.py |
This file contains functions that rely on overlap data. In this case overlap is not a data source, but the type of technical analysis performed. These functions represent commands that belong to technical_analysis category from MULTIPLE contexts. These functions are called by overlap_view.py, and will return data to be processed in either a string, dictionary or dataframe format. Due to the fact that this file is common to multiple contexts the functions need to be generic enough to accommodate for this. E.g. if we are getting the sentiment of an instrument, we should ensure that these functions accept both a "GME" or a "BTC", for stocks and crypto, respectively. |
Follow Coding Guidelines
General Code Requirements
-
Each function should have default values for non critical kwargs
- Why? It increases code readability and acts as an input example for the functions arguments. This increases the ease of use of the functions through the SDK, but also just generally.
Good code ✅ Bad code ❌ def display_last_uni_swaps( top: int = 10, sortby: str = "timestamp", descend: bool = False, export: str = "",) -> None:def display_last_uni_swaps( top: int, sortby: str, descend: bool, export: str,) -> None:
-
Simple and understandable input objects; avoid for example weird dictionaries packed with data: {“title”: DataFrame}
- Why? Ease of use and often these complex formats are clumsy, prone to error and the formatting required for complex parameters is time consuming and unneeded.
Good code ✅ Bad code ❌ def get_coins( top: int = 250, category: str = "") -> pd.DataFrame:def load( file: str, file_types: list, data_files: Dict[Any, Any], data_examples: Dict[Any, Any],) -> pd.DataFrame:
-
Each function needs to have a docstring explaining what it does, its parameters and what it returns.
- Why? You can use the function without reading its source code. This improves the developing experience and SDK usage. The SDK factory also can’t handle functions with out docstrings.
-
Consistent and clear argument naming; not
symbolin_viewand thentickerin_file-> ticker everywhere; the name should be descriptive of what information it holds (see Style Guide section below)- Why? You can quickly understand what the input should be; example: tickers and stock names are fundamentally different, but they’re both strings so they should be named accordingly.
Good code ✅ Bad code ❌ data: pd.Series, dataset_name: str, y_label: str,data: pd.Series, dataset: str, column: str,
-
Classes (for example the portfolio class) should hold the relevant data and perform no other calculations, these calculations should be done in an independent function.
- Why? Two reasons:
These calculations can then be used outside of the class with custom data; for example via the sdk or for tests.
from openbb_terminal.portfolio.portfolio_helper import get_gaintopain_ratio # Direct function access get_gaintopain_ratio(historical_trade_data, benchmark_trades, benchmark_returns)The function can be loaded in SDK factory as an endpoint and user can get result by passing the class instance.
from openbb_terminal.sdk import openbb from openbb_terminal.sdk import Portfolio transactions = Portfolio.read_orderbook("../../portfolio/holdings/example.csv") P = Portfolio(transactions) P.generate_portfolio_data() P.set_benchmark() # SDK endpoint access openbb.portfolio.gaintopain(P)Good code ✅ Bad code ❌ def get_gaintopain_ratio(portfolio: PortfolioEngine) -> pd.DataFrame: """...""" gtp_period_df = portfolio_helper.get_gaintopain_ratio( portfolio.historical_trade_data, portfolio.benchmark_trades, portfolio.benchmark_returns) return gtp_period_dfdef get_gaintopain_ratio(self) -> pd.DataFrame: """...""" vals = list() for period in portfolio_helper.PERIODS: port_rets = portfolio_helper.filter_df_by_period(self.portfolio_returns, period) bench_rets = portfolio_helper.filter_df_by_period(self.benchmark_returns, period) ...
-
Naming among related model and view functions should be obvious; just different prefix if possible
- Why? Eases SDK factory mapping and keeps code clean.
Good code ✅ Bad code ❌ # [fred_view.py] def display_yieldcurve(country: str): df = fred_model.get_yieldcurve(country) … # [fred_model.py] def get_yieldcurve(country: str) -> pd.Dataframe: …# [fred_view.py] def display_bondscrv(country: str): df = fred_model.get_yieldcurve(country) … # [fred_model.py] def get_yldcurve(country: str) -> pd.Dataframe: …
File Specific Requirements
-
No data altering in the view file or controller file (view and model with same args)
- Why? Consistency and good code structure. This also improves the SDK user experience. Thus follows that view and model files will have the same arguments (except for output options like raw, export, external_axes), since no data changes shall be done in the view file.
-
Each model (get_) should almost always have its own view function (display_)
-
Why? To respect the principles laid out in Code Structure and the previous bullet point. If your code does not have this
get_→display_map it’s likely that i. and/or ii. fail to hold.i. Data is processed in
_modelfiles and displayed in_viewfilesii.
_viewand_modelfiles will have the same arguments (except for output options)
-
Coding Style
When in doubt, follow https://www.python.org/dev/peps/pep-0008/.
OpenBB Style Guide
The style guide is a reverse dictionary for argument names, where a brief definition is mapped to an OpenBB recommended argument name and type. When helpful a code snippet example is added below. Following this guide will help keep argument naming consistent and improve SDK users experience.
Style guide structure:
<definition> : <argument_name (argument_type)> e.g. <examples>
def func(..., argument_name: argument_type = default, ...):
...
Flags
Show raw data : raw (bool)
def display_data(..., raw: bool = False, ...):
...
if raw:
print_rich_table(...)
Sort in ascending order : ascend (bool)
def display_data(..., sortby: str = "", ascend: bool = False, ...):
...
if sortby:
data = data.sort_values(by=sortby, ascend=ascend)
Show plot : plot (bool)
def display_data(..., plot: bool = False, ...):
...
if plot:
...
ax.plot(...)
Output format
Format to export data : export (str), e.g. csv, json, xlsx
def display_data(..., export: str = "", ...):
...
export_data(export, os.path.dirname(os.path.abspath(__file__)), "func", data)
List of external axes to include in a plot : external_axes (Optional[List[plt.Axes]])
def display_data(..., external_axes: Optional[List[plt.Axes]] = None, ...):
...
if external_axes is None:
_, ax = plt.subplots(figsize=plot_autoscale(), dpi=PLOT_DPI)
else:
ax = external_axes[0]
ax.plot(...)
Field by which to sort : sortby (str), e.g. "Volume"
def display_data(..., sortby: str = "col", ...):
...
if sortby:
data = data.sort_values(by=sortby)
Maximum limit number of output items : limit (int)
def display_data(..., limit = 10, ...):
...
print_rich_table(
data[:limit],
...
)
Time-related
Date from which data is fetched (YYYY-MM-DD) : start_date (str), e.g. 2022-01-01
Date up to which data is fetched (YYYY-MM-DD) : end_date (str), e.g. 2022-12-31
Note: We want to accept dates in string because it is easier to deal from user standpoint. Inside the function you can convert it to datetime and check its validity. Please specify date format in docstring.
def get_historical_data(..., start_date: str = "2022-01-01", end_date: str = "2022-12-31",):
"""
...
Parameters
----------
start_date: str
Date from which data is fetched in format YYYY-MM-DD
end_date: str
Date up to which data is fetched in format YYYY-MM-DD
...
"""
data = source_model.get_data(data_name, start_date, end_date, ...)
Year from which data is fetched (YYYY) : start_year (str), e.g. 2022
Year up to which data is fetched (YYYY) : end_year (str), e.g. 2023
def get_historical_data(..., start_year: str = "2022", end_year str = "2023", ...):
...
data = source_model.get_data(data_name, start_year, end_year, ...)
Interval for data observations : interval (str), e.g. 60m, 90m, 1h
def get_prices(interval: str = "60m", ...):
...
data = source.download(
...,
interval=interval,
...
)
Rolling window length : window (int/str), e.g. 252, 252d
def get_rolling_sum(returns: pd.Series, window: str = "252d"):
rolling_sum = returns.rolling(window=window).sum()
Data selection and manipulation
Search term used to query : query (str)
Maximum limit of search items/periods in data source: limit (int)
Note: please specify limit application in docstring
def get_data_from_source(..., limit: int = 10, ...):
"""
Parameters
----------
...
limit: int
Number of results to fetch from source
...
"""
data = source.get_data(data_name, n_results=limit, ...)
Dictionary of input datasets : datasets (Dict[str, pd.DataFrame])
Note: Most occurrences are on the econometrics menu and might be refactored in near future
Input dataset : data (pd.DataFrame)
def process_data(..., data: pd.DataFrame, ...):
"""
...
Parameters
----------
...
data : pd.DataFrame
Dataframe of ...
...
"""
col_data = pd.DataFrame(data["Col"])
Dataset name : dataset_name (str)
Input series : data (pd.Series)
Dependent variable series : dependent_series (pd.Series)
Independent variable series : independent_series (pd.Series)
def get_econometric_test(dependent_series, independent_series, ...):
...
dataset = pd.concat([dependent_series, independent_series], axis=1)
result = econometric_test(dataset, ...)
Country name : country (str), e.g. United States, Portugal
Country initials or abbreviation : country_code (str) e.g. US, PT, USA, POR
Currency to convert data : currency (str) e.g. EUR, USD
Financial instrument characteristics
Instrument ticker, name or currency pair : symbol (str), e.g. AAPL, ethereum, ETH, ETH-USD
def get_prices(symbol: str = "AAPL", ...):
...
data = source.download(
tickers=symbol,
...
)
Instrument name: name (str)
Note: If a function has both name and symbol as parameter, we should distinguish them and call it name
List of instrument tickers, names or currency pairs : symbols (List/List[str]), e.g. ["AAPL", "MSFT"]
Base currency under BASE-QUOTE → XXX-YYY convention : from_symbol (str), e.g. ETH in ETH-USD
Quote currency under BASE-QUOTE → XXX-YYY convention : to_symbol (str), e.g. USD in ETH-USD
def get_exchange_rate(from_symbol: str = "", to_symbol: str = "", ...):
...
df = source.get_quotes(from_symbol, to_symbol, ...)
Instrument price : price (float)
Instrument implied volatility : implied_volatility (float)
Option strike price : strike_price (float)
Option days until expiration : time_to_expiration (float/str)
Risk free rate : risk_free_rate (float)
Options expiry date : expiry (str)
Naming Convention
- The name of the variables must be descriptive of what they stand for. I.e.
tickeris descriptive,auxis not. - Single character variables must be avoided. Except if they correspond to the iterator of a loop.
Docstrings
The docstring format used in numpy, an example is shown below:
def command_foo(var1: str, var2: List[int], var3: bool = False) -> Tuple[int, pd.DataFrame]:
"""Small description
[Optional: Longer description]
Parameters
----------
var1 : str
var1 description
var2 : List[int]
var2 description
var3 : bool, optional
var3 description
Returns
-------
foo : int
returned foo description
pd.DataFrame
dataframe returned
"""
Linters
The following linters are used by our codebase:
| Linter | Description |
|---|---|
| bandit | security analyzer |
| black | code formatter |
| codespell | spelling checker |
| flake8 | style guide enforcer |
| mypy | static typing checker |
| pyupgrade | upgrade syntax for newer versions |
| safety | checks security vulnerabilities |
| pylint | bug and quality checker |
| markdownlint | markdown linter |
Command names
-
The command name should be as short as possible.
-
The command name should allow the user to know what the command refers to without needing to read description. (e.g.
earn)- If this is not possible, then the command name should be an abbreviation of what the functionality corresponds to (e.g.
ycrvforyield curve)
- If this is not possible, then the command name should be an abbreviation of what the functionality corresponds to (e.g.
-
The command name should not have the data source explicit
UI and UX
It is important to keep a coherent UI/UX throughout the terminal. These are the rules we must abide:
- There is 1 single empty line between user input and start of the command output.
- There is 1 single empty line between command output and the user input.
- The menu help has 1 empty line above text and 1 empty line below. Both still within the rectangular panel.
- From menu help rectangular panel there's no empty line below - this makes it more clear to the user that they are inside such menu.
External API Keys
Creating API key
OpenBB Terminal currently has over 100 different data sources. Most of these require an API key that allows access to some free tier features from the data provider, but also paid ones.
When a new API data source is added to the platform, it must be added through config_terminal.py. E.g.
# https://messari.io/
API_MESSARI_KEY = os.getenv("OPENBB_API_MESSARI_KEY") or "REPLACE_ME"
Note that a OPENBB_ is added so that the user knows that that environment variable is used by our terminal.
Setting and checking API key
One of the first steps once adding a new data source that requires an API key is to add that key to our keys_controller.py. This menu allows the user to set API keys and check their validity.
The following code allows to check the validity of the IEX Cloud API key.
def check_iex_key(show_output: bool = False) -> str:
"""Check IEX Cloud key
Parameters
----------
show_output: bool
Display status string or not.
Returns
-------
status: str
"""
if cfg.API_IEX_TOKEN == "REPLACE_ME": # nosec
logger.info("IEX Cloud key not defined")
status = KeyStatus.NOT_DEFINED
else:
try:
pyEX.Client(api_token=cfg.API_IEX_TOKEN, version="v1").quote(symbol="AAPL")
logger.info("IEX Cloud key defined, test passed")
status = KeyStatus.DEFINED_TEST_PASSED
except Exception as _: # noqa: F841
logger.warning("IEX Cloud key defined, test failed")
status = KeyStatus.DEFINED_TEST_FAILED
if show_output:
console.print(status.colorize() + "\n")
return status
Note that there are usually 3 states:
- defined, test passed: The user has set their API key and it is valid.
- defined, test failed: The user has set their API key but it is not valid.
- not defined: The user has not defined any API key.
Note: Sometimes the user may have the correct API key but still not have access to a feature from that data source, and that may be because such feature required an API key of a higher level.
A function can then be created with the following format to allow the user to change its environment key directly from the terminal.
@log_start_end(log=logger)
def call_iex(self, other_args: List[str]):
"""Process iex command"""
parser = argparse.ArgumentParser(
add_help=False,
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
prog="iex",
description="Set IEX Cloud API key.",
)
parser.add_argument(
"-k",
"--key",
type=str,
dest="key",
help="key",
)
if not other_args:
console.print("For your API Key, visit: https://iexcloud.io\n")
return
if other_args and "-" not in other_args[0][0]:
other_args.insert(0, "-k")
ns_parser = parse_simple_args(parser, other_args)
if ns_parser:
self.status_dict["iex"] = keys_model.set_iex_key(
key=ns_parser.key, persist=True, show_output=True
)
ADVANCED
Important functions and classes
Base controller class
This BaseController class is inherited by all controllers on the terminal.
This class contains both important variables and methods that are common across all terminal controllers.
CHOICES_COMMON: List of common commands across all controllers
cls: clear screenhome: go back to the main rootabout: allows to open our documentation directly on the menu or commandh,?andhelp: display the help menu the user is inq,quitand..: go back to one menu aboveexit: exit the platformrandreset: reset the platform (reading code and settings again but going into the same state)support: create a support request ticket
All of these variables have a call_FUNCTION associated with them.
Worthy methods to mention are:
load_class: Checks for an existing instance of the controller before creating a new one to speed up access to that menu.custom_reset: Should be used by controllers that rely on a state variable - meant to be overridden. They should add the commands necessary to have the same data loaded.print_help: Meant to be overridden by each controllerparse_input: Processes the string the user inputs into a list of actionable commandsswitch: Acts upon the command action receivedparse_known_args_and_warn: Parses the command with the-and--flags and variables. Some built-in flags are:export_allowed: Which can be set to_NO_EXPORT_,_EXPORT_ONLY_RAW_DATA_ALLOWED_,_EXPORT_ONLY_FIGURES_ALLOWED_and_EXPORT_BOTH_RAW_DATA_AND_FIGURES_raw: Displaying the data rawlimit: Number of rows to display
menu: Most important method. When a menu is executed, the way to call it is throughstocks_menu.menu()
Default Data Sources
The document data_sources_default.json contains all data sources that the terminal has access to and specifies the data source utilized by default for each command.
The convention is as follows:
{
"stocks": {
"search": ["FinanceDatabase"],
"quote": ["YahooFinance"],
"candle": [],
"load": [
"YahooFinance",
"IEXCloud",
"AlphaVantage",
"Polygon",
"EODHD"
],
"options": {
"unu": ["FDScanner"],
"calc": [],
"screen": {
"view": ["Syncretism"],
"set": [],
"scr": ["Syncretism"]
},
"load": [
"YahooFinance",
"Tradier",
"Nasdaq"
],
"exp": [
"YahooFinance",
"Tradier",
"Nasdaq"
],
...
The way to interpret this file is by following the path to a data source, e.g.
stocks/searchrelies onFinanceDatabasestocks/candledoes not rely on any data source. This means that it relies on data that has been loaded before.stocks/loadrelies onYahooFinance,IEXCloud,AlphaVantage,PolygonorEODHD.- The order is important as the first data source is the one utilized by default.
stoks/options/unurelies onFDScanner.stocks/options/exprelies onYahooFinanceby default butTradierandNasdaqsources are allowed.
Export Data
In the _view.py files it is common having at the end of each function export_data being called. This typically looks like:
export_data(
export,
os.path.dirname(os.path.abspath(__file__)),
"contracts",
df_contracts
)
Let's go into each of these arguments:
exportcorresponds to the type of file we are exporting.- If the user doesn't has anything selected, then this function doesn't do anything.
- The user can export multiple files and even name the files.
- The allowed type of files
json,csv,xlsxfor raw data andjpg,png,svgfor figures depends on theexport_allowedvariable defined inparse_known_args_and_warn.
os.path.dirname(os.path.abspath(__file__))corresponds to the directory path- This is important when
export folderselected is the default because the data gets stored based on where it is called. - If this is called from a
commonfolder, we can useos.path.dirname(os.path.abspath(__file__)).replace("common", "stocks")insteaad
- This is important when
"contracts"corresponds to the name of the exported file (+ unique datetime) if the user doesn't provide onedf_contractscorresponds to the dataframe with data. Although we don't call this function with the figure reference, because it is open, we can useplt.savefigto achieve that.
If export_allowed=EXPORT_BOTH_RAW_DATA_AND_FIGURES in parse_known_args_and_warn, valid examples are:
cmd --export csvcmd --export csv,png,jpgcmd --export mydata.csvcmd --export mydata.txt,alsomydata.csv,alsoalsomydata.png
Note that these files are saved on a location based on the environment variable: EXPORT_FOLDER_PATH. Which can be set in settings/export.
The default location is the exports folder and the data will be stored with the same organization of the terminal. But, if the user specifies the name of the file, then that will be dropped onto the folder as is with the datetime attached.
Queue and pipeline
The variable self.queue contains a list of all actions to be run on the platform. That is the reason why this variable is always passed as an argument to a new controller class and received back.
self.queue = self.load_class(
DarkPoolShortsController, self.ticker, self.start, self.stock, self.queue
)
Example:
If a user is in the root of the terminal and runs:
stocks/load AAPL/dps/psi -l 90
The queue created becomes:
self.queue = ["stocks", "load AAPL", "dps", "psi -l 90"]
And the user goes into the stocks menu and runs load AAPL. Then the queue is updated to
self.queue = ["dps", "psi -l 90"]
At that point the user goes into the dps menu and runs the command psi with the argument -l 90 therefore displaying price vs short interest of the past 90 days.
Auto Completer
In order to help users with a powerful autocomplete, we have implemented our own (which can be found here).
This STATIC list of options is meant to be defined on the __init__ method of a class as follows.
if session and obbff.USE_PROMPT_TOOLKIT:
self.choices: dict = {c: {} for c in self.controller_choices}
self.choices["overview"] = {
"--type": {c: None for c in self.overview_options},
"-t": "--type",
}
self.choices["futures"] = {
"--commodity": {c: None for c in self.futures_commodities},
"-c": "--commodity",
"--sortby": {c: None for c in self.wsj_sortby_cols_dict.keys()},
"-s": "--sortby",
"--reverse": {},
"-r": "--reverse",
}
self.choices["map"] = {
"--period": {c: None for c in self.map_period_list},
"-p": "--period",
"--type": {c: None for c in self.map_filter_list},
"-t": "--type",
}
self.completer = NestedCompleter.from_nested_dict(self.choices)
Important things to note:
self.choices: dict = {c: {} for c in self.controller_choices}: this allows users to have autocomplete on the command that they are allowed to select in each menuself.choices["overview"]: this corresponds to the list of choices that the user is allowed to select after specifying$ overview"--commodity": {c: None for c in self.futures_commodities}: this allows the user to select several commodity values after--commodityflag"-c": "--commodity": this is interpreted as-chaving the same effect as--commodity"--reverse": {}: corresponds to a boolean flag (does not expect any value after)"--start": None: corresponds to a flag where the values allowed are not easily discrete due to vast rangeself.completer = NestedCompleter.from_nested_dict(self.choices): from the choices create our custom completer
In case the user is interested in a DYNAMIC list of options which changes based on user's state, then a class method must be defined.
The example below shows the update_runtime_choices method being defined in the options controller.
def update_runtime_choices(self):
"""Update runtime choices"""
if self.expiry_dates and session and obbff.USE_PROMPT_TOOLKIT:
self.choices["exp"] = {str(c): {} for c in range(len(self.expiry_dates))}
self.choices["exp"]["-d"] = {c: {} for c in self.expiry_dates + [""]}
self.completer = NestedCompleter.from_nested_dict(self.choices)
This method should only be called when the user's state changes leads to the auto-complete not being accurate.
In this case, this method is called as soon as the user successfully loads a new ticker since the options expiry dates vary based on the ticker. Note that the completer is recreated from it.
Logging
A logging system is used to help tracking errors inside the OpenBBTerminal.
This is storing every logged message inside the following location :
$HOME/OpenBBUserData/logs
Where $HOME is the user home directory, for instance:
C:\Users\fooif your are in Windows and your name is foo/home/bar/if you are is macOS or Linux and your name is bar
The user can override this location using the settings key OPENBB_USER_DATA_DIRECTORY.
If you want to log a particular message inside a function you can do like so:
import logging
logger = logging.getLogger(__name__)
def your_function() -> pd.DataFrame:
logger.info("Some log message with the level INFO")
logger.warning("Some log message with the level WARNING")
logger.fatal("Some log message with the level FATAL")
You can also use the decorator @log_start_end to automatically record a message every time a function starts and ends, like this:
import logging
from openbb_terminal.decorators import log_start_end
logger = logging.getLogger(__name__)
@log_start_end(log=logger)
def your_function() -> pd.DataFrame:
pass
Internationalization
WORK IN PROGRESS - The menu can be internationalised BUT we do not support yet help commands-h internationalization.
In order to add support for a new language, the best approach is to:
- Copy-paste
i18n/en.yml - Rename that file to a short version of language you are translating to, e.g.
i18n/pt.ymlfor portuguese - Then just update the text on the right. E.g.
stocks/NEWS: latest news of the company
becomes
stocks/NEWS: mais recentes notícias da empresa
Note: To speed up translation, the team developed a script that uses Google translator API to help translating the entire en.yml document to the language of choice. Then the output still needs to be reviewed, but this can be an useful bootstrap.
This is the convention in use for creating a new key/value pair:
stocks/search- Understockscontext, short commandsearchdescription on thehelp menustocks/SEARCH- Understockscontext, long commandsearchdescription, whensearch -hstocks/SEARCH_query- Understockscontext,querydescription when inquiring aboutsearchcommand withsearch -hstocks/_ticker- Understockscontext,_tickeris used as a key of a parameter, and the displayed parameter description is given as valuecrypto/dd/_tokenomics_- Undercryptocontext and underddmenu,_tokenomics_is used as a key of an additional information, and the displayed information is given as value
Write Code and Commit
At this stage it is assumed that you have already forked the project and are ready to start working.
Pre Commit Hooks
Git hook scripts are useful for identifying simple issues before submission to code review. We run our hooks on every commit to automatically point out issues in code such as missing semicolons, trailing whitespace, and debug statements. By pointing these issues out before code review, this allows a code reviewer to focus on the architecture of a change while not wasting time with trivial style nitpicks.
Install the pre-commit hooks by running: pre-commit install.
Coding
Although the Coding Guidelines section has been already explained, it is worth mentioning that if you want to be faster
at developing a new feature, you may implement it first on a jupyter notebook and then carry it across to the
terminal. This is mostly useful when the feature relies on scraping data from a website, or implementing a Neural
Network model.
Git Process
- Create your Feature Branch, e.g.
git checkout -b feature/AmazingFeature - Check the files you have touched using
git status - Stage the files you want to commit, e.g.
git add openbb_terminal/stocks/stocks_controller.py openbb_terminal/stocks/stocks_helper.py. Note: DON'T addconfig_terminal.pyor.envfiles with personal information, or evenfeature_flags.pywhich is user-dependent. - Write a concise commit message under 50 characters, e.g.
git commit -m "meaningful commit message". If your PR solves an issue raised by a user, you may specify such issue by adding #ISSUE_NUMBER to the commit message, so that these get linked. Note: If you installed pre-commit hooks and one of the formatters re-formats your code, you'll need to go back to step 3 to add these.
Branch Naming Conventions
The accepted branch naming conventions are:
feature/feature-namehotfix/hotfix-namerelease/2.1.0orrelease/2.1.0rc0.
All feature/feature-name related branches can only have PRs pointing to develop branch. hotfix/hotfix-name and release/2.1.0 or release/2.1.0rc0 branches can only have PRs pointing to main branch.
Add a Test
Unit tests minimize errors in code and quickly find errors when they do arise. Integration tests are standard usage examples, which are also used to identify errors.
A thorough introduction on the usage of unit tests and integration tests in OpenBBTerminal can be found on the following page respectively:
In short:
- Pytest: is the tool we are using to run our tests, with the command:
pytest tests/ - Coverage: can be checked like running
coverage run -m pytestorcoverage html
Installers
When implementing a new feature or fixing something within the codebase, it is necessary to ensure that it is working appropriately on the terminal. However, it is equally as important to ensure that new features or fixes work on the installer terminal too. This is because a large portion of users utilize the installer to use OpenBB Terminal. More information on how to build an installer can be found here.