mirror of
https://github.com/freqtrade/freqtrade.git
synced 2024-11-10 10:21:59 +00:00
apply pylint recommendations
This commit is contained in:
parent
abdddd5193
commit
f8084b117e
|
@ -21,12 +21,13 @@ def parse_ticker_dataframe(ticker: list) -> DataFrame:
|
|||
:param ticker: See exchange.get_ticker_history
|
||||
:return: DataFrame
|
||||
"""
|
||||
df = DataFrame(ticker) \
|
||||
columns = {'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'}
|
||||
frame = DataFrame(ticker) \
|
||||
.drop('BV', 1) \
|
||||
.rename(columns={'C': 'close', 'V': 'volume', 'O': 'open', 'H': 'high', 'L': 'low', 'T': 'date'})
|
||||
df['date'] = to_datetime(df['date'], utc=True, infer_datetime_format=True)
|
||||
df.sort_values('date', inplace=True)
|
||||
return df
|
||||
.rename(columns=columns)
|
||||
frame['date'] = to_datetime(frame['date'], utc=True, infer_datetime_format=True)
|
||||
frame.sort_values('date', inplace=True)
|
||||
return frame
|
||||
|
||||
|
||||
def populate_indicators(dataframe: DataFrame) -> DataFrame:
|
||||
|
@ -116,19 +117,20 @@ def get_buy_signal(pair: str) -> bool:
|
|||
return signal
|
||||
|
||||
|
||||
def plot_dataframe(dataframe: DataFrame, pair: str) -> None:
|
||||
def plot_analyzed_dataframe(pair: str) -> None:
|
||||
"""
|
||||
Plots the given dataframe
|
||||
:param dataframe: DataFrame
|
||||
Calls analyze() and plots the returned dataframe
|
||||
:param pair: pair as str
|
||||
:return: None
|
||||
"""
|
||||
|
||||
import matplotlib
|
||||
|
||||
matplotlib.use("Qt5Agg")
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
# Init Bittrex to use public API
|
||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||
dataframe = analyze_ticker(pair)
|
||||
|
||||
# Two subplots sharing x axis
|
||||
fig, (ax1, ax2, ax3) = plt.subplots(3, sharex=True)
|
||||
fig.suptitle(pair, fontsize=14, fontweight='bold')
|
||||
|
@ -160,9 +162,6 @@ def plot_dataframe(dataframe: DataFrame, pair: str) -> None:
|
|||
if __name__ == '__main__':
|
||||
# Install PYQT5==5.9 manually if you want to test this helper function
|
||||
while True:
|
||||
exchange._API = Bittrex({'key': '', 'secret': ''})
|
||||
test_pair = 'BTC_ETH'
|
||||
# for pair in ['BTC_ANT', 'BTC_ETH', 'BTC_GNT', 'BTC_ETC']:
|
||||
# get_buy_signal(pair)
|
||||
plot_dataframe(analyze_ticker(test_pair), test_pair)
|
||||
for p in ['BTC_ANT', 'BTC_ETH', 'BTC_GNT', 'BTC_ETC']:
|
||||
plot_analyzed_dataframe(p)
|
||||
time.sleep(60)
|
||||
|
|
|
@ -14,7 +14,7 @@ logging.basicConfig(level=logging.DEBUG,
|
|||
logger = logging.getLogger(__name__)
|
||||
|
||||
_CONF = {}
|
||||
Base = declarative_base()
|
||||
_DECL_BASE = declarative_base()
|
||||
|
||||
|
||||
def init(config: dict, db_url: Optional[str] = None) -> None:
|
||||
|
@ -37,7 +37,7 @@ def init(config: dict, db_url: Optional[str] = None) -> None:
|
|||
session = scoped_session(sessionmaker(bind=engine, autoflush=True, autocommit=True))
|
||||
Trade.session = session()
|
||||
Trade.query = session.query_property()
|
||||
Base.metadata.create_all(engine)
|
||||
_DECL_BASE.metadata.create_all(engine)
|
||||
|
||||
|
||||
def cleanup() -> None:
|
||||
|
@ -48,7 +48,7 @@ def cleanup() -> None:
|
|||
Trade.session.flush()
|
||||
|
||||
|
||||
class Trade(Base):
|
||||
class Trade(_DECL_BASE):
|
||||
__tablename__ = 'trades'
|
||||
|
||||
id = Column(Integer, primary_key=True)
|
||||
|
|
|
@ -20,7 +20,7 @@ logging.getLogger('requests.packages.urllib3').setLevel(logging.INFO)
|
|||
logging.getLogger('telegram').setLevel(logging.INFO)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
_updater: Updater = None
|
||||
_UPDATER: Updater = None
|
||||
_CONF = {}
|
||||
|
||||
|
||||
|
@ -32,13 +32,13 @@ def init(config: dict) -> None:
|
|||
:param config: config to use
|
||||
:return: None
|
||||
"""
|
||||
global _updater
|
||||
global _UPDATER
|
||||
|
||||
_CONF.update(config)
|
||||
if not is_enabled():
|
||||
return
|
||||
|
||||
_updater = Updater(token=config['telegram']['token'], workers=0)
|
||||
_UPDATER = Updater(token=config['telegram']['token'], workers=0)
|
||||
|
||||
# Register command handler and start telegram message polling
|
||||
handles = [
|
||||
|
@ -53,8 +53,8 @@ def init(config: dict) -> None:
|
|||
CommandHandler('help', _help),
|
||||
]
|
||||
for handle in handles:
|
||||
_updater.dispatcher.add_handler(handle)
|
||||
_updater.start_polling(
|
||||
_UPDATER.dispatcher.add_handler(handle)
|
||||
_UPDATER.start_polling(
|
||||
clean=True,
|
||||
bootstrap_retries=3,
|
||||
timeout=30,
|
||||
|
@ -73,7 +73,7 @@ def cleanup() -> None:
|
|||
"""
|
||||
if not is_enabled():
|
||||
return
|
||||
_updater.stop()
|
||||
_UPDATER.stop()
|
||||
|
||||
|
||||
def is_enabled() -> bool:
|
||||
|
@ -448,7 +448,7 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
|||
if not is_enabled():
|
||||
return
|
||||
try:
|
||||
bot = bot or _updater.bot
|
||||
bot = bot or _UPDATER.bot
|
||||
try:
|
||||
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode)
|
||||
except NetworkError as error:
|
||||
|
@ -459,5 +459,5 @@ def send_msg(msg: str, bot: Bot = None, parse_mode: ParseMode = ParseMode.MARKDO
|
|||
error.message
|
||||
)
|
||||
bot.send_message(_CONF['telegram']['chat_id'], msg, parse_mode=parse_mode)
|
||||
except Exception:
|
||||
except BaseException:
|
||||
logger.exception('Exception occurred within Telegram API')
|
||||
|
|
Loading…
Reference in New Issue
Block a user