Пример #1
0
 def seatmoney_bu(self, event):
     ''' 函数说明:席位资金按钮'''
     self.time_count()
     invclass, tabdata, alldeparment, allvari = fn.allclient_cal(
         self.data, 0, 1, 'settlement')
     colname = [u'交易所', u'结算价与持仓价盈亏', u'保证金调整(负为能释放)', u'合计(正为能释放)']
     hac = {'DCE': 0, 'CFE': 0, 'SHF': 0, 'CZC': 0}
     ham = {'DCE': 0, 'CFE': 0, 'SHF': 0, 'CZC': 0}
     hamr = {'DCE': 0, 'CFE': 0, 'SHF': 0, 'CZC': 0}
     for x in invclass:
         for y in hac:
             s = 'holdprofit_' + y
             hac[y] += invclass[x].InvInf[s]
             s = 'margin_' + y
             ham[y] += invclass[x].InvInf[s]
     hch = {'DCE': 'DCE', 'CFFEX': 'CFE', 'SHFE': 'SHF', 'CZCE': 'CZC'}
     for x in self.data['invclass']:
         for pos in self.data['invclass'][x].Position:
             hamr[hch[pos['house']]] += pos['realmargin']
     od = []
     for x in hac:
         v = [x]
         v.append(round(hac[x], 2))
         v.append(round(ham[x] - hamr[x], 2))
         v.append(round(v[1] - v[2], 2))
         for i in range(len(v)):
             v[i] = fn.float_to_str(v[i])
         od.append(v)
     self.time_count()
     tg = table_gui(s_title=u'席位资金', colname=colname, data=od, w=150)
     tg.mainloop()
Пример #2
0
    def riskclient_visiable(self, dept):
        ''' 函数说明:按营业部显示风险客户'''
        self.time_count()
        if self.data['risk_client'].has_key(dept):
            ids = self.data['risk_client'][dept]
        else:
            ids = []
            for x in self.data['risk_client']:
                ids = ids + self.data['risk_client'][x]
        frame = tk.Frame(self.note, bg='Azure')
        self.note.add(frame, text=dept)
        self.note.select(self.note.tabs()[-1])
        invclass = self.data['invclass2']
        l1 = []
        l2 = []
        for x in ids:
            if invclass[x].InvInf['riskdegree'] >= 100:
                l1.append((invclass[x].InvInf['riskdegree'], x))
            else:
                l2.append((invclass[x].InvInf['cor_riskdegree'], x))
        l1.sort(reverse=True)
        l2.sort(reverse=True)
        colname = self.bsh_class.bsh_tg.tree['columns']
        outdata = []
        for x in l1 + l2:
            ivid = x[1]
            td = []
            for y in colname:
                if y == 'invid':
                    td.append(ivid)
                    continue
                try:
                    td.append(
                        fn.float_to_str(round(invclass[ivid].InvInf[y], 2)))
                except:
                    td.append(invclass[ivid].InvInf[y])
            outdata.append(td)

        tg = table_gui(colname=colname,
                       data=outdata,
                       isframe=frame,
                       parentclass=self)
        tg.highlight()
        tg.sorttree()
        tg.bus_double_click()
        tg.canvas.xview_moveto(0.0)
        self.time_count(False)
Пример #3
0
    def out_table(self, tabdata, alldeparment, allvari):
        ''' 函数说明:大表显示'''
        rowname = tabdata.keys()
        rowname.sort()
        #colname=data[rowname[0]].keys()
        rcolname = [
            'invid', 'inv_name', 'invdepartment', 'spmark', 'riskdegree',
            'cor_riskdegree', 'leftcapital', 'cor_leftcapital', 'seat',
            'margin', 'capital', 'lastriskstate', 'maxcode', 'posstrut',
            'forcedbound', 'phone'
        ]
        data = []
        tags = []
        for i in range(len(rowname)):
            v = []
            for x in rcolname:
                temp = tabdata[rowname[i]][x]
                if type(temp) == float:
                    temp = fn.float_to_str(round(temp, 2))
                v.append(temp)
            data.append(v)
            tags.append(tabdata[rowname[i]]['tags'])
        imf = [0, 0, 0, 0, 0]
        for i in range(len(rowname)):
            if float(tabdata[rowname[i]]['leftcapital']) < 0:
                imf[0] += float(tabdata[rowname[i]]['leftcapital'])
                imf[1] += 1
                if tabdata[rowname[i]]['spmark'] == '1':
                    imf[2] += 1
                if float(tabdata[rowname[i]]['capital']) < 0:
                    imf[3] += float(tabdata[rowname[i]]['capital'])
                    imf[4] += 1
            else:
                break
        tt = u'强平金额:' + fn.float_to_str(imf[0]) + u',强平人数:' + fn.float_to_str(
            imf[1]) + u',其中特殊客户数:' + fn.float_to_str(
                imf[2]) + u'。穿仓金额:' + fn.float_to_str(
                    imf[3]) + u',穿仓人数:' + fn.float_to_str(imf[4])
        #self.labels['bsh_statu'].config(text=tt,fg='red')
        title = u'客户资金风险信息     ' + tt + u'    计算时间:' + datetime.datetime.now(
        ).strftime('%H:%M')

        self.bsh_class.inputdata(title,
                                 rcolname,
                                 data,
                                 tags=tags,
                                 alldeparment=alldeparment,
                                 allvari=allvari,
                                 invclass=self.data['invclass'])
        self.note.select(self.note.tabs()[1])
        self.time_count()
Пример #4
0
 def outpos(self, fs=0):
     frame = self.posframe
     cl = [
         'code', 'longnums', 'shortnums', 'longholdprice', 'shortholdprice',
         'longmar', 'shortmar', 'cor_longmar', 'cor_shortmar'
     ]
     inv = self.inv3
     outdata = []
     for x in inv.Position:
         v = []
         for y in cl:
             v.append(fn.float_to_str(x[y]))
         outdata.append(v)
     if fs:
         tg = table_gui(colname=cl,
                        data=outdata,
                        isframe=frame,
                        w=90,
                        vrows=8)
         self.postree_gui = tg
     else:
         self.postree_gui.resettree(outdata)
Пример #5
0
 def outinf(self):
     inv = self.inv2
     for x in self.up_info:
         for y in x:
             self.labels[y].config(
                 text=fn.float_to_str(round(inv.InvInf[y], 2)))
Пример #6
0
    def __init__(self, data, ivid, isframe=''):
        invclass = data['invclass']
        '''
        ivid=tkSimpleDialog.askstring('HUATAI FUTURE',u'请输入客户号',initialvalue = u'10802698')
        if ivid==None:
            return
        if not invclass.has_key(ivid):
            tkMessageBox.showinfo(title=u'温馨提醒',message=u'找不到投资者'+ivid)
            return
        '''
        inv = copy.deepcopy(invclass[ivid])
        if isframe == '':
            root = tk.Toplevel()
            root.iconbitmap('ht_48X48.ico')
            root.title(u'单个客户风险试算')
        else:
            root = isframe
        self.root = root
        self.data = data
        self.inv = inv
        self.inv2 = copy.deepcopy(inv)
        self.ivid = ivid
        self.codeclass = copy.deepcopy(data['ini_codeclass'])
        self.ps = 'meanprice'
        self.recal()
        self.calforced()
        inv = self.inv2
        labels = {}

        gr = 0
        gl = 0
        tk.Label(root, text=ivid, fg='red').grid(row=gr, column=0, sticky='W')
        tk.Label(root, text=inv.InvInf['inv_name'],
                 fg='red').grid(row=gr, column=3, columnspan=3, sticky='W')
        tk.Label(root, text=inv.InvInf['invdepartment']).grid(row=gr,
                                                              column=1,
                                                              sticky='W')
        tk.Label(root, text=inv.InvInf['seat']).grid(row=gr,
                                                     column=2,
                                                     sticky='W')
        lbname = [[u'交易所可用', u'交易所风险度', u'公司可用', u'公司风险度'],
                  [u'出入金', u'平仓盈亏', u'持仓盈亏', u'手续费'],
                  [u'昨权益', u'权益', u'交易所保证金', u'公司保证金'],
                  [u'质押金额', u'资金冻结', u'银期可取', u'OA可取']]
        for i in range(len(lbname)):
            gr = 1
            for x in lbname[i]:
                lb = tk.Label(root, text=x)
                lb.grid(row=gr, column=i * 2, sticky='W')
                labels[x] = lb
                gr += 1

        cl = [[
            'leftcapital', 'riskdegree', 'cor_leftcapital', 'cor_riskdegree'
        ], ['cashmove', 'closeprofit', 'holdprofit', 'fee'],
              ['lastcapital', 'capital', 'margin', 'cor_margin'],
              ['mortgagemoney', 'frozenmoney', 'bankmoney', 'oa_bankmoney']]
        self.up_info = cl
        self.edit_info = [
            'cashmove', 'mortgagemoney', 'closeprofit', 'fee', 'frozenmoney'
        ]
        for i in range(len(cl)):
            gr = 1
            for x in cl[i]:
                lb = tk.Label(root,
                              bg='white',
                              text=fn.float_to_str(round(inv.InvInf[x], 2)))
                lb.grid(row=gr, column=i * 2 + 1, sticky='W')
                labels[x] = lb
                gr += 1
        labels[u'交易所风险度'].config(fg='red')
        labels['riskdegree'].config(fg='red')
        self.labels = labels
        self.mainframe = tk.LabelFrame(root)
        self.mainframe.grid(row=gr, column=0, columnspan=100, sticky='W')
        self.outtree(1)
        gr += 1
        posframe = tk.LabelFrame(root)
        posframe.grid(row=gr, column=0, columnspan=100, sticky='W')
        self.posframe = posframe
        self.outpos(1)
        self.edit_label()

        cmbox = ttk.Combobox(root, width=5)
        cmbox['values'] = [u'均价', u'今结算', u'昨结算', u'最新价']
        cmbox.grid(row=0, column=6)
        cmbox.current(0)
        self.cmbox = cmbox
        cmbox.bind('<<ComboboxSelected>>', self.cmbox_bu)
        pos_cmbox = ttk.Combobox(root, width=8)
        pos_cmbox['values'] = [u'正常持仓价', u'不利持仓价']
        pos_cmbox.grid(row=0, column=7)
        pos_cmbox.current(0)
        self.pos_cmbox = pos_cmbox
        pos_cmbox.bind('<<ComboboxSelected>>', self.pos_cmbox_bu)