def work(self): today = str(datetime.datetime.now()) today = today + 'everyday_com_fin_index_short' mail_helper = MailHelper() try: mail_helper.send_mail_to(dest='*****@*****.**', message=today) except Exception, e: logging.error(e)
def __init__(self): self.wd = WebDriver() self.wd.implicitly_wait(60) self.session = SessionHelper(self) self.mail = MailHelper(self)
if __name__ == '__main__': # 设置策略池 lst_coin = ['eos_usdt'] # For回测用,设置初始资金池 total_pool = 3000.0 total_count = 0.0 # Provide constants API_QUERY_URL = 'data.gateio.io' API_TRADE_URL = 'api.gateio.io' log('开始测试...初始资金池为 %d' % total_pool) buy_sell_flag = True while True: try: content = '' mail_helper = MailHelper(get_conf('my_sender'), get_conf('my_pass')) # Create a gate class instance gate_query = GateIO(API_QUERY_URL, get_conf('apiKey'), get_conf('secretKey')) gate_trade = GateIO(API_TRADE_URL, get_conf('apiKey'), get_conf('secretKey')) signal = check_signal(lst_coin[0], get_MA(lst_coin[0], gate_query)) if signal == 1: if not buy_sell_flag: total_pool, content = sell(lst_coin[0], get_ask_bid(lst_coin[0], gate_query), total_count, gate_trade) buy_sell_flag = True total_count = 0.0 content = content + log('卖出 %s' % lst_coin[0] + '\n当前持仓为: 【现金】 %.6f, 【%s】 %.6f 个' % (total_pool, lst_coin[0], total_count)) mail_helper.sendmail(get_conf('my_user'), get_conf('subject'), content) else: log('取消卖出【%s】动作,因为最近已经卖出过' % lst_coin[0] + '\n当前持仓为: 【现金】 %.6f, 【%s】 %.6f 个' % (total_pool, lst_coin[0], total_count)) elif signal == -1: if buy_sell_flag: