本文整理汇总了Python中messenger.Messenger.print_pause方法的典型用法代码示例。如果您正苦于以下问题:Python Messenger.print_pause方法的具体用法?Python Messenger.print_pause怎么用?Python Messenger.print_pause使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messenger.Messenger
的用法示例。
在下文中一共展示了Messenger.print_pause方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Trader
# 需要导入模块: from messenger import Messenger [as 别名]
# 或者: from messenger.Messenger import print_pause [as 别名]
class Trader(object):
"""
Used for handling all trade functionality
"""
def __init__(self, secrets):
self.trade_params = secrets["tradeParameters"]
self.pause_params = secrets["pauseParameters"]
self.Bittrex = Bittrex(secrets)
self.Messenger = Messenger(secrets)
self.Database = Database()
def initialise(self):
"""
Fetch the initial coin pairs to track and to print the header line
"""
try:
if len(self.Database.app_data["coinPairs"]) < 1:
self.Database.store_coin_pairs(self.get_markets("BTC"))
self.Messenger.print_header(len(self.Database.app_data["coinPairs"]))
except ConnectionError as exception:
self.Messenger.print_exception_error("connection")
logger.exception(exception)
exit()
def analyse_pauses(self):
"""
Check all the paused buy and sell pairs and reactivate the necessary ones
"""
if self.Database.check_resume(self.pause_params["buy"]["pauseTime"], "buy"):
self.Database.store_coin_pairs(self.get_markets("BTC"))
self.Messenger.print_resume_pause(len(self.Database.app_data["coinPairs"]), "buy")
if self.Database.check_resume(self.pause_params["sell"]["pauseTime"], "sell"):
self.Messenger.print_resume_pause(self.Database.app_data["pausedTrackedCoinPairs"], "sell")
self.Database.resume_sells()
def analyse_buys(self):
"""
Analyse all the un-paused coin pairs for buy signals and apply buys
"""
trade_len = len(self.Database.trades["trackedCoinPairs"])
pause_trade_len = len(self.Database.app_data["pausedTrackedCoinPairs"])
if (trade_len < 1 or pause_trade_len == trade_len) and trade_len < self.trade_params["buy"]["maxOpenTrades"]:
for coin_pair in self.Database.app_data["coinPairs"]:
self.buy_strategy(coin_pair)
def analyse_sells(self):
"""
Analyse all the un-paused tracked coin pairs for sell signals and apply sells
"""
for coin_pair in self.Database.trades["trackedCoinPairs"]:
if coin_pair not in self.Database.app_data["pausedTrackedCoinPairs"]:
self.sell_strategy(coin_pair)
def buy_strategy(self, coin_pair):
"""
Applies the buy checks on the coin pair and handles the results appropriately
:param coin_pair: Coin pair market to check (ex: BTC-ETH, BTC-FCT)
:type coin_pair: str
"""
if (len(self.Database.trades["trackedCoinPairs"]) >= self.trade_params["buy"]["maxOpenTrades"] or
coin_pair in self.Database.trades["trackedCoinPairs"]):
return
rsi = self.calculate_RSI(coin_pair=coin_pair, period=14, unit=self.trade_params["tickerInterval"])
day_volume = self.get_current_24hr_volume(coin_pair)
current_buy_price = self.get_current_price(coin_pair, "ask")
if self.check_buy_parameters(rsi, day_volume, current_buy_price):
buy_stats = {
"rsi": rsi,
"24HrVolume": day_volume
}
self.buy(coin_pair, self.trade_params["buy"]["btcAmount"], current_buy_price, buy_stats)
elif rsi is not None and rsi <= self.pause_params["buy"]["rsiThreshold"]:
self.Messenger.print_no_buy(coin_pair, rsi, day_volume, current_buy_price)
elif rsi is not None:
self.Messenger.print_pause(coin_pair, rsi, self.pause_params["buy"]["pauseTime"], "buy")
self.Database.pause_buy(coin_pair)
def sell_strategy(self, coin_pair):
"""
Applies the sell checks on the coin pair and handles the results appropriately
:param coin_pair: Coin pair market to check (ex: BTC-ETH, BTC-FCT)
:type coin_pair: str
"""
if (coin_pair in self.Database.app_data["pausedTrackedCoinPairs"] or
coin_pair not in self.Database.trades["trackedCoinPairs"]):
return
rsi = self.calculate_RSI(coin_pair=coin_pair, period=14, unit=self.trade_params["tickerInterval"])
current_sell_price = self.get_current_price(coin_pair, "bid")
profit_margin = self.Database.get_profit_margin(coin_pair, current_sell_price)
if self.check_sell_parameters(rsi, profit_margin):
sell_stats = {
"rsi": rsi,
"profitMargin": profit_margin
}
#.........这里部分代码省略.........