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