diff --git a/.github/workflows/lint_python.yml b/.github/workflows/lint_python.yml new file mode 100644 index 00000000000..3365e5f3f6b --- /dev/null +++ b/.github/workflows/lint_python.yml @@ -0,0 +1,20 @@ +name: lint_python +on: [pull_request, push] +jobs: + lint_python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v2 + - run: pip install bandit black codespell flake8 isort mypy pytest pyupgrade safety + - run: bandit -r . || true + - run: black --check . || true + - run: codespell --ignore-words-list="mape" --quiet-level=2 # --skip="" + - run: flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics + - run: isort --check-only --profile black . || true + - run: pip install -r requirements.txt || true + - run: mypy --ignore-missing-imports . || true + - run: pytest . || true + - run: pytest --doctest-modules . || true + - run: shopt -s globstar && pyupgrade --py36-plus **/*.py || true + - run: safety check diff --git a/discovery/short_interest_api.py b/discovery/short_interest_api.py index 901fc555723..351eec49bb4 100644 --- a/discovery/short_interest_api.py +++ b/discovery/short_interest_api.py @@ -43,7 +43,7 @@ def high_short_interest(l_args): l_stock_info = list() for elem in a_high_short_interested_stocks: - if elem is '': + if elem == '': continue l_stock_info.append(elem) @@ -92,7 +92,7 @@ def low_float(l_args): l_stock_info = list() for elem in a_low_float_stocks: - if elem is '': + if elem == '': continue l_stock_info.append(elem) @@ -103,4 +103,4 @@ def low_float(l_args): pd.set_option('display.max_colwidth', -1) print(df_low_float.head(n=ns_parser.n_num).to_string(index=False)) - print("") \ No newline at end of file + print("") diff --git a/fundamental_analysis/README.md b/fundamental_analysis/README.md index 2501ab3ad88..f5cdc6046e7 100644 --- a/fundamental_analysis/README.md +++ b/fundamental_analysis/README.md @@ -178,7 +178,7 @@ Prints a complete balance sheet statement over time. This can be either quarterl ``` usage: cash [-n N_NUM] [-q] ``` -Prints a complete cash flow statement over time. This can be either quarterly or annually. The following fields are expected: Accepted date, Accounts payables, Accounts receivables, Acquisitions net, Capital expenditure, Cash at beginning of period, Cash at end of period, Change in working capital, Common stock issued, Common stock repurchased, Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, Net cash used for investing activites, Net cash used provided by financing activities, Net change in cash, Net income, Operating cash flow, Other financing activites, Other investing activites, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Alpha Vantage] +Prints a complete cash flow statement over time. This can be either quarterly or annually. The following fields are expected: Accepted date, Accounts payables, Accounts receivables, Acquisitions net, Capital expenditure, Cash at beginning of period, Cash at end of period, Change in working capital, Common stock issued, Common stock repurchased, Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, Net cash used for investing activities, Net cash used provided by financing activities, Net change in cash, Net income, Operating cash flow, Other financing activities, Other investing activities, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Alpha Vantage] * n : Number of latest years/quarters. Default 1. * q : Quarter fundamental data flag. Default False. @@ -241,7 +241,7 @@ Prints a complete balance sheet statement over time. This can be either quarterl ``` usage: cashf [-n N_NUM] [-q] ``` -Prints a complete cash flow statement over time. This can be either quarterly or annually. The following fields are expected: Accepted date, Accounts payables, Accounts receivables, Acquisitions net, Capital expenditure, Cash at beginning of period, Cash at end of period, Change in working capital, Common stock issued, Common stock repurchased, Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, Net cash used for investing activites, Net cash used provided by financing activities, Net change in cash, Net income, Operating cash flow, Other financing activites, Other investing activites, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Financial Modeling Prep] +Prints a complete cash flow statement over time. This can be either quarterly or annually. The following fields are expected: Accepted date, Accounts payables, Accounts receivables, Acquisitions net, Capital expenditure, Cash at beginning of period, Cash at end of period, Change in working capital, Common stock issued, Common stock repurchased, Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, Net cash used for investing activities, Net cash used provided by financing activities, Net change in cash, Net income, Operating cash flow, Other financing activities, Other investing activities, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Financial Modeling Prep] * n : Number of latest years/quarters. Default 1. * q : Quarter fundamental data flag. Default False. diff --git a/fundamental_analysis/alpha_vantage_api.py b/fundamental_analysis/alpha_vantage_api.py index 87a9b1288f8..8de17800192 100644 --- a/fundamental_analysis/alpha_vantage_api.py +++ b/fundamental_analysis/alpha_vantage_api.py @@ -247,9 +247,9 @@ def cash_flow(l_args, s_ticker): Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, - Net cash used for investing activites, Net cash used provided by financing activities, Net - change in cash, Net income, Operating cash flow, Other financing activites, Other investing - activites, Other non cash items, Other working capital, Period, Purchases of investments, + Net cash used for investing activities, Net cash used provided by financing activities, Net + change in cash, Net income, Operating cash flow, Other financing activities, Other investing + activities, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Alpha Vantage]""") parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, @@ -329,7 +329,7 @@ def earnings(l_args, s_ticker): "estimatedEPS":"Estimated EPS", "reportedDate":"Reported Date", "surprise":"Surprise", - "surprisePercentage":"Suprise Percentage"}) + "surprisePercentage":"Surprise Percentage"}) else: df_fa = pd.DataFrame(df_fa['annualEarnings'][0]) df_fa = df_fa.rename(columns={"fiscalDateEnding":"Fiscal Date Ending", diff --git a/fundamental_analysis/financial_modeling_prep_api.py b/fundamental_analysis/financial_modeling_prep_api.py index f9e9e684296..7ff1558b585 100644 --- a/fundamental_analysis/financial_modeling_prep_api.py +++ b/fundamental_analysis/financial_modeling_prep_api.py @@ -286,9 +286,9 @@ def cash_flow(l_args, s_ticker): Debt repayment, Deferred income tax, Depreciation and amortization, Dividends paid, Effect of forex changes on cash, Filling date, Final link, Free cash flow, Inventory, Investments in property plant and equipment, Link, Net cash provided by operating activities, - Net cash used for investing activites, Net cash used provided by financing activities, Net - change in cash, Net income, Operating cash flow, Other financing activites, Other investing - activites, Other non cash items, Other working capital, Period, Purchases of investments, + Net cash used for investing activities, Net cash used provided by financing activities, Net + change in cash, Net income, Operating cash flow, Other financing activities, Other investing + activities, Other non cash items, Other working capital, Period, Purchases of investments, Sales maturities of investments, Stock based compensation. [Source: Financial Modeling Prep]""") parser.add_argument('-n', "--num", action="store", dest="n_num", type=check_positive, default=1, @@ -509,4 +509,4 @@ def financial_statement_growth(l_args, s_ticker): except: print("") return - \ No newline at end of file + diff --git a/prediction_techniques/neural_networks.py b/prediction_techniques/neural_networks.py index ff1c24f6fa7..38f7da13f85 100644 --- a/prediction_techniques/neural_networks.py +++ b/prediction_techniques/neural_networks.py @@ -27,7 +27,7 @@ def build_neural_network_model(Recurrent_Neural_Network, n_inputs, n_days): for idx_layer, d_layer in enumerate(Recurrent_Neural_Network): # Recurrent Neural Network - if str(*d_layer) is 'SimpleRNN': + if str(*d_layer) == 'SimpleRNN': # Is this the input layer? If so, define input_shape if idx_layer == 0: model.add(SimpleRNN(**d_layer['SimpleRNN'], input_shape=(n_inputs, 1))) @@ -38,7 +38,7 @@ def build_neural_network_model(Recurrent_Neural_Network, n_inputs, n_days): model.add(SimpleRNN(**d_layer['SimpleRNN'])) # Long-Short Term-Memory - elif str(*d_layer) is 'LSTM': + elif str(*d_layer) == 'LSTM': # Is this the input layer? If so, define input_shape if idx_layer == 0: model.add(LSTM(**d_layer['LSTM'], input_shape=(n_inputs, 1))) @@ -49,7 +49,7 @@ def build_neural_network_model(Recurrent_Neural_Network, n_inputs, n_days): model.add(LSTM(**d_layer['LSTM'])) # Dense (Simple Neuron) - elif str(*d_layer) is 'Dense': + elif str(*d_layer) == 'Dense': # Is this the input layer? If so, define input_shape if idx_layer == 0: model.add(Dense(**d_layer['Dense'], input_dim=n_inputs)) @@ -60,7 +60,7 @@ def build_neural_network_model(Recurrent_Neural_Network, n_inputs, n_days): model.add(Dense(**d_layer['Dense'])) # Dropout (Regularization) - elif str(*d_layer) is 'Dropout': + elif str(*d_layer) == 'Dropout': model.add(Dropout(**d_layer['Dropout'])) else: diff --git a/sentiment/reddit_api.py b/sentiment/reddit_api.py index 6ef651a33ec..61132119b40 100644 --- a/sentiment/reddit_api.py +++ b/sentiment/reddit_api.py @@ -104,7 +104,7 @@ def watchlist(l_args): d_watchlist_tickers[key] = 1 l_watchlist_links.append(f"https://www.reddit.com{submission.permalink}") - # delte below, not necessary I reckon. Probably just link? + # delete below, not necessary I reckon. Probably just link? # Refactor data s_datetime = datetime.utcfromtimestamp(submission.created_utc).strftime("%d/%m/%Y %H:%M:%S") @@ -361,7 +361,7 @@ def spac_community(l_args): d_watchlist_tickers[key] = 1 l_watchlist_links.append(f"https://www.reddit.com{submission.permalink}") - # delte below, not necessary I reckon. Probably just link? + # delete below, not necessary I reckon. Probably just link? # Refactor data s_datetime = datetime.utcfromtimestamp(submission.created_utc).strftime("%d/%m/%Y %H:%M:%S") @@ -497,7 +497,7 @@ def spac(l_args): d_watchlist_tickers[key] = 1 l_watchlist_links.append(f"https://www.reddit.com{submission.permalink}") - # delte below, not necessary I reckon. Probably just link? + # delete below, not necessary I reckon. Probably just link? # Refactor data s_datetime = datetime.utcfromtimestamp(submission.created_utc).strftime("%d/%m/%Y %H:%M:%S") @@ -642,4 +642,4 @@ def wsb_community(l_args): break print("") except: - print("") \ No newline at end of file + print("")