示例#1
0
def filter_main(stock_new, state_dt, predict_dt, poz):

    #先更新持股天数
    DBUtils.update_hold_days()

    #根据最新的仓位调整相应持股比例
    #先卖出
    deal = Deal.Deal(state_dt)
    stock_pool_local = deal.stock_pool
    for stock in stock_pool_local:

        predict = DBUtils.get_stock_predict(state_dt, stock)
        ans = Operator.sell(stock, state_dt, predict)

    #后买入
    for stock_index in range(len(stock_new)):
        deal_buy = Deal.Deal(state_dt)

        # # 如果模型f1分值低于50则不买入
        # sql_f1_check = "select * from model_ev_resu a where a.stock_code = '%s' and a.state_dt < '%s' order by a.state_dt desc limit 1"%(stock_new[stock_index],state_dt)
        # cursor.execute(sql_f1_check)
        # done_check = cursor.fetchall()
        # db.commit()
        # if len(done_check) > 0:
        #     if float(done_check[0][4]) < 0.5:
        #         print('F1 Warning !!')
        #         continue

        ans = Operator.buy(stock_new[stock_index], state_dt,
                           poz[stock_index] * deal_buy.cur_money_rest)
        del deal_buy
示例#2
0
def one_sided_CED(S1, S2, sim, f_k, alpha):
    """
    :return: Float                                                  -- \tilde{d}_{CED}(S_1,S_2) Cost to edit S1 -> S2
    """
    D = np.zeros((S1.size + 1, S2.size + 1))
    for i in prange(S1.size + 1):
        for j in prange(S2.size + 1):
            if (i == 0 or j == 0):
                D[i, j] = j + i
            else:
                op_mod = Operator(ED.MOD, S1, S2[j - 1],
                                  i - 1)  # Modification operator
                op_del = Operator(ED.DEL, S1, S1[i - 1], i - 1)  # Deletion --
                op_add = Operator(ED.ADD, S1, S2[j - 1], i - 1)  # Addition --

                cost_mod = edit_cost(op_mod, f_k, sim,
                                     alpha)  # Cost of apply Modification
                cost_del = edit_cost(op_del, f_k, sim,
                                     alpha)  # --            Del
                cost_add = edit_cost(op_add, f_k, sim,
                                     alpha)  # --            Add

                D[i, j] = round(
                    min(D[i - 1, j - 1] + cost_mod, D[i - 1, j] + cost_del,
                        D[i, j - 1] + cost_add), 2)
    print(D)
    return D[S1.size, S2.size]
示例#3
0
 def parseOperator(self, t):
     if t == '/' and self.unitRegex.match(self.tokenizer.peek()):
         return Operator.unitDivideOperator()
     elif t == '-' and not (self.lastValue and self.lastValue.isNumber()):
         self.parseToken('0')
         return Operator.unaryMinusOperator()
     else:
         return Operator.Operator(t)
示例#4
0
def one_sided_CED(S1, S2, f, sim):
    D = np.zeros((len(S1) + 1, len(S2) + 1))
    for i in range(len(S1) + 1):
        for j in range(len(S2) + 1):
            if (i == 0 and j == 0):
                D[i, j] = 0
            else:
                if (i == 0):
                    e = Operator(Edit_operator.ADD, S1, S2[j - 1], 0)
                    D[i, j] = D[i, j - 1] + e.cost_edit(f, sim)
                if (j == 0):
                    e = Operator(Edit_operator.DEL, S1, S1[i - 1], i - 1)
                    D[i, j] = D[i - 1, j] + e.cost_edit(f, sim)
                if (i != 0 and j != 0):

                    cost_mod = Operator(Edit_operator.MOD, S1, S2[j - 1],
                                        i - 1).cost_edit(f, sim)
                    cost_del = Operator(Edit_operator.DEL, S1, S1[i - 1],
                                        i - 1).cost_edit(f, sim)
                    cost_add = Operator(Edit_operator.ADD, S1, S2[j - 1],
                                        i - 2).cost_edit(f, sim)

                    D[i,
                      j] = min(D[i - 1, j - 1] + cost_mod,
                               D[i - 1, j] + cost_del, D[i, j - 1] + cost_add)
    #print D
    return D[len(S1), len(S2)]
示例#5
0
def filter_main(stock_new,state_dt,predict_dt,poz):
    # 建立数据库连接
    ##################################################
    # 建立数据库连接,设置tushare的token,定义一些初始化参数
    env=get_env()
    db,cursor,pro=env.db,env.cursor,env.pro
    ##################################################

    #先更新持股天数
    sql_update_hold_days = 'update my_stock_pool w set w.hold_days = w.hold_days + 1'
    cursor.execute(sql_update_hold_days)
    db.commit()

    #先卖出
    deal = Deal.Deal(state_dt)
    stock_pool_local = deal.stock_pool

    for stock in stock_pool_local:
        sql_predict = "select predict from model_ev_resu a where a.state_dt = '%s' and a.stock_code = '%s'"%(predict_dt,stock)
        cursor.execute(sql_predict)
        done_set_predict = cursor.fetchall()
        predict = 0
        if len(done_set_predict) > 0:
            predict = int(done_set_predict[0][0])
            print  "predict: %s,predictvalue: %d " % (stock ,predict)  
        ans = Operator.sell(stock,state_dt,predict)
        print "sell: %s" % stock  

    #后买入
    for stock_index in range(len(stock_new)):
        deal_buy = Deal.Deal(state_dt)
        # # 如果模型f1分值低于50则不买入
        # sql_f1_check = "select * from model_ev_resu a where a.stock_code = '%s' and a.state_dt < '%s' order by a.state_dt desc limit 1"%(stock_new[stock_index],state_dt)
        # cursor.execute(sql_f1_check)
        # done_check = cursor.fetchall()
        # db.commit()
        # if len(done_check) > 0:
        #     if float(done_check[0][4]) < 0.5:
        #         print('F1 Warning !!')
        #         continue
        # macd模型,如果预测值为1则买入
        # sql_macd_check="select * from model_macd_resu where stock_code= '%s' and state_dt= '%s' " % (stock_new[stock_index],state_dt)
        # cursor.execute(sql_macd_check)
        # done_check = cursor.fetchall()
        # print done_check
        # db.commit()
        # if len(done_check) > 0:
        #     if done_check[0][2] <> '1': # 不可买
        #         print(state_dt,': ',stock_new[stock_index],'macd forbidden !')
        #         continue
        ans = Operator.buy(stock_new[stock_index],state_dt,float(poz[stock_index])*deal_buy.cur_money_rest)
        print "stock_new[stock_index],state_dt,poz[stock_index]*deal_buy.cur_money_rest", stock_new[stock_index],state_dt,poz[stock_index]*deal_buy.cur_money_rest
        del deal_buy
 
    db.close()
示例#6
0
    def create_operator(self, operator_symbol):
        """
        Match the given operator symbol to its corresponding function.

        Return None if the operator symbol is unknown.
        """
        if operator_symbol == "^":
            operator_object = Operator.Operator("^", lambda x, y: x**y)
        elif operator_symbol == "*":
            operator_object = Operator.Operator("*", lambda x, y: x * y)
        elif operator_symbol == "/":
            operator_object = Operator.Operator("/", lambda x, y: x / y)
        elif operator_symbol == "%":
            operator_object = Operator.Operator("%", lambda x, y: x % y)
        elif operator_symbol == "+":
            operator_object = Operator.Operator("+", lambda x, y: x + y)
        elif operator_symbol == "-":
            operator_object = Operator.Operator("-", lambda x, y: x - y)
        elif operator_symbol == "sin":
            operator_object = Operator.Operator("sin", lambda x: sin(x))
        elif operator_symbol == "cos":
            operator_object = Operator.Operator("cos", lambda x: cos(x))
        elif operator_symbol == "exp":
            operator_object = Operator.Operator("exp", lambda x: exp(x))
        else:
            operator_object = None
        return operator_object
 def registerNewOperator(self, data):
     print("registering new operator: " + data.data)
     newOperator = Operator(data.data)
     self.activeOperatorDictionary[data.data] = newOperator
     # Check the robotsForOperatorQueue to see if there are robots that need help
     if (len(self.robotsForOperator) > 0):
         robotToHelp = self.robotsForOperator.pop()
         newOperator.sendNewRobotToOperator.publish(robotToHelp)
         newOperator.operatorIsBusy = True
         newOperator.linkToRobot(robotToHelp)
         print("Passing robot: " + robotToHelp.name + " to operator: " + newOperator.operatorID)
示例#8
0
def filter_main(stock_new, state_dt, predict_dt, poz):
    # 建立数据库连接
    db = pymysql.connect(host='127.0.0.1',
                         user='******',
                         passwd='root',
                         db='stock',
                         charset='utf8')
    cursor = db.cursor()

    #先更新持股天数
    sql_update_hold_days = 'update my_stock_pool w set w.hold_days = w.hold_days + 1'
    cursor.execute(sql_update_hold_days)
    db.commit()

    #先卖出
    deal = Deal.Deal(state_dt)
    stock_pool_local = deal.stock_pool

    for stock in stock_pool_local:
        sql_predict = "select predict from model_ev_resu a where a.state_dt = '%s' and a.stock_code = '%s'" % (
            predict_dt, stock)
        cursor.execute(sql_predict)
        done_set_predict = cursor.fetchall()
        predict = 0
        if len(done_set_predict) > 0:
            predict = int(done_set_predict[0][0])
            print "predict: %s,predictvalue: %d " % (stock, predict)
        ans = Operator.sell(stock, state_dt, predict)
        print "sell: %s" % stock

    #后买入
    for stock_index in range(len(stock_new)):
        deal_buy = Deal.Deal(state_dt)

        # # 如果模型f1分值低于50则不买入
        # sql_f1_check = "select * from model_ev_resu a where a.stock_code = '%s' and a.state_dt < '%s' order by a.state_dt desc limit 1"%(stock_new[stock_index],state_dt)
        # cursor.execute(sql_f1_check)
        # done_check = cursor.fetchall()
        # db.commit()
        # if len(done_check) > 0:
        #     if float(done_check[0][4]) < 0.5:
        #         print('F1 Warning !!')
        #         continue
        ans = Operator.buy(stock_new[stock_index], state_dt,
                           float(poz[stock_index]) * deal_buy.cur_money_rest)
        print "stock_new[stock_index],state_dt,poz[stock_index]*deal_buy.cur_money_rest", stock_new[
            stock_index], state_dt, poz[stock_index] * deal_buy.cur_money_rest
        del deal_buy

    db.close()
示例#9
0
    def splitFileOrCode(self, data, args):

        ret_list = list()
        args_split = {
            'wtype': data['f_wtype'],
            'beishu': data['f_beishu'],
            'fileorcode': data['f_fileorcode'],
            'selecttype': data['f_selecttype']
        }

        split_obj = Operator.get(data['f_lotid'])
        logger.info(args_split)
        ret = split_obj.splitCodes(args_split)

        allmoney = 0
        singlemoney = Config.SINGLEMONEY
        for info in ret:
            tmp_dict = copy.deepcopy(args)
            tmp_dict['wtype'] = info['wtype']
            tmp_dict['beishu'] = info['beishu']
            tmp_dict['zhushu'] = info['zhushu']
            tmp_dict['fileorcode'] = info['code']
            tmp_dict['selecttype'] = info['selecttype']
            tmp_dict['allmoney'] = int(info['beishu']) * int(
                info['zhushu']) * singlemoney
            tmp_dict['printdetail'] = info.get('printdetail', 0)

            ret_list.append(tmp_dict)
            allmoney += tmp_dict['allmoney']

        logger.info(allmoney)
        logger.info(data['f_allmoney'])
        return ret_list, allmoney
示例#10
0
    def splitFileOrCode( self, data, args ):

        ret_list = list()
        args_split = {'wtype'      : data['f_wtype'],
                      'beishu'     : data['f_beishu'],
                      'fileorcode' : data['f_fileorcode']
                     }

        split_obj = Operator.get( data['f_lotid'] )

        ret = split_obj.splitCodes( args_split )

        singlemoney = 2
        if str( data['f_wtype'] ) in Config.ZJWTYPE:
            singlemoney = 3

        for info in ret:
            if type(info) == list:
               info = info[0]
            tmp_dict = copy.deepcopy( args )
            tmp_dict['wtype']      = data['f_wtype']
            tmp_dict['code']       = info['code']
            tmp_dict['beishu']     = info['beishu']
            tmp_dict['zhushu']     = info['zhushu']
            tmp_dict['allmoney']   = int( info['beishu'] ) * int( info['zhushu'] ) * singlemoney

            #解析
            fileorcode, retflag    = self.parseFileorcode( info['code'] )
            tmp_dict['fileorcode'] = fileorcode
            tmp_dict['selecttype'] = retflag
            ret_list.append(tmp_dict)

        logger.debug(ret_list)
        return ret_list
示例#11
0
    def createTypeGraph(self, atom3i, rootNode):

        self.obj39 = TypeName(atom3i)

        self.obj39.Name.setValue('ImageText')
        self.obj39.graphClass_ = graph_TypeName
        from graph_TypeName import *
        new_obj = graph_TypeName(178.0, 177.0, self.obj39)
        self.obj39.graphObject_ = new_obj
        rootNode.addNode(self.obj39)

        self.obj40 = LeafType(atom3i)

        self.obj40.TypeConstraint.setValue(
            ('typeConst', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE OBJECT'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n\n'))
        self.obj40.Type.setValue(
            ('Image', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj40.Type.initialValue = ATOM3String('')
        self.obj40.graphClass_ = graph_LeafType
        from graph_LeafType import *
        new_obj = graph_LeafType(70.0, 400.0, self.obj40)
        self.obj40.graphObject_ = new_obj
        rootNode.addNode(self.obj40)

        self.obj41 = LeafType(atom3i)

        self.obj41.TypeConstraint.setValue(
            ('typeConst', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE OBJECT'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n\n'))
        self.obj41.Type.setValue(
            ('Text', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj41.Type.initialValue = ATOM3String('')
        self.obj41.graphClass_ = graph_LeafType
        from graph_LeafType import *
        new_obj = graph_LeafType(253.0, 402.0, self.obj41)
        self.obj41.graphObject_ = new_obj
        rootNode.addNode(self.obj41)

        self.obj42 = Operator(atom3i)

        self.obj42.type.setValue((['X', 'U', '->'], 1))
        self.obj42.type.config = 0
        self.obj42.graphClass_ = graph_Operator
        from graph_Operator import *
        new_obj = graph_Operator(198.0, 308.0, self.obj42)
        self.obj42.graphObject_ = new_obj
        rootNode.addNode(self.obj42)
        self.obj39.out_connections_.append(self.obj42)
        self.obj42.in_connections_.append(self.obj39)
        self.obj42.out_connections_.append(self.obj41)
        self.obj41.in_connections_.append(self.obj42)
        self.obj42.out_connections_.append(self.obj40)
        self.obj40.in_connections_.append(self.obj42)
示例#12
0
    def __init__(self, parent):
        GGrule.__init__(self, 1)
        self.TimeDelay = ATOM3Integer(2)
        self.exactMatch = 1
        self.LHS = ASG_TypesMetaModel(parent)

        self.obj32 = Operator(parent)

        self.obj32.type.setValue((['X', 'U', '->'], 1))
        self.obj32.type.config = 0
        self.obj32.GGLabel.setValue(1)
        self.obj32.graphClass_ = graph_Operator
        if parent.genGraphics:
            from graph_Operator import *
            new_obj = graph_Operator(215.0, 300.0, self.obj32)
        else:
            new_obj = None
        self.obj32.graphObject_ = new_obj
        self.LHS.addNode(self.obj32)
        self.RHS = ASG_TypesMetaModel(parent)

        self.obj34 = Operator(parent)

        self.obj34.type.setValue((['X', 'U', '->'], 1))
        self.obj34.type.config = 0
        self.obj34.GGLabel.setValue(1)
        self.obj34.graphClass_ = graph_Operator
        if parent.genGraphics:
            from graph_Operator import *
            new_obj = graph_Operator(226.0, 344.0, self.obj34)
        else:
            new_obj = None
        self.obj34.graphObject_ = new_obj
        self.obj340 = AttrCalc()
        self.obj340.Copy = ATOM3Boolean()
        self.obj340.Copy.setValue(('Copy from LHS', 1))
        self.obj340.Copy.config = 0
        self.obj340.Specify = ATOM3Constraint()
        self.obj340.Specify.setValue(
            ('AttrSpecify', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n'))
        self.obj34.GGset2Any['type'] = self.obj340
        self.RHS.addNode(self.obj34)
示例#13
0
def open_today_headlines():
    print('开始执行 [打开今日头条]')
    # 点击两次主页键
    operator.touch_home()
    operator.touch_home()
    # 左滑三次, 抵达今日头条所在页
    swipe([1050, 800], [15, 800])
    swipe([1050, 800], [15, 800])
    swipe([1050, 800], [15, 800])
    # 滑动特效可能导致图像识别失败, 延时1s
    time.sleep(1)
    # 打开今日头条

    touch(
        Template(r"tpl1563417199187.png",
                 record_pos=(0.115, -0.505),
                 resolution=(1080, 1920)))
示例#14
0
    def createTypeGraph(self, atom3i, rootNode):

        self.obj45 = TypeName(atom3i)

        self.obj45.Name.setValue('segment')
        self.obj45.graphClass_ = graph_TypeName
        new_obj = graph_TypeName(283.0, 197.0, self.obj45)
        self.obj45.graphObject_ = new_obj
        rootNode.addNode(self.obj45)

        self.obj46 = LeafType(atom3i)

        self.obj46.Type.setValue(
            ('width', 'Integer', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj46.Type.initialValue = ATOM3Integer(0)
        self.obj46.graphClass_ = graph_LeafType
        new_obj = graph_LeafType(161.0, 344.0, self.obj46)
        self.obj46.graphObject_ = new_obj
        rootNode.addNode(self.obj46)

        self.obj47 = LeafType(atom3i)

        self.obj47.Type.setValue(
            ('fill', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj47.Type.initialValue = ATOM3String('')
        self.obj47.graphClass_ = graph_LeafType
        new_obj = graph_LeafType(279.0, 387.0, self.obj47)
        self.obj47.graphObject_ = new_obj
        rootNode.addNode(self.obj47)

        self.obj48 = LeafType(atom3i)

        self.obj48.Type.setValue(('decoration', 'Appearance', None, ('Key', 0),
                                  ('Direct Editing', 1)))
        self.obj48.Type.initialValue = ATOM3Appearance()
        self.obj48.Type.initialValue.setValue(('class0', self.obj48.Type))
        self.obj48.graphClass_ = graph_LeafType
        new_obj = graph_LeafType(401.0, 355.0, self.obj48)
        self.obj48.graphObject_ = new_obj
        rootNode.addNode(self.obj48)

        self.obj49 = Operator(atom3i)

        self.obj49.Type.setValue((['U', 'X'], 1))
        self.obj49.Type.config = 0
        self.obj49.graphClass_ = graph_Operator
        new_obj = graph_Operator(312.0, 292.0, self.obj49)
        self.obj49.graphObject_ = new_obj
        rootNode.addNode(self.obj49)
        self.obj45.out_connections_.append(self.obj49)
        self.obj49.in_connections_.append(self.obj45)
        self.obj49.out_connections_.append(self.obj46)
        self.obj46.in_connections_.append(self.obj49)
        self.obj49.out_connections_.append(self.obj47)
        self.obj47.in_connections_.append(self.obj49)
        self.obj49.out_connections_.append(self.obj48)
        self.obj48.in_connections_.append(self.obj49)
示例#15
0
	def __init__(self):
		self.operator = Operator.Operator() #instance of the operator object
		self.ResList = [] #a list of result objects
		self.links = [] #the list of links returned
		self.results = []
		self.hasOutPutFile = False
		self.outputFile = None
		self.hasRegexOption = False
		return
    def __init__(self):

        self.functions = {
            'EXP': Function(np.exp),
            'LOG': Function(np.log),
            'SIN': Function(np.sin),
            'COS': Function(np.cos),
            'SQRT': Function(np.sqrt),
            'NEG': Function(np.negative)
        }

        self.operators = {
            'ADD': Operator(np.add, 0),
            'MULT': Operator(np.multiply, 1),
            'DIVIDE': Operator(np.divide, 1),
            'SUBTRACT': Operator(np.subtract, 0)
        }
        self.output_queue = Queue()
示例#17
0
    def createTypeGraph(self, atom3i, rootNode):

        self.obj37 = TypeName(atom3i)

        self.obj37.Name.setValue('StringList')
        self.obj37.graphClass_ = graph_TypeName
        new_obj = graph_TypeName(147.0, 102.0, self.obj37)
        self.obj37.graphObject_ = new_obj
        rootNode.addNode(self.obj37)

        self.obj38 = LeafType(atom3i)

        self.obj38.TypeConstraint.setValue(
            ('typeConst', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE OBJECT'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n\n'))
        self.obj38.Type.setValue(
            ('ltypename', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj38.Type.initialValue = ATOM3String('')
        self.obj38.graphClass_ = graph_LeafType
        new_obj = graph_LeafType(60.0, 316.0, self.obj38)
        self.obj38.graphObject_ = new_obj
        rootNode.addNode(self.obj38)

        self.obj39 = LeafType(atom3i)

        self.obj39.TypeConstraint.setValue(
            ('typeConst', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE OBJECT'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n\n'))
        self.obj39.Type.setValue(
            ('ltypename', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj39.Type.initialValue = ATOM3String('')
        self.obj39.graphClass_ = graph_LeafType
        new_obj = graph_LeafType(249.0, 317.0, self.obj39)
        self.obj39.graphObject_ = new_obj
        rootNode.addNode(self.obj39)

        self.obj40 = Operator(atom3i)

        self.obj40.type.setValue((['X', 'U', '->'], 1))
        self.obj40.type.config = 0
        self.obj40.graphClass_ = graph_Operator
        new_obj = graph_Operator(177.0, 229.0, self.obj40)
        self.obj40.graphObject_ = new_obj
        rootNode.addNode(self.obj40)
        self.obj37.out_connections_.append(self.obj40)
        self.obj40.in_connections_.append(self.obj37)
        self.obj40.out_connections_.append(self.obj39)
        self.obj39.in_connections_.append(self.obj40)
        self.obj40.out_connections_.append(self.obj38)
        self.obj38.in_connections_.append(self.obj40)
示例#18
0
def createNewOperator(self, wherex, wherey, screenCoordinates=1):
    self.fromClass = None
    self.toClass = None
    # try the global constraints...
    res = self.ASGroot.preCondition(ASG.CREATE)
    if res:
        self.constraintViolation(res)
        self.mode = self.IDLEMODE
        return

    new_semantic_obj = Operator(self)
    ne = len(self.ASGroot.listNodes["Operator"])
    if new_semantic_obj.keyword_:
        new_semantic_obj.keyword_.setValue(
            new_semantic_obj.keyword_.toString() + str(ne))
    if screenCoordinates:
        new_obj = graph_Operator(self.UMLmodel.canvasx(wherex),
                                 self.UMLmodel.canvasy(wherey),
                                 new_semantic_obj)
    else:  # already in canvas coordinates
        new_obj = graph_Operator(wherex, wherey, new_semantic_obj)
    new_obj.DrawObject(self.UMLmodel, self.editGGLabel)
    self.UMLmodel.addtag_withtag("Operator", new_obj.tag)
    new_semantic_obj.graphObject_ = new_obj
    self.ASGroot.addNode(new_semantic_obj)
    res = self.ASGroot.postCondition(ASG.CREATE)
    if res:
        self.constraintViolation(res)
        self.mode = self.IDLEMODE
        return

    res = new_semantic_obj.postCondition(ASGNode.CREATE)
    if res:
        self.constraintViolation(res)
        self.mode = self.IDLEMODE
        return

    self.mode = self.IDLEMODE
    if self.editGGLabel:
        self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE)
    else:
        self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE)
    return new_semantic_obj
示例#19
0
def filter_main(stock_new, state_dt, predict_dt, year):
    # 建立数据库连接
    db = pymysql.connect(host='127.0.0.1',
                         user='******',
                         passwd='admin',
                         db='stock',
                         charset='utf8')
    cursor = db.cursor()

    #先更新持股天数
    sql_update_hold_days = 'update my_stock_pool w set w.hold_days = w.hold_days + 1'
    cursor.execute(sql_update_hold_days)
    db.commit()

    #先卖出
    deal = Deal.Deal()
    stock_pool_local = deal.stock_pool
    for stock in stock_pool_local:
        sql_predict = "select predict from good_pool a where a.state_dt = '%s' and a.stock_code = '%s'" % (
            predict_dt, stock)
        cursor.execute(sql_predict)
        done_set_predict = cursor.fetchall()
        predict = 0
        if len(done_set_predict) > 0:
            predict = int(done_set_predict[0][0])
        ans = Operator.sell(stock, state_dt, predict, year)

    #后买入
    #对于已经持仓的股票不再重复买入
    stock_new2 = [x for x in stock_new if x not in stock_pool_local]
    #每只买入股票配仓资金为3万元
    for stock_buy in stock_new2:
        deal_buy = Deal.Deal()
        if deal_buy.cur_money_rest > 30000:
            # sql_ban_pool = "select distinct stock_code from ban_list"
            # cursor.execute(sql_ban_pool)
            # done_ban_pool = cursor.fetchall()
            # ban_list = [x[0] for x in done_ban_pool]
            ans = Operator.buy(stock_buy, state_dt, 30000, year)
            break
    db.close()
示例#20
0
def createNewOperator(self, wherex, wherey, screenCoordinates = 1):
   self.fromClass = None
   self.toClass = None
   # try the global constraints...
   res = self.ASGroot.preCondition(ASG.CREATE)
   if res:
      self.constraintViolation(res)
      self.mode=self.IDLEMODE
      return

   new_semantic_obj = Operator(self)
   ne = len(self.ASGroot.listNodes["Operator"])
   if new_semantic_obj.keyword_:
      new_semantic_obj.keyword_.setValue(new_semantic_obj.keyword_.toString()+str(ne))
   if screenCoordinates:
      new_obj = graph_Operator(self.UMLmodel.canvasx(wherex), self.UMLmodel.canvasy(wherey), new_semantic_obj)
   else: # already in canvas coordinates
      new_obj = graph_Operator(wherex, wherey, new_semantic_obj)
   new_obj.DrawObject(self.UMLmodel, self.editGGLabel)
   self.UMLmodel.addtag_withtag("Operator", new_obj.tag)
   new_semantic_obj.graphObject_ = new_obj
   self.ASGroot.addNode(new_semantic_obj)
   res = self.ASGroot.postCondition(ASG.CREATE)
   if res:
      self.constraintViolation(res)
      self.mode=self.IDLEMODE
      return

   res = new_semantic_obj.postCondition(ASGNode.CREATE)
   if res:
      self.constraintViolation(res)
      self.mode=self.IDLEMODE
      return

   self.mode=self.IDLEMODE
   if self.editGGLabel :
      self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE)
   else:
      self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE)
   return new_semantic_obj
示例#21
0
def one_sided_CED(S1, S2, sim, f_k, alpha):
    """
    :return: Float -- \tilde{d}_{CED}(S_1,S_2) Cost to edit S1 -> S2
    """
    D = np.zeros((len(S1)+1, len(S2)+1))
    for i in range(len(S1) + 1):
        for j in range(len(S2) +1):
            if(i == 0 or j == 0):
                D[i, j] = j + i
            else:
                op_mod = Operator(Edit_operator.MOD, S1, S2[j-1], i-1)
                op_del = Operator(Edit_operator.DEL, S1, S1[i-1], i-1)
                op_add = Operator(Edit_operator.ADD, S1, S2[j-1], i-1)

                cost_mod = edit_cost(op_mod, f_k, sim, alpha)
                cost_del = edit_cost(op_del, f_k, sim, alpha)
                cost_add = edit_cost(op_add, f_k, sim, alpha)

                D[i, j] = round(min(D[i - 1, j-1] + cost_mod,
                              D[i - 1, j] + cost_del,
                              D[i, j - 1] + cost_add), 2)
    return D[len(S1), len(S2)]
示例#22
0
def test_iadd():
    class C(object):
        def __add__(self, other):
            return '__add__'

        def __iadd__(self, other):
            return '__iadd__'

    c = C()
    # c + 5
    assert operator.add(c, 5) == "__add__"
    assert Operator.add(c, 5) == '__add__'
    # c += 5
    assert operator.iadd(c, 5) == "__iadd__"
    assert Operator.iadd(c, 5) == '__iadd__'

    class C(object):
        def __add__(self, other):
            return '__add__'
    c = C()
    assert operator.iadd(c, 5) == "__add__"
    assert Operator.iadd(c, 5) == '__add__'
示例#23
0
def filter_main(stock_new, state_dt, predict_dt, poz):
    # 建立数据库连接
    db = pymysql.connect(host='127.0.0.1',
                         user='******',
                         passwd='000109',
                         db='stock_list',
                         charset='utf8')
    cursor = db.cursor()

    #先更新持股天数
    sql_update_hold_days = 'update my_stock_pool w set w.hold_days = w.hold_days + 1'
    cursor.execute(sql_update_hold_days)
    db.commit()

    #先卖出
    deal = Deal.Deal(state_dt)
    stock_pool_local = deal.stock_pool
    for stock in stock_pool_local:
        # sql_predict = "select predict from good_pool_all a where a.state_dt = '%s' and a.stock_code = '%s'"%(predict_dt,stock)
        # cursor.execute(sql_predict)
        # done_set_predict = cursor.fetchall()
        predict = 0
        # if len(done_set_predict) > 0:
        #     # predict = int(done_set_predict[0][0])
        #     ans = Operator.sell(stock,state_dt,predict)

    #后买入
    for stock_index in range(len(stock_new)):
        deal_buy = Deal.Deal(state_dt)
        #if poz[stock_index]*deal_buy.cur_money_rest >= :
        # sql_ban_pool = "select distinct stock_code from ban_list"
        # cursor.execute(sql_ban_pool)
        # done_ban_pool = cursor.fetchall()
        # ban_list = [x[0] for x in done_ban_pool]

        # # 如果模型f1分值低于50则不买入
        # sql_f1_check = "select * from good_pool_all a where a.stock_code = '%s' and a.state_dt < '%s' order by a.state_dt desc limit 1"%(stock_new[stock_index],state_dt)
        # cursor.execute(sql_f1_check)
        # done_check = cursor.fetchall()
        # db.commit()
        # if len(done_check) > 0:
        #     if float(done_check[0][4]) < 0.5:
        #         print('F1 Warning !!')
        #         continue

        ans = Operator.buy(stock_new[stock_index], state_dt,
                           poz[stock_index] * deal_buy.cur_money_rest)
        del deal_buy
    db.close()
示例#24
0
def search_five_times():
    time.sleep(1.5)
    print('开始执行[点击搜索框推荐词5次]')
    # 点击首页
    operator.touch_app_home()
    time.sleep(1.5)
    # 点击搜索框
    operator.touch_app_search_bar()
    time.sleep(1.5)
    # 点击第一个推荐词
    for i in range(5):
        touch([200, 250])
        time.sleep(1.5)
        operator.touch_back()
        time.sleep(1)
    operator.touch_back()
    time.sleep(2)
示例#25
0
def Bot_BactTest(stock_code, date_seq, para_min, para_up_limit,
                 para_low_limit):

    # 建立数据库连接,剔除已入库的部分
    db = pymysql.connect(host='127.0.0.1',
                         user='******',
                         passwd='admin',
                         db='stock',
                         charset='utf8')
    cursor = db.cursor()
    sql_dele = "delete from %s_my_cap where seq != 1" % (stock_code)
    cursor.execute(sql_dele)
    db.commit()

    for i in range(200, len(date_seq)):

        ans = singal2(stock_code, date_seq[i - 200:i], para_min, para_up_limit,
                      para_low_limit)

        #ans2 = warning_macd(date_seq[i-200:i],para_warning)
        ans2 = 0
        print('State_Dt : ' + str(date_seq[i]) + '   Singal : ' + str(ans) +
              '   Warning : ' + str(ans2))
        cap = My_CAP.My_CAP(stock_code)
        buy_money = cap.usdt_acct
        if ans == 1 and ans2 == 0:
            op.buy(stock_code, date_seq[i - 1], buy_money, para_min)
        elif ans == -1:
            op.sell(stock_code, date_seq[i - 1], -1, para_min)
        elif ans == -1:
            op.sell(stock_code, date_seq[i - 1], 0, para_min)
    db.commit()
    print('ALL Finished!!')

    sql_resu_select = "select * from %s_my_cap order by seq desc limit 1" % (
        stock_code)
    cursor.execute(sql_resu_select)
    done_set_resu_select = cursor.fetchall()
    final_cap = done_set_resu_select[0][0]
    sql_resu = "insert into coordinate_descent(Bot_Name,up_limit,low_limit,final_cap,state_dt)values('%s','%.2f','%.2f','%.2f','%s')" % (
        str(str(stock_code) + str(para_min)) + str('Signal2'),
        float(para_up_limit), float(para_low_limit), float(final_cap),
        date_seq[-1])
    cursor.execute(sql_resu)
    db.commit()
    db.close()
示例#26
0
    def splitFileOrCode(self, data, args):

        ret_list = list()
        logger.info(data)
        args_split = {
            'ggtype': data['f_ggtype'],
            'wtype': data['f_wtype'],
            'beishu': data['f_beishu'],
            'fileorcode': data['f_fileorcode'],
            'isquchu': data['f_isquchu'],
            'danma': data['f_danma'],
            'lotid': data['f_lotid'],
        }

        split_obj = Operator.get(data['f_lotid'])

        logger.info(args_split)
        ret = split_obj.splitCodes(args_split)
        for info in ret:
            tmp_dict = copy.deepcopy(args)
            tmp_dict['wtype'] = info['wtype']
            tmp_dict['ggtype'] = info['ggtype']
            tmp_dict['fileorcode'] = info['fileorcode']
            tmp_dict['code'] = info['fileorcode']
            tmp_dict['cptype'] = info['wtype']
            tmp_dict['beishu'] = info['beishu']
            tmp_dict['zhushu'] = info['zhushu']
            tmp_dict['allmoney'] = int(info['beishu']) * int(
                info['zhushu']) * 2
            tmp_dict['firstprocessid'] = (info['fileorcode'].split(
                '/')[0]).split('|')[0]  # 投注内容的第一场,不是比赛的第一场,有疑问
            tmp_dict['lastprocessid'] = (
                info['fileorcode'].split('/')[-1]).split('|')[0]
            ret_list.append(tmp_dict)

        return ret_list
示例#27
0
def read_loop():
    # 点击首页
    operator.touch_app_home()
    time.sleep(2)
    # 预防万一, 多看5次
    for i in range(35):
        # 置顶的文章貌似是不给金币的, 所以先上滑一次
        swipe([500, 1565], [500, 1065])
        time.sleep(1)
        touch(
            Template(r"tpl1563451046681.png",
                     record_pos=(-0.168, -0.31),
                     resolution=(1080, 1920)))
        time.sleep(1.5)
        if not exists(
                Template(r"tpl1563458236019.png",
                         record_pos=(0.002, -0.766),
                         resolution=(1080, 1920))):
            i = i - 1
            operator.touch_back()
            time.sleep(2)
            continue

        start = time.time()
        period = time.time() - start
        # 在文章内停留35s, 期间上下滑动, 然后调用返回键
        while period <= 35:
            print(str(int(period)) + '/35s')
            swipe([500, 1565], [500, 1065])
            time.sleep(1.5)
            swipe([500, 1565], [500, 1065])
            #             swipe([500, 1065], [500, 1565])
            period = time.time() - start
        operator.touch_back()
        time.sleep(2)
        print('当前进度: ' + str(i) + '/35')
示例#28
0
    def createTypeGraph(self, atom3i, rootNode):
        self.types = atom3i.types

        self.obj28 = TypeName(atom3i)

        self.obj28.Name.setValue('testModels')
        self.obj28.graphClass_ = graph_TypeName
        if atom3i.genGraphics:
            from graph_TypeName import *
            new_obj = graph_TypeName(74.0, 59.0, self.obj28)
        else:
            new_obj = None
        self.obj28.graphObject_ = new_obj
        rootNode.addNode(self.obj28)

        self.obj29 = LeafType(atom3i)

        self.obj29.TypeConstraint.setValue(
            ('typeConst', (['Python', 'OCL'], 1),
             (['PREcondition', 'POSTcondition'], 1), ([
                 'EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT',
                 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'
             ], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), '\n\n'))
        self.obj29.Type.setValue(
            ('a', 'String', None, ('Key', 0), ('Direct Editing', 1)))
        self.obj29.Type.initialValue = ATOM3String('a')
        self.obj29.graphClass_ = graph_LeafType
        if atom3i.genGraphics:
            from graph_LeafType import *
            new_obj = graph_LeafType(29.0, 198.0, self.obj29)
        else:
            new_obj = None
        self.obj29.graphObject_ = new_obj
        rootNode.addNode(self.obj29)

        self.obj30 = ModelType(atom3i)

        self.obj30.MetaModelName.setValue('StateChart')
        self.obj30.Name.setValue('Method_SC')
        self.obj30.graphClass_ = graph_ModelType
        if atom3i.genGraphics:
            from graph_ModelType import *
            new_obj = graph_ModelType(139.0, 286.0, self.obj30)
        else:
            new_obj = None
        self.obj30.graphObject_ = new_obj
        rootNode.addNode(self.obj30)

        self.obj31 = ModelType(atom3i)

        self.obj31.MetaModelName.setValue('CBD4OOCSMP')
        self.obj31.Name.setValue('Method_CBD')
        self.obj31.graphClass_ = graph_ModelType
        if atom3i.genGraphics:
            from graph_ModelType import *
            new_obj = graph_ModelType(302.0, 289.0, self.obj31)
        else:
            new_obj = None
        self.obj31.graphObject_ = new_obj
        rootNode.addNode(self.obj31)

        self.obj32 = Operator(atom3i)

        self.obj32.type.setValue((['X', 'U', '->'], 0))
        self.obj32.type.config = 0
        self.obj32.graphClass_ = graph_Operator
        if atom3i.genGraphics:
            from graph_Operator import *
            new_obj = graph_Operator(106.0, 127.0, self.obj32)
        else:
            new_obj = None
        self.obj32.graphObject_ = new_obj
        rootNode.addNode(self.obj32)

        self.obj33 = Operator(atom3i)

        self.obj33.type.setValue((['X', 'U', '->'], 1))
        self.obj33.type.config = 0
        self.obj33.graphClass_ = graph_Operator
        if atom3i.genGraphics:
            from graph_Operator import *
            new_obj = graph_Operator(192.0, 183.0, self.obj33)
        else:
            new_obj = None
        self.obj33.graphObject_ = new_obj
        rootNode.addNode(self.obj33)
        self.obj28.out_connections_.append(self.obj32)
        self.obj32.in_connections_.append(self.obj28)
        self.obj28.graphObject_.pendingConnections.append(
            (self.obj28.graphObject_.tag, self.obj32.graphObject_.tag,
             [113.0, 93.0, 112.0, 145.0], 2, 0))
        self.obj32.out_connections_.append(self.obj29)
        self.obj29.in_connections_.append(self.obj32)
        self.obj32.graphObject_.pendingConnections.append(
            (self.obj32.graphObject_.tag, self.obj29.graphObject_.tag,
             [133.0, 218.0, 141.0, 145.0], 2, 0))
        self.obj32.out_connections_.append(self.obj33)
        self.obj33.in_connections_.append(self.obj32)
        self.obj32.graphObject_.pendingConnections.append(
            (self.obj32.graphObject_.tag, self.obj33.graphObject_.tag,
             [169.0, 173.0, 141.0, 145.0], 2, 0))
        self.obj33.out_connections_.append(self.obj30)
        self.obj30.in_connections_.append(self.obj33)
        self.obj33.graphObject_.pendingConnections.append(
            (self.obj33.graphObject_.tag, self.obj30.graphObject_.tag,
             [234.0, 307.0, 227.0, 201.0], 2, 0))
        self.obj33.out_connections_.append(self.obj31)
        self.obj31.in_connections_.append(self.obj33)
        self.obj33.graphObject_.pendingConnections.append(
            (self.obj33.graphObject_.tag, self.obj31.graphObject_.tag,
             [305.0, 312.0, 227.0, 201.0], 2, 0))
示例#29
0
 def operate(self):
     operator = Operator(str(self.args.ip), PORT)
     operator.doProcess(self.op)
示例#30
0
 def parseUnit(self, t):
     if self.lastValue and self.lastValue.isNumber():
         self.processValue(Operator.unitMultiplyOperator())
     self.parseToken('1')
     self.lastValue.addUnitStr(t)
     return None
示例#31
0
  def createTypeGraph(self, atom3i, rootNode):
    self.types = atom3i.types

    self.obj203=TypeName(atom3i)
    self.obj203.preAction( rootNode.CREATE )
    self.obj203.isGraphObjectVisual = True

    if(hasattr(self.obj203, '_setHierarchicalLink')):
      self.obj203._setHierarchicalLink(False)

    # Name
    self.obj203.Name.setValue('FSB_Button_TYPE')

    self.obj203.graphClass_= graph_TypeName
    if atom3i.genGraphics:
       new_obj = graph_TypeName(60.0,80.0,self.obj203)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj203.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj203)
    self.obj203.postAction( rootNode.CREATE )

    self.obj204=LeafType(atom3i)
    self.obj204.preAction( rootNode.CREATE )
    self.obj204.isGraphObjectVisual = True

    if(hasattr(self.obj204, '_setHierarchicalLink')):
      self.obj204._setHierarchicalLink(False)

    # TypeConstraint
    self.obj204.TypeConstraint.setValue(('typeConst', (['Python', 'OCL'], 1), (['PREcondition', 'POSTcondition'], 1), (['EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT', 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), None))

    # Type
    self.obj204.Type.setValue(('iconPath', 'String', None, ('Key', 0), ('Direct Editing', 1)))
    self.obj204.Type.initialValue=ATOM3String('', 20)
    self.obj204.Type.isDerivedAttribute = False

    self.obj204.graphClass_= graph_LeafType
    if atom3i.genGraphics:
       new_obj = graph_LeafType(220.0,100.0,self.obj204)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj204.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj204)
    self.obj204.postAction( rootNode.CREATE )

    self.obj205=LeafType(atom3i)
    self.obj205.preAction( rootNode.CREATE )
    self.obj205.isGraphObjectVisual = True

    if(hasattr(self.obj205, '_setHierarchicalLink')):
      self.obj205._setHierarchicalLink(False)

    # TypeConstraint
    self.obj205.TypeConstraint.setValue(('typeConst', (['Python', 'OCL'], 1), (['PREcondition', 'POSTcondition'], 1), (['EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT', 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), None))

    # Type
    self.obj205.Type.setValue(('action', 'Text', None, ('Key', 0), ('Direct Editing', 1)))
    self.obj205.Type.initialValue=ATOM3Text('# Button action code\n# The following is generated for you: \n# def action(self): # self = ATOM3 instance\n# Typical contents of action:\n# newPlace = self.createNew<CLASS NAME IN META-MODEL>(self, wherex, wherey)\n# Action that shows dialog to edit ASG attributes:\n# self.modelAttributes(self.ASGroot.getASGbyName("<META-MODEL NAME>_META")) \n', 80,15 )
    self.obj205.Type.isDerivedAttribute = False

    self.obj205.graphClass_= graph_LeafType
    if atom3i.genGraphics:
       new_obj = graph_LeafType(220.0,180.0,self.obj205)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj205.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj205)
    self.obj205.postAction( rootNode.CREATE )

    self.obj206=Operator(atom3i)
    self.obj206.preAction( rootNode.CREATE )
    self.obj206.isGraphObjectVisual = True

    if(hasattr(self.obj206, '_setHierarchicalLink')):
      self.obj206._setHierarchicalLink(False)
      
      
    self.obj40=LeafType(atom3i)
    self.obj40.preAction( rootNode.CREATE )
    self.obj40.isGraphObjectVisual = True

    if(hasattr(self.obj40, '_setHierarchicalLink')):
      self.obj40._setHierarchicalLink(False)

    # TypeConstraint
    self.obj40.TypeConstraint.setValue(('typeConst', (['Python', 'OCL'], 1), (['PREcondition', 'POSTcondition'], 1), (['EDIT', 'SAVE', 'CREATE', 'CONNECT', 'DELETE', 'DISCONNECT', 'TRANSFORM', 'SELECT', 'DRAG', 'DROP', 'MOVE'], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]), None))

    # Type
    self.obj40.Type.setValue(('takesActionImmediately', 'Boolean', None, ('Key', 0), ('Direct Editing', 1)))
    self.obj40.Type.initialValue=ATOM3Boolean()
    self.obj40.Type.initialValue.setValue(('', 0))
    self.obj40.Type.initialValue.config = 1
    self.obj40.Type.isDerivedAttribute = False

    self.obj40.graphClass_= graph_LeafType
    if atom3i.genGraphics:
       new_obj = graph_LeafType(220.0,240.0,self.obj40)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj40.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj40)
    self.obj40.postAction( rootNode.CREATE )
    

    # type
    self.obj206.type.setValue( (['X', 'U', '->'], 0) )
    self.obj206.type.config = 0

    self.obj206.graphClass_= graph_Operator
    if atom3i.genGraphics:
       new_obj = graph_Operator(188.0,107.5,self.obj206)
       new_obj.layConstraints = dict() # Graphical Layout Constraints 
       new_obj.layConstraints['scale'] = [1.0, 1.0]
    else: new_obj = None
    self.obj206.graphObject_ = new_obj

    # Add node to the root: rootNode
    rootNode.addNode(self.obj206)
    self.obj206.postAction( rootNode.CREATE )

    self.obj203.out_connections_.append(self.obj206)
    self.obj206.in_connections_.append(self.obj203)
    self.obj203.graphObject_.pendingConnections.append((self.obj203.graphObject_.tag, self.obj206.graphObject_.tag, [136.0, 96.0, 188.0, 107.5], 2, 1))
    self.obj206.out_connections_.append(self.obj204)
    self.obj204.in_connections_.append(self.obj206)
    self.obj206.graphObject_.pendingConnections.append((self.obj206.graphObject_.tag, self.obj204.graphObject_.tag, [240.0, 119.0, 188.0, 107.5], 2, 1))
    self.obj206.out_connections_.append(self.obj205)
    self.obj205.in_connections_.append(self.obj206)
    self.obj206.graphObject_.pendingConnections.append((self.obj206.graphObject_.tag, self.obj205.graphObject_.tag, [240.0, 199.0, 188.0, 107.5], 2, 1))
示例#32
0
        para_min)
    #sql_dt_seq = "select distinct state_dt from btc_%smin a where a.timestamp >= 1524137700 order by state_dt asc"%(para_min)
    #30  1522740600   60    1522382400

    cursor.execute(sql_dt_seq)
    done_set_dt = cursor.fetchall()
    date_seq = [x[0] for x in done_set_dt]
    for i in range(1000, len(date_seq)):
        ans = singal(date_seq[i - 1000:i], para_min)
        #ans2 = warning_macd(date_seq[i-200:i],para_warning)
        ans2 = 0
        print('State_Dt : ' + str(date_seq[i]) + '   Singal : ' + str(ans) +
              '   Warning : ' + str(ans2))
        cap = My_CAP.My_CAP()
        if ans == 1 and ans2 == 0:
            op.buy('BTC', date_seq[i], cap.usdt_acct, para_min)
        elif ans == -1:
            op.sell('BTC', date_seq[i], -1, para_min)
    db.commit()
    print('ALL Finished!!')

    sql_show_btc = "select * from btc_%smin order by state_dt asc" % (para_min)
    #sql_show_btc = "select * from btc_%smin a where a.timestamp >= 1524137700 order by state_dt asc"%(para_min)

    cursor.execute(sql_show_btc)
    done_set_show_btc = cursor.fetchall()
    btc_x = [int(x[-1]) for x in done_set_show_btc]
    btc_y = [x[2] / done_set_show_btc[0][2] for x in done_set_show_btc]
    dict_anti_x = {}
    dict_x = {}
    for a in range(len(btc_x)):
import Operator as op

if __name__ == '__main__':
    print(op.multiple(2, 4))
    print(op.divide(2, 0))