Added __init__ files and updated files for pylint (#649)

* Added init files fixed pylint

* Updated coverage settings

* Fixing pylint issues

* Refactored residual_api imports

* Fixing pylint

* Fixing pylint

* Update fx_view.py

* Fixed black

* Removing ignore

Co-authored-by: Colin Delahunty <colindelahunty@Colins-Air.attlocal.net>
This commit is contained in:
colin99d
2021-08-08 14:03:55 -04:00
committed by GitHub
parent 00e4e7ca22
commit 7f05e2e7ae
31 changed files with 73 additions and 33 deletions

1
.coveragerc vendored
View File

@@ -1,4 +1,5 @@
[coverage:run] [coverage:run]
omit = omit =
env/* env/*
tests/*
source = . source = .

View File

@@ -1,6 +1,6 @@
repos: repos:
- repo: https://github.com/pre-commit/pre-commit-hooks - repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.4.0 rev: v4.0.1
hooks: hooks:
- id: check-yaml - id: check-yaml
- id: end-of-file-fixer - id: end-of-file-fixer
@@ -8,16 +8,16 @@ repos:
- id: check-merge-conflict - id: check-merge-conflict
- id: detect-private-key - id: detect-private-key
- repo: https://github.com/psf/black - repo: https://github.com/psf/black
rev: 21.5b1 rev: 21.7b0
hooks: hooks:
- id: black - id: black
- repo: https://github.com/pycqa/flake8 - repo: https://github.com/pycqa/flake8
rev: 3.9.1 rev: 3.9.2
hooks: hooks:
- id: flake8 - id: flake8
entry: flake8 --max-line-length=122 --ignore=E203,W503 entry: flake8 --max-line-length=122 --ignore=E203,W503
- repo: https://github.com/codespell-project/codespell - repo: https://github.com/codespell-project/codespell
rev: v2.0.0 rev: v2.1.0
hooks: hooks:
- id: codespell - id: codespell
entry: codespell entry: codespell
@@ -28,7 +28,7 @@ repos:
- id: mypy - id: mypy
args: [ --ignore-missing-imports ] args: [ --ignore-missing-imports ]
- repo: https://github.com/pre-commit/mirrors-pylint - repo: https://github.com/pre-commit/mirrors-pylint
rev: 'v3.0.0a3' rev: 'v3.0.0a4'
hooks: hooks:
- id: pylint - id: pylint
entry: pylint terminal.py gamestonk_terminal tests entry: pylint terminal.py gamestonk_terminal tests
@@ -39,7 +39,7 @@ repos:
args: [ '--baseline', '.secrets.baseline' ] args: [ '--baseline', '.secrets.baseline' ]
exclude: package.lock.json exclude: package.lock.json
- repo: https://github.com/asottile/pyupgrade - repo: https://github.com/asottile/pyupgrade
rev: v2.18.2 rev: v2.23.3
hooks: hooks:
- id: pyupgrade - id: pyupgrade
args: [ --py36-plus ] args: [ --py36-plus ]

View File

@@ -0,0 +1,10 @@
# flake8: noqa
from . import common
from . import cryptocurrency
from . import economy
from . import etf
from . import forex
from . import options
from . import portfolio
from . import resources
from . import stocks

View File

@@ -11,6 +11,8 @@ from pandas.plotting import register_matplotlib_converters
import numpy as np import numpy as np
import seaborn as sns import seaborn as sns
import statsmodels.api as sm import statsmodels.api as sm
# pylint: disable=R0402
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
from statsmodels.tsa.seasonal import seasonal_decompose from statsmodels.tsa.seasonal import seasonal_decompose
from gamestonk_terminal.helper_funcs import ( from gamestonk_terminal.helper_funcs import (

View File

@@ -8,13 +8,14 @@ from matplotlib import pyplot as plt
import pandas as pd import pandas as pd
from pandas.plotting import register_matplotlib_converters from pandas.plotting import register_matplotlib_converters
import seaborn as sns import seaborn as sns
import scipy.stats as stats from scipy import stats
import statsmodels.api as sm import statsmodels.api as sm
# pylint: disable=R0402
import matplotlib.gridspec as gridspec import matplotlib.gridspec as gridspec
from statsmodels.graphics.gofplots import qqplot from statsmodels.graphics.gofplots import qqplot
from statsmodels.tsa.stattools import adfuller, kpss, bds from statsmodels.tsa.stattools import adfuller, kpss, bds
from statsmodels.stats.diagnostic import het_arch from statsmodels.stats.diagnostic import het_arch
from scipy.stats import skewtest, kurtosistest, skew, kurtosis
from gamestonk_terminal.helper_funcs import ( from gamestonk_terminal.helper_funcs import (
parse_known_args_and_warn, parse_known_args_and_warn,
plot_autoscale, plot_autoscale,
@@ -352,11 +353,11 @@ def normality(
# Kurtosis # Kurtosis
# Measures height and sharpness of the central peak relative to that of a standard bell curve # Measures height and sharpness of the central peak relative to that of a standard bell curve
k, kpval = kurtosistest(residuals) k, kpval = stats.kurtosistest(residuals)
# Skewness # Skewness
# Measure of the asymmetry of the probability distribution of a random variable about its mean # Measure of the asymmetry of the probability distribution of a random variable about its mean
s, spval = skewtest(residuals) s, spval = stats.skewtest(residuals)
# Jarque-Bera goodness of fit test on sample data # Jarque-Bera goodness of fit test on sample data
# Tests if the sample data has the skewness and kurtosis matching a normal distribution # Tests if the sample data has the skewness and kurtosis matching a normal distribution
@@ -380,9 +381,9 @@ def normality(
) )
print("") print("")
kurtosis_val = kurtosis(residuals, fisher=True) kurtosis_val = stats.kurtosis(residuals, fisher=True)
print("Kurtosis value: %.4f" % kurtosis_val) print("Kurtosis value: %.4f" % kurtosis_val)
skew_val = skew(residuals) skew_val = stats.skew(residuals)
print("Skewness value: %.4f" % skew_val) print("Skewness value: %.4f" % skew_val)
print("") print("")

View File

View File

@@ -1,14 +1,27 @@
from datetime import datetime
import argparse import argparse
from oandapyV20 import API
from typing import List from typing import List
import oandapyV20.endpoints.pricing as pricing
import oandapyV20.endpoints.accounts as accounts
import oandapyV20.endpoints.orders as orders import pandas as pd
import oandapyV20.endpoints.instruments as instruments import pandas_ta as ta
import oandapyV20.endpoints.positions as positions import mplfinance as mpf
import oandapyV20.endpoints.trades as trades import matplotlib.pyplot as plt
import oandapyV20.endpoints.forexlabs as labs import matplotlib.ticker as mticker
import seaborn as sns
from oandapyV20 import API
from oandapyV20.exceptions import V20Error from oandapyV20.exceptions import V20Error
from oandapyV20.endpoints import (
pricing,
accounts,
orders,
instruments,
positions,
trades,
forexlabs,
)
from gamestonk_terminal import config_terminal as cfg from gamestonk_terminal import config_terminal as cfg
from gamestonk_terminal import config_plot as cfgPlot from gamestonk_terminal import config_plot as cfgPlot
from gamestonk_terminal import feature_flags as gtff from gamestonk_terminal import feature_flags as gtff
@@ -17,13 +30,6 @@ from gamestonk_terminal.helper_funcs import (
plot_autoscale, plot_autoscale,
check_non_negative, check_non_negative,
) )
import pandas as pd
import pandas_ta as ta
import mplfinance as mpf
import matplotlib.pyplot as plt
import matplotlib.ticker as mticker
import seaborn as sns
from datetime import datetime
client = API(access_token=cfg.OANDA_TOKEN, environment="live") client = API(access_token=cfg.OANDA_TOKEN, environment="live")
@@ -51,6 +57,7 @@ def get_fx_price(accountID, instrument, other_args: List[str]):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -106,6 +113,7 @@ def get_account_summary(accountID, other_args: List[str]):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -154,6 +162,7 @@ def list_orders(accountID, other_args: List[str]):
except KeyError: except KeyError:
print("No orders were found\n") print("No orders were found\n")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -182,6 +191,7 @@ def get_order_book(instrument, other_args):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -207,6 +217,7 @@ def get_position_book(instrument, other_args):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -241,7 +252,7 @@ def create_order(accountID, instrument, other_args: List[str]):
ns_parser = parse_known_args_and_warn(parser, other_args) ns_parser = parse_known_args_and_warn(parser, other_args)
if not ns_parser: if not ns_parser:
return return
if "JPY" or "THB" or "HUF" in instrument: if "JPY" in instrument or "THB" in instrument or "HUF" in instrument:
ns_parser.price = round(ns_parser.price, 3) ns_parser.price = round(ns_parser.price, 3)
else: else:
ns_parser.price = round(ns_parser.price, 5) ns_parser.price = round(ns_parser.price, 5)
@@ -274,6 +285,7 @@ def create_order(accountID, instrument, other_args: List[str]):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
except Exception as e: except Exception as e:
@@ -307,6 +319,7 @@ def cancel_pending_order(accountID, other_args: List[str]):
print(f"Order {order_id} canceled.") print(f"Order {order_id} canceled.")
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -347,6 +360,7 @@ def get_pending_orders(accountID, other_args):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -386,6 +400,7 @@ def get_open_positions(accountID, other_args):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
@@ -492,6 +507,7 @@ def close_trade(accountID, other_args: List[str]):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
except Exception as e: except Exception as e:
@@ -599,6 +615,7 @@ def show_candles(accountID, instrument, other_args: List[str]):
if gtff.USE_ION: if gtff.USE_ION:
plt.ion() plt.ion()
# pylint: disable=W0612
fig, ax = mpf.plot( fig, ax = mpf.plot(
df, df,
type="candle", type="candle",
@@ -611,11 +628,13 @@ def show_candles(accountID, instrument, other_args: List[str]):
ax[0].set_title(f"{instrument} {ns_parser.granularity}") ax[0].set_title(f"{instrument} {ns_parser.granularity}")
ax[0].legend(legends) ax[0].legend(legends)
# pylint: disable=C0200
for i in range(0, len(subplot_legends), 2): for i in range(0, len(subplot_legends), 2):
ax[subplot_legends[i]].legend(subplot_legends[i + 1]) ax[subplot_legends[i]].legend(subplot_legends[i + 1])
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
except TypeError as e: except TypeError as e:
@@ -709,10 +728,11 @@ def calendar(instrument, other_args: List[str]):
parameters = {"instrument": instrument, "period": str(ns_parser.days * 86400 * -1)} parameters = {"instrument": instrument, "period": str(ns_parser.days * 86400 * -1)}
try: try:
request = labs.Calendar(params=parameters) request = forexlabs.Calendar(params=parameters)
response = client.request(request) response = client.request(request)
l_data = [] l_data = []
# pylint: disable=C0200
for i in range(len(response)): for i in range(len(response)):
if "forecast" in response[i]: if "forecast" in response[i]:
forecast = response[i]["forecast"] forecast = response[i]["forecast"]
@@ -765,10 +785,13 @@ def calendar(instrument, other_args: List[str]):
print("") print("")
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["message"], "\n") print(d_error["message"], "\n")
# pylint: disable=W0613
# pylint: disable=R1710
def get_candles_dataframe(accountID, instrument, parameters): def get_candles_dataframe(accountID, instrument, parameters):
if not parameters: if not parameters:
parameters = { parameters = {
@@ -797,10 +820,12 @@ def get_candles_dataframe(accountID, instrument, parameters):
df.index = pd.to_datetime(df.index) df.index = pd.to_datetime(df.index)
return df return df
except V20Error as e: except V20Error as e:
# pylint: disable=W0123
d_error = eval(e.msg) d_error = eval(e.msg)
print(d_error["errorMessage"], "\n") print(d_error["errorMessage"], "\n")
# pylint: disable=R1710
def load(other_args: List[str]): def load(other_args: List[str]):
"""Load a forex instrument to use""" """Load a forex instrument to use"""
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(
@@ -875,6 +900,7 @@ def book_plot(df, instrument, book_type):
plt.show() plt.show()
# pylint: disable=R1710
def format_instrument(instrument, char): def format_instrument(instrument, char):
try: try:
if char not in instrument: if char not in instrument:

View File

@@ -20,11 +20,11 @@ def inputhook(inputhook_context):
history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his") history_file = os.path.join(os.path.expanduser("~"), ".gamestonk_terminal.his")
try: try:
session = PromptSession(history=FileHistory(history_file)) session = PromptSession(history=FileHistory(history_file)) # type: ignore
set_eventloop_with_inputhook(inputhook) set_eventloop_with_inputhook(inputhook)
# pylint: disable=unused-variable # pylint: disable=unused-variable
except Exception as e: # noqa: F841 except Exception as e: # noqa: F841
print( print(
"WARNING: Prompt toolkit is turned on but did not initialize successfully. Falling back to input()..." "WARNING: Prompt toolkit is turned on but did not initialize successfully. Falling back to input()..."
) )
session = None session = None # type: ignore

View File

View File

@@ -5,7 +5,7 @@ from typing import Union
# IMPORTATION THIRDPARTY # IMPORTATION THIRDPARTY
import pandas as pd import pandas as pd
import degiro_connector.trading.helpers.payload_handler as payload_handler from degiro_connector.trading.helpers import payload_handler
from degiro_connector.trading.api import API as TradingAPI from degiro_connector.trading.api import API as TradingAPI
from degiro_connector.trading.pb.trading_pb2 import ( from degiro_connector.trading.pb.trading_pb2 import (

View File

@@ -1,7 +1,7 @@
# IMPORTATION THIRDPARTY # IMPORTATION THIRDPARTY
from argparse import Namespace from argparse import Namespace
import pandas as pd import pandas as pd
import degiro_connector.trading.helpers.payload_handler as payload_handler from degiro_connector.trading.helpers import payload_handler
from degiro_connector.trading.pb.trading_pb2 import ( from degiro_connector.trading.pb.trading_pb2 import (
Credentials, Credentials,

View File

View File