Exemple #1
0
def refresh():
    count = 1
    while True:
        ret = main_account.check_update()
        if ret is not False:
            if count == 1:
                old_pos = ret
                signal = True
                count += 1
            else:
                if ret == old_pos:
                    # logging.info('没有变化')
                    signal = False
                    count += 1
                else:
                    logging.info("主账户订单信息发生变化")
                    old_pos = ret
                    signal = True
                    count = 2
            if signal:
                f_th = [
                    MyThread(f_account.check_and_update, args=(ret, ))
                    for f_account in fallow_account_list
                ]
                [th.start() for th in f_th]
                [th.join() for th in f_th]
            time.sleep(0.5)
        elif ret is False:
            break
    msg = "主账户停掉了, 快检查程序"
    title = "MT4 跟单软件,主账户停掉了"
    Email(em_user, pwd, address, smtp_server).send_email(msg, title)
    logging.error('主账户停掉了, 赶紧检查主账户接口问题')
Exemple #2
0
 def send(self, count, em_user, pwd, address, smtp_server, info='K线'):
     now_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     try:
         with open(self.filename) as f:
             message = f.read()
     except Exception:
         message = ''
     if message:
         title = now_time + info + '监测问题总和'
         Email(em_user, pwd, address,
               smtp_server).send_email(message, title)
     else:
         if self.filename == 'warn_api.txt' and len(address) == 2:
             address.pop(1)
         title = now_time + info + ' 监测正常,没有问题'
         if count == 0:
             Email(em_user, pwd, address,
                   smtp_server).send_email(message, title)
Exemple #3
0
 def send(self, count, em_user, pwd, address, smtp_server, info='K线'):
     now_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
     try:
         with open(self.filename) as f:
             message = f.read()
     except Exception:
         message = ''
     if message:
         title = now_time + info + '监测问题总和'
         Email(em_user, pwd, address, smtp_server).send_email(message, title)
Exemple #4
0
em_user = '******'
pwd = 'agagwzladccqbhce'
address = '*****@*****.**'
smtp_server = 'smtp.qq.com'

process_count_old = [
    i.split('-u')[1].split('\n')[0]
    for i in os.popen('ps -f -C python').readlines()[1:]
]

while True:
    process_count_new = [
        i.split('-u')[1].split('\n')[0]
        for i in os.popen('ps -f -C python').readlines()[1:]
    ]
    if len(process_count_new) < len(process_count_old):
        deth_process = [
            i for i in process_count_old if i not in process_count_new
        ]
        deth_process = str(deth_process)
        message = '{}个进程意外关闭,当前进程数量为{},意外关闭的进程为{}'.format(
            len(process_count_old) - len(process_count_new),
            len(process_count_new), deth_process)
        title = '旧服进程数量警告'
        Email(em_user, pwd, address, smtp_server).send_email(message, title)
    now_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') + ' '
    print(now_time + '当前进程数量为:')
    print(len(process_count_new))
    process_count_old = process_count_new
    time.sleep(60)
Exemple #5
0
            1)有成交单  次账户跟随下单(承担不同的风险下不同的订单, 不同的风险下不同的量的订单)
            2)下单失败处理方式:
                重新下单 继续失败  标注不进行此轮操作
                重新下单成功  继续此次交易
            3)无成交单则继续扫描主账户
'''

# order_signal = 0  # 0 没有成交单 1存在成交单
# trade_order_signal_old = list()  # 存储旧的已成交订单号列表
# trade_order_signal_new = list()  # 存储新的已成交订单号列表
# # 两个记录的存在差别即出现订单被平仓
# close_out_signal = 0  # 0 没有平仓 1 出现平仓
# close_out_order = list()  # 平仓订单信息

mt4_Email = Email(em_user=em_user,
                  pwd=pwd,
                  address=address,
                  smtp_server=smtp_server)


def mt4_send_email(msg, title):
    th = MyThread(mt4_Email.send_email, args=(msg, title))
    th.start()


class MainAccount(MT4Account):
    def __init__(self, account, ip):
        MT4Account.__init__(self, account, ip)
        self.logger = logging.getLogger('MainAccount ' + str(account))
        self.count = 0

    def check_update(self):
Exemple #6
0
mt4_pos = list()
for i in range(len(mt4_account_list)):
    if sym_m[i] == 'DJI' or sym_m[i] == 'DJ30':
        mt4_pos.append(
            int(balance[i] * mt4_max_retracement_per[i] / 1000) / 10)
    elif sym_m[i] == 'USA30':
        mt4_pos.append(
            int(balance[i] * mt4_max_retracement_per[i] / 1000) / 100)
    else:
        mt4_pos.append(int(balance[i] * mt4_max_retracement_per[i] / 1000))

log.info("account: " + " ".join(mt4_account_list))
log.info("position: " + " ".join([str(i) for i in mt4_pos]))

# em = Email('*****@*****.**', 'qxkrwbmoxosdbhfi', "*****@*****.**", "smtp.qq.com")
em = Email('*****@*****.**', 'qxkrwbmoxosdbhfi', '*****@*****.**',
           "smtp.qq.com")

error_count = 0

# step 1: 检查昨天收盘时间和状况,输入收盘价,计算各账户仓位

last_close = 25574

# step 2: 等待2:30,确定总体做单方向

cut_time = datetime.time(14, 30, 0)
while True:
    try:
        dep = sp_acc_1.get_depth(sym_s)
        if dep is False:
            log.info('两点半之前, 开始转到第二个sp账户获取深度')