tfukaza / harvest

Simple and intuitive Python framework for algorithmic trading. Easily create bots to live and paper trade stocks, crypto, and options!
https://tfukaza.github.io/harvest-website
MIT License
124 stars 26 forks source link

Major update to test framework #261

Closed tfukaza closed 2 years ago

tfukaza commented 2 years ago

The biggest change in this PR is the updated and near-final live testing framework. Running unit tests in test/livetests will execute a series of test that will use a real broker for tests.

The directory contains three types of files:

For the first two, there is a decorator @decorator_repeat_test defined. This allows the same test to be run for different brokers. For example, decorating a test with @decorator_repeat_test([Robinhood, Webull]) will run the test for Robinhood and Webull.

Currently only Robinhood is being tested, as other brokers seem to have lots of bugs. We want to hold off debugging those until the API class API is stabilized.

For now, we ask developers to run these tests locally with their own credentials. To run the tests, the SECRET_PATH env variable needs to be set to specify where secret.yaml is for the brokers.

codecov[bot] commented 2 years ago

Codecov Report

Merging #261 (162c84b) into main (fcdd55d) will decrease coverage by 0.14%. The diff coverage is 20.53%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #261      +/-   ##
==========================================
- Coverage   55.63%   55.48%   -0.15%     
==========================================
  Files          24       24              
  Lines        3764     3765       +1     
==========================================
- Hits         2094     2089       -5     
- Misses       1670     1676       +6     
Flag Coverage Δ
unittests 55.48% <20.53%> (-0.15%) :arrow_down:

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
harvest/api/alpaca.py 3.04% <0.00%> (-0.17%) :arrow_down:
harvest/api/kraken.py 2.38% <0.00%> (+0.05%) :arrow_up:
harvest/api/paper.py 83.78% <ø> (ø)
harvest/api/robinhood.py 1.51% <0.00%> (-0.03%) :arrow_down:
harvest/api/webull.py 1.47% <0.00%> (ø)
harvest/storage/base_storage.py 81.08% <57.14%> (+1.97%) :arrow_up:
harvest/api/_base.py 69.20% <66.66%> (-1.54%) :arrow_down:
harvest/utils.py 86.62% <81.81%> (+0.33%) :arrow_up:
harvest/api/yahoo.py 82.75% <100.00%> (+0.09%) :arrow_up:
harvest/trader/trader.py 84.34% <100.00%> (+0.11%) :arrow_up:
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update b834c0c...162c84b. Read the comment docs.