本文整理汇总了Python中messenger.Messenger.send_buy_slack方法的典型用法代码示例。如果您正苦于以下问题:Python Messenger.send_buy_slack方法的具体用法?Python Messenger.send_buy_slack怎么用?Python Messenger.send_buy_slack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类messenger.Messenger
的用法示例。
在下文中一共展示了Messenger.send_buy_slack方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Trader
# 需要导入模块: from messenger import Messenger [as 别名]
# 或者: from messenger.Messenger import send_buy_slack [as 别名]
#.........这里部分代码省略.........
:return: Boolean indicating if the sell conditions have been met
:rtype : bool
"""
return ((rsi is not None and rsi >= self.trade_params["sell"]["rsiThreshold"] and
profit_margin > self.trade_params["sell"]["minProfitMarginThreshold"]) or
profit_margin > self.trade_params["sell"]["profitMarginThreshold"])
def buy(self, coin_pair, btc_quantity, price, stats, trade_time_limit=2):
"""
Used to place a buy order to Bittrex. Wait until the order is completed.
If the order is not filled within trade_time_limit minutes cancel it.
:param coin_pair: String literal for the market (ex: BTC-LTC)
:type coin_pair: str
:param btc_quantity: The amount of BTC to buy with
:type btc_quantity: float
:param price: The price at which to buy
:type price: float
:param stats: The buy stats object
:type stats: dict
:param trade_time_limit: The time in minutes to wait fot the order before cancelling it
:type trade_time_limit: float
"""
buy_data = self.Bittrex.buy_limit(coin_pair, btc_quantity / price, price)
if not buy_data["success"]:
return logger.error("Failed to buy on {} market.".format(coin_pair))
self.Database.store_initial_buy(coin_pair, buy_data["result"]["uuid"])
buy_order_data = self.get_order(buy_data["result"]["uuid"], trade_time_limit * 60)
self.Database.store_buy(buy_order_data["result"], stats)
self.Messenger.print_buy(coin_pair, price, stats["rsi"], stats["24HrVolume"])
self.Messenger.send_buy_slack(coin_pair, stats["rsi"], stats["24HrVolume"])
self.Messenger.send_buy_gmail(buy_order_data["result"], stats)
self.Messenger.play_sw_imperial_march()
def sell(self, coin_pair, price, stats, trade_time_limit=2):
"""
Used to place a sell order to Bittrex. Wait until the order is completed.
If the order is not filled within trade_time_limit minutes cancel it.
:param coin_pair: String literal for the market (ex: BTC-LTC)
:type coin_pair: str
:param price: The price at which to buy
:type price: float
:param stats: The buy stats object
:type stats: dict
:param trade_time_limit: The time in minutes to wait fot the order before cancelling it
:type trade_time_limit: float
"""
trade = self.Database.get_open_trade(coin_pair)
sell_data = self.Bittrex.sell_limit(coin_pair, trade["quantity"], price)
if not sell_data["success"]:
return logger.error(
"Failed to sell on {} market. Bittrex error message: {}".format(coin_pair, sell_data["message"])
)
sell_order_data = self.get_order(sell_data["result"]["uuid"], trade_time_limit * 60)
# TODO: Handle partial/incomplete sales.
self.Database.store_sell(sell_order_data["result"], stats)
self.Messenger.print_sell(coin_pair, price, stats["rsi"], stats["profitMargin"])
self.Messenger.send_sell_slack(coin_pair, stats["rsi"], stats["profitMargin"])
self.Messenger.send_sell_gmail(sell_order_data["result"], stats)
self.Messenger.play_sw_theme()