Esempio n. 1
0
 def __init__(self, parent):
     super(StraLister, self).__init__(parent)
     self.parent = parent
     self.stra_info_map = {}
     self.center = center.Center()
     self.head_name_list = ["", "模块", "名称", "状态", "说明", "路径"]
     self.InitUserInterface()
Esempio n. 2
0
 def __init__(self):
     threading.Thread.__init__(self)
     self.log_text = ""
     self.log_cate = "Strate"
     self.started = False
     self.config = config.Config()
     self.logger = logger.Logger()
     self.center = center.Center()
Esempio n. 3
0
 def HandleStrategyUserControl(self, str_type):
     self.center = center.Center()
     self.strate = strate.Strate()
     if str_type == "加载":
         self.strate.OnReloadStrategy()  # 先添加内部数据
         self.stra_lister.OnReloadStrategy()  # 再更新界面显示
     else:
         if self.stra_lister.GetSelectedRowIndex() < 0:
             QMessageBox.information(self, "提示", "请先选择要 %s 的策略。" % str_type,
                                     QMessageBox.Ok)
             return
         else:
             strategy = self.stra_lister.GetSelectedStrategy()
             self.center.data.strategies_locker.acquire()
             strategy_info = self.center.data.strategies[strategy]
             self.center.data.strategies_locker.release()
             dlg = None
             if str_type == "运行":
                 if strategy_info.state != define.USER_CTRL_LOAD and strategy_info.state != define.USER_CTRL_STOP:
                     dlg = QMessageBox.information(
                         self, "提示", "%s:状态不是已加载或已停止,无需运行。" % strategy,
                         QMessageBox.Ok)
             elif str_type == "暂停":
                 if strategy_info.state != define.USER_CTRL_EXEC:
                     dlg = QMessageBox.information(
                         self, "提示", "%s:状态不是运行中,无需暂停。" % strategy,
                         QMessageBox.Ok)
             elif str_type == "继续":
                 if strategy_info.state != define.USER_CTRL_WAIT:
                     dlg = QMessageBox.information(
                         self, "提示", "%s:状态不是已暂停,无需继续。" % strategy,
                         QMessageBox.Ok)
             elif str_type == "停止":
                 if strategy_info.state != define.USER_CTRL_EXEC and strategy_info.state != define.USER_CTRL_WAIT and strategy_info.state != define.USER_CTRL_FAIL:
                     dlg = QMessageBox.information(
                         self, "提示", "%s:状态不是运行中或已暂停或已异常,无需停止。" % strategy,
                         QMessageBox.Ok)
             elif str_type == "卸载":
                 if strategy_info.state != define.USER_CTRL_LOAD and strategy_info.state != define.USER_CTRL_STOP:
                     dlg = QMessageBox.information(
                         self, "提示", "%s:请先停止策略运行,再进行卸载。" % strategy,
                         QMessageBox.Ok)
             if dlg != None:
                 return
             reply = QMessageBox.question(
                 self, "询问", "确定 %s 策略 %s ?" % (str_type, strategy),
                 QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
             if reply == QMessageBox.Yes:
                 if str_type == "卸载":
                     self.stra_lister.OnUnloadStrategy(
                         strategy_info)  # 先删除界面显示
                     self.strate.OnUnloadStrategy(strategy_info)  # 再删除内部数据
                 else:
                     self.strate.OnChangeStrategyState(
                         strategy_info, str_type)  # 先改变数据状态
                     self.stra_lister.OnChangeStrategyState(
                         strategy_info)  # 再改变界面显示
Esempio n. 4
0
def load_centers(center_dir, filenames):
    centers = []
    center_names = os.listdir(center_dir)

    for center_name in center_names:
        center_path = os.path.join(center_dir, center_name)
        _center = center.Center(center_path, filenames)
        centers.append(_center)
    return centers
Esempio n. 5
0
 def __init__(self, parent):
     super(QuoteCenterBar, self).__init__(parent)
     self.parent = parent
     self.log_text = ""
     self.log_cate = "QuoteCenterBar"
     self.config = config.Config()
     self.logger = logger.Logger()
     self.center = center.Center()
     self.InitUserInterface()
Esempio n. 6
0
def index():
    if not check_login():
        return redirect(url_for('login'))
    if session['role'] != 'patient':
        return redirect('/provider_profile/' + utils.quote(session['email']))
    pt = patient.Patient(session['email'])
    center_v = ""
    provider_v = ""
    service_v = ""

    if request.method == "GET":
        results = pt.search(center=center_v,
                            provider=provider_v,
                            service=service_v)
        for res in results:
            pvd = provider.Provider(res['provider_email'])
            ct = center.Center(res['health_centre_name'])
            res['center_rate'] = ct.get_rate()
            res['provider_rate'] = pvd.get_rate()
            res['health_centre_name_quote'] = utils.quote(
                res['health_centre_name'])
            res['provider_email_quote'] = utils.quote(res['provider_email'])
        return render_template('index.html',
                               patient_email=session['email'],
                               result_list=results)

    center_v = request.form["center"]
    provider_v = request.form["provider"]
    service_v = request.form["service"]
    results = pt.search(center=center_v,
                        provider=provider_v,
                        service=service_v)
    for res in results:
        pvd = provider.Provider(res['provider_email'])
        ct = center.Center(res['health_centre_name'])
        res['center_rate'] = ct.get_rate()
        res['provider_rate'] = pvd.get_rate()
        res['health_centre_name_quote'] = utils.quote(
            res['health_centre_name'])
        res['provider_email_quote'] = utils.quote(res['provider_email'])
    return render_template('index.html',
                           patient_email=session['email'],
                           result_list=results)
Esempio n. 7
0
    def __init__(self):
        strategy_base.StrategyBase.__init__(self, "Strategy_Test_Future", "Test_Future", "行情测试")
        self.log_cate = "Strategy_Test_Future"
        self.beat_calc = BeatCalc(self)
        
        self.subscribe = False # 行情订阅标志
        self.center = center.Center()

        self.symbol_f = "IF1806"
        self.price_round_f = 1 # 股指期货价格需精确到小数点后一位,且为 0.2 的整数倍
Esempio n. 8
0
    def __init__(self):
        strategy_base.StrategyBase.__init__(self, "Strategy_Test_Stock",
                                            "Test_Stock", "行情测试")
        self.log_cate = "Strategy_Test_Stock"
        self.beat_calc = BeatCalc(self)

        self.subscribe = False  # 行情订阅标志
        self.center = center.Center()

        self.symbol_s = "600000"
        self.price_round_s = 2  # 股票类价格需精确到小数点后两位
Esempio n. 9
0
 def __init__(self, parent, quote_name, address, port, quote_subs):
     self.log_text = ""
     self.log_cate = "QuoteX"
     self.parent = parent
     self.quote_name = quote_name
     self.address = address
     self.port = port
     self.quote_subs = quote_subs  # Dict
     self.started = False
     self.userstop = False  # 防止用户退出时行情服务重连线程执行操作
     self.connected = False
     self.heart_check_time = datetime.now()
     self.heart_check_span = timedelta(seconds=10 * 3)
     self.logger = logger.Logger()
     self.center = center.Center()
     self.RegReplyMsgHandleFunc()
Esempio n. 10
0
 def __init__(self, **kwargs):
     super(Panel, self).__init__()
     self.strategy = kwargs.get("strategy", "")
     self.version_info = "V0.1.0-Beta Build 20180422"
     self.log_text = ""
     self.log_cate = "Panel_Trader_FUE_CTP"
     self.logger = logger.Logger()
     
     self.InitUserInterface()
     
     self.contract = ""
     self.exchange = ""
     self.trader = None # 策略中赋值
     self.subscribe = False # 行情订阅标志
     self.center = center.Center()
     
     self.quote_data = None
     self.price_round_future = 2 # 小数位数
Esempio n. 11
0
    def __init__(self, strategy, strategy_name, strategy_introduction):
        self.log_text = ""
        self.log_cate = "StrategyBase"
        self.beat_calc = None
        self.strategy_panel = None
        self.config = config.Config()
        self.logger = logger.Logger()
        self.center = center.Center()
        self.strategy = strategy
        self.strategy_name = strategy_name
        self.strategy_introduction = strategy_introduction

        self.center.data.strategies_locker.acquire()
        self.strategy_info = self.center.data.strategies[self.strategy]  # 已经存在
        self.center.data.strategies_locker.release()

        self.show_debug_info = self.config.cfg_main.stra_debug_info  # 为 1 或 0

        self.started = False
Esempio n. 12
0
    def __init__(self, **kwargs):
        super(Panel, self).__init__()
        self.strategy = kwargs.get("strategy", "")
        self.version_info = "V0.1.0-Beta Build 20180422"
        self.log_text = ""
        self.log_cate = "Panel_Trader_STK_APE"
        self.logger = logger.Logger()

        self.InitUserInterface()

        self.symbol = ""
        self.exchange = ""  # SH、SZ 或 SSE、SZE # 目前只订阅个股行情,不考虑沪深个股和指数代码重合问题
        self.trader = None  # 策略中赋值
        self.subscribe = False  # 行情订阅标志
        self.center = center.Center()

        self.quote_data = None
        self.price_round_stock = 2  # 小数位数
        self.price_round_index = 2  # 小数位数
Esempio n. 13
0
def center_profile(name):
    name = utils.unquote(name)
    pmode = True if session['role'] == 'patient' else False
    if not check_login():
        return redirect(url_for('login'))
    ct = center.Center(name)
    info = ct.info()
    pvd_list = ct.list_providers()
    for pvd in pvd_list:
        pvd['provider_email_quote'] = utils.quote(pvd['provider_email'])
        pvd['qs'] = utils.gen_query_string({
            'center': name,
            'provider': pvd['provider_email'],
            'time': pvd['provider_time']
        })
    if request.method == 'GET':
        return render_template('center_profile.html',
                               patient_mode=pmode,
                               success=False,
                               center_name_quote=utils.quote(info['name']),
                               center=info,
                               center_rate=ct.get_rate(),
                               email_quote=utils.quote(session['email']),
                               email=session['email'],
                               provider_list=pvd_list)
    else:
        rate = request.form["rate"]
        patient = session["email"]
        ct.set_rate(patient, rate)
        return render_template('center_profile.html',
                               patient_mode=pmode,
                               success=True,
                               center_name_quote=utils.quote(info['name']),
                               center=info,
                               center_rate=ct.get_rate(),
                               email_quote=utils.quote(session['email']),
                               email=session['email'],
                               provider_list=pvd_list)
P1_X = -200
P1_Y = 250

P2_X = 200
P2_Y = 250

X_SPEED = 0.5
Y_SPEED = 0.5

screen = turtle.Screen()
screen.tracer(0)
screen.setup(width=WIDTH, height=HEIGHT)
screen.bgcolor("black")

middle = center.Center()
middle.draw_line()

pong_ball = ball.Ball()

right_paddle = paddle.Paddle(PADDLE_RIGHT_X)
left_paddle = paddle.Paddle(PADDLE_LEFT_X)
score_p1 = score.Score(P1_X, P1_Y)
score_p1.initial_display("P1", 0)
score_p2 = score.Score(P2_X, P2_Y)
score_p2.initial_display("P2", 0)

curr_score_1 = 0
curr_score_2 = 0
game_is_on = True