def __init__(self): # 主窗口 self.window = tk.Tk() self.window.wm_attributes('-topmost', 1) # 设置背景色 color = colorConstants() self.window.configure( background=u'#{0}'.format(color.hexColorString(60, 64, 67))) # 窗口标题 self.window.title('Finance Data Dashboard') # 窗口标题小 icon #self.window.iconbitmap('iVBORw0KGgoAAAANSUhEUgAAABwAAAA2CAYAAADUOvnEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA5tJREFUeNrcWE1oE0EUnp0kbWyUpCiNYEpCFSpIMdpLRTD15s2ePHixnj00N4/GoyfTg2fbiwdvvagHC1UQ66GQUIQKKgn1UAqSSFua38b3prPJZDs7s5ufKn0w7CaZ2W/fe9/73kyMRqNB3Nrj1zdn4RJ6du9T2u1a2iHYSxjP4d41oOHGQwAIwSUHIyh8/RA8XeiXh0kLGFoaXiTecw/hoTG4ZCSAaFkY0+BpsZceLtiAoV2FkepZSDk5EpppczBvpuuQCqx0YnkYcVVoqQYMyeCG+lFdaGkXeVOFNu4aEBalOBk6sbQrQF7gSdK5JXjuHXuYVIVyr0TZ0FjKDeCs6km7JYMUdrWAUVmZUBtmRnVPK+x6nIR2xomH06R35ggwJPeofWphr/W5UjPIxq8B2bKgE8C4HVHWvg+2gZjXj19PkdFztY7bk9TDCH/g6oafDPpaoMvZIRI5WyMB/0Hv++HkpTKE0kM+A+h20cPAfN4GuRyp9G+LMTW+z8rCLI8b46XO9zRcYZTde/j0AZm8WGb3Y2F9KLlE2nqYkjFLJAsDOl/lea0q55mqxXcL7YBc++bsCPMe8mUyU2ZIpnCoblca6TZA/ga2Co8PGg7UGUlEDd0ueptglbrRZLLE7poti6pCaWUo2pu1oaYI1CF9b9cCZPO3F8ikJQ/rPpQT5YETht26ss+uCIL2Y8vHwJGpA96GI5mjOlaKhowUy6BcNcgIhDviTGWCGFaqEuufWz4pgcbCh+w0gEOyOjTlTtYYlIWPYWKEsLDzOs+nhzaO1KEpd+MXpOoTUgKiNyhdy5aSMPNVqxtSsJFgza5EWA4zKtCJ2OGbLn0JSLu8+SL4G86p1Fpr7ABXdGFF/UTD4rfmFYFw4G9VAJ9SM3aF8l3yok4/J6IV9sDVb36ynmtJ2M5+CwxTYBdKNMBaocKGV2nYgkz6r+cHBP30MzAfi4Sy+BebSoPIOi8PW1PpCCvr/KOD4k9Zu0WSH0Y0+SxJ2awp/nlwKtcGyHOJ8vNHtRJzhPlsHr8MogtlVtwUU0tSM1x58upSKbfJnSKUR07GVMKkDNfXpzpv0RTHy3nZMVx5IOWdZIaPabGFvfpwpjnvfmJHXLaEvZUTseu/TeLc+xgAPhEAb/PbjO6PBaOTf6LQRh/dERde23zxLtOXbaKNhfq2L/1fAOPHDUhOpIf5485h7l+GNHHiSYPKE3Myz9sFxoJuAyazvwIMAItferha5LTqAAAAAElFTkSuQmCC') self.window.iconbitmap(os.path.join(currentDir, 'icon1.ico')) # icon2.ico 备用 # 窗口尺寸 self.window.geometry( '542x360+100-100') # +{0} = origin.x 80 +{1} = origin.y # 剪切板 self.window.clipboard_clear() # 清除剪贴板内容 self.window.clipboard_append('') # 向剪贴板追加内容,防止 clipboard_get 函数崩溃 self.clipboardValue = StringVar() self.clipboardValue.set(self.window.clipboard_get()) self.createWidgets() # 开启剪切板监控子线程 t = clipboardObserveThread(kwargs={ \ thread_key_window : self.window, \ thread_key_clipboard_text_callback: self.clipboardTextUpdate \ }) t.start()
def __init__(self): self.pm = pathManager() self.colorManager = colorConstants() self.allAccounts = [] dataPath = os.path.join(self.pm.configPath, 'account.json') if os.path.exists(dataPath): with open(dataPath, 'r', encoding='utf-8') as f: self.allAccounts = json.loads(f.read())
def __init__(self): self.pm = pathManager() self.fundCategorys = self.getFundCategorys() categoryConstants = assetCategoryConstants() self.category1Array = categoryConstants.category1Array self.category2Array = categoryConstants.category2Array self.category3Array = categoryConstants.category3Array self.modelArray = [] self.colorConstants = colorConstants()
def __init__(self, strategy='a'): if strategy == 'a': self.pm = pathManager(strategyName='康力泉') elif strategy == 'b': self.pm = pathManager(strategyName='父母') self.fundCategorys = self.getFundCategorys() self.colorConstants = colorConstants() self.fundJsonFilePathExt = '' self.dingtalk = dingtalk()
def __init__(self, path): self.pm = pathManager() self.colorConstants = colorConstants() categoryConstants = assetCategoryConstants() self.category1Array = categoryConstants.category1Array self.category2Array = categoryConstants.category2Array self.category3Array = categoryConstants.category3Array self.indexValueInfo = indexValueInfo() self.historyManager = historyProfitManager() self.dingtalk = dingtalk() self.outputPath = path
def __init__(self): self.pm = pathManager() self.fundCategorys = self.getFundCategorys() self.historyManager = historyProfitManager() categoryConstants = assetCategoryConstants() self.category1Array = categoryConstants.category1Array self.category2Array = categoryConstants.category2Array self.category3Array = categoryConstants.category3Array self.modelArray = [] self.accountManager = accountManager() self.colorConstants = colorConstants() self.dingtalk = dingtalk()
def __init__(self, strategy='a'): if strategy == 'a': self.pm = pathManager(strategyName='康力泉') elif strategy == 'b': self.pm = pathManager(strategyName='父母') self.fundCategorys = self.getFundCategorys() categoryConstants = assetCategoryConstants() self.category1Array = categoryConstants.category1Array self.category2Array = categoryConstants.category2Array self.category3Array = categoryConstants.category3Array self.modelArray = [] self.colorConstants = colorConstants() self.accountManager = accountManager() self.fundJsonFilePathExt = '' self.dingtalk = dingtalk()
def __init__(self): auth('13810650842', '123456a') print(u'聚宽数据API:{0}'.format(get_query_count())) self.pm = pathManager('全家') self.colorConstants = colorConstants() self.result_df = pd.read_csv(os.path.join(self.pm.holdingOutputPath,u'indexHoldingInfo.csv'), sep='\t') self.outputRenameColumns = {'name': '名称', 'code': '代码', 'market_cap': '市值(亿元)', 'pe_ratio': 'pe', 'pb_ratio': 'pb', 'daily_change': '涨跌幅', 'holding': '持有市值(元)', 'daily_gain': '日盈亏', 'hy_code1': '一级行业代码', 'hy_name1': '一级行业名称', 'hy_code2': '二级行业代码', 'hy_name2': '二级行业名称', 'relate_index': '相关指数'} # 转置列名的 key-value,作为读入内存后的列名 self.inputRenameColumns = dict( [(value, key) for key, value in self.outputRenameColumns.items()]) self.result_df = self.result_df.rename(columns=self.inputRenameColumns) with open(os.path.join(self.pm.configPath,u'indexIndustryInfo.json'),'r',encoding='utf-8') as f: self.swIndexInfos = json.loads(f.read())
def __init__(self, strategy='a'): categoryConstants = assetCategoryConstants() self.colorConstants = colorConstants() self.category1Array = categoryConstants.category1Array self.category2Array = categoryConstants.category2Array self.category3Array = categoryConstants.category3Array self.modelArray = [] self.jsonStr = u'' self.echarts = [] self.strategy = strategy if strategy == 'a': self.pm = pathManager(strategyName='康力泉') elif strategy == 'b': self.pm = pathManager(strategyName='父母') elif strategy == 'd': self.pm = pathManager(strategyName='全家')
def __init__(self): # 需要比对年线的品种 self.indexValueInfos = [ \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"上证50",u"indexCode":u"000016",u"requestCode":u"0000161",u"categoryId":u"111"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"50AH",u"indexCode":u"000170",u"requestCode":u"0001701",u"categoryId":u"112"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"沪深300",u"indexCode":u"000300",u"requestCode":u"0003001",u"categoryId":u"113"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"300价值",u"indexCode":u"000919",u"requestCode":u"0009191",u"categoryId":u"114"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"基本面60",u"indexCode":u"399701",u"requestCode":u"3997012",u"categoryId":u"115"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"基本面120",u"indexCode":u"399702",u"requestCode":u"3997022",u"categoryId":u"116"}, \ {u"category1":u"A 股",u"category2":u"大盘股",u"category3":u"中小板",u"indexCode":u"399005",u"requestCode":u"3990052",u"categoryId":u"117"}, \ {u"category1":u"A 股",u"category2":u"中小盘股",u"category3":u"中证500",u"indexCode":u"000905",u"requestCode":u"0009051",u"categoryId":u"121"}, \ {u"category1":u"A 股",u"category2":u"中小盘股",u"category3":u"中证1000",u"indexCode":u"000852",u"requestCode":u"0008521",u"categoryId":u"123"}, \ {u"category1":u"A 股",u"category2":u"中小盘股",u"category3":u"创业板",u"indexCode":u"399006",u"requestCode":u"3990062",u"categoryId":u"124"}, \ {u"category1":u"A 股",u"category2":u"红利价值",u"category3":u"中证红利",u"indexCode":u"000922",u"requestCode":u"0009221",u"categoryId":u"131"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"养老产业",u"indexCode":u"399812",u"requestCode":u"3998122",u"categoryId":u"141"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"全指医药",u"indexCode":u"000991",u"requestCode":u"0009911",u"categoryId":u"142"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"中证环保",u"indexCode":u"000827",u"requestCode":u"0008271",u"categoryId":u"143"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"中证传媒",u"indexCode":u"399971",u"requestCode":u"3999712",u"categoryId":u"144"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"证券公司",u"indexCode":u"399975",u"requestCode":u"3999752",u"categoryId":u"145"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"金融地产",u"indexCode":u"000992",u"requestCode":u"0009921",u"categoryId":u"146"}, \ {u"category1":u"A 股",u"category2":u"行业股",u"category3":u"全指消费",u"indexCode":u"000990",u"requestCode":u"0009901",u"categoryId":u"147"}, \ {u"category1":u"海外新兴",u"category2":u"香港",u"category3":u"恒生",u"indexCode":u"HSI5",u"requestCode":u"HSI5",u"categoryId":u"211"}, \ {u"category1":u"海外新兴",u"category2":u"台湾",u"category3":u"台湾加权",u"indexCode":u"TWII_UI",u"requestCode":u"TWII_UI",u"categoryId":u"213"}, \ {u"category1":u"海外新兴",u"category2":u"日本",u"category3":u"日经225",u"indexCode":u"N225_UI",u"requestCode":u"N225_UI",u"categoryId":u"214"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"德国30",u"indexCode":u"GDAXI_UI",u"requestCode":u"GDAXI_UI",u"categoryId":u"311"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"富时100",u"indexCode":u"FTSE_UI",u"requestCode":u"FTSE_UI",u"categoryId":u"312"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"法国40",u"indexCode":u"FCHI_UI",u"requestCode":u"FCHI_UI",u"categoryId":u"313"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"道琼斯",u"indexCode":u"DJIA_UI",u"requestCode":u"DJIA_UI",u"categoryId":u"314"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"纳斯达克",u"indexCode":u"NDX_UI",u"requestCode":u"NDX_UI",u"categoryId":u"315"}, \ {u"category1":u"海外成熟",u"category2":u"海外成熟",u"category3":u"标普500",u"indexCode":u"SPX_UI",u"requestCode":u"SPX_UI",u"categoryId":u"316"}, \ {u"category1":u"债券",u"category2":u"国内债券",u"category3":u"可转债",u"indexCode":u"000832",u"requestCode":u"0008321",u"categoryId":u"411"}, \ {u"category1":u"商品",u"category2":u"商品",u"category3":u"黄金",u"indexCode":u"GC00Y",u"requestCode":u"GC00Y0",u"categoryId":u"511"}, \ {u"category1":u"商品",u"category2":u"商品",u"category3":u"原油",u"indexCode":u"CL00Y",u"requestCode":u"CL00Y0",u"categoryId":u"512"}, \ {u"category1":u"商品",u"category2":u"商品",u"category3":u"白银",u"indexCode":u"SI00Y",u"requestCode":u"SI00Y0",u"categoryId":u"513"} \ ] self.colorConstants = colorConstants() self.pm = pathManager() self.outputDir = os.path.join(self.pm.outputPath, u'indexYearDataCompare') if not os.path.exists(self.outputDir): os.makedirs(self.outputDir)
def __init__(self, strategyName, skipUpdateIfExist=False): self.strategyName = strategyName self.pm = pathManager(self.strategyName) self.colorConstants = colorConstants() self.echarts = [] # 市值情况 with open(os.path.join(self.pm.configPath, 'indexHoldingInfo.json'), u'r', encoding=u'utf-8') as f: self.holdingInfos = json.loads(f.read()) # print(self.holdingInfos) # 输出时切换到中文列名 self.outputRenameColumns = { 'name': '名称', 'code': '代码', 'market_cap': '市值(亿元)', 'pe_ratio': 'pe', 'pb_ratio': 'pb', 'daily_change': '涨跌幅', 'holding': '持有市值(元)', 'daily_gain': '日盈亏', 'hy_code1': '一级行业代码', 'hy_name1': '一级行业名称', 'hy_code2': '二级行业代码', 'hy_name2': '二级行业名称', 'relate_index': '相关指数' } # 转置列名的 key-value,作为读入内存后的列名 self.inputRenameColumns = dict([ (value, key) for key, value in self.outputRenameColumns.items() ]) # print(self.inputRenameColumns) # 个股持仓明细表 cachFile = os.path.join(self.pm.holdingOutputPath, 'indexHoldingInfo.csv') if (not os.path.exists(cachFile)) or (not skipUpdateIfExist): shouldUpdate = True else: shouldUpdate = False if not shouldUpdate: # print('indexHoldingInfo.csv 存在... 是否需要在线更新?[Y/N]') # choice = str(input()).upper() # # 这里只要不是 Y 都不更新了,防止过多查询聚宽 # if choice != 'Y': # shouldUpdate = False self.result_df = pd.read_csv(cachFile, sep='\t') self.result_df = self.result_df.rename( columns=self.inputRenameColumns) #print('日盈亏:{0} 元'.format(round(self.result_df.daily_gain.sum(), 2))) else: # 登录 auth('13810650842', '123456a') print(u'聚宽数据API:{0}'.format(get_query_count())) self.result_df = self.generateDataFrameCSVFile() # 申万指数 json with open(os.path.join(self.pm.configPath, u'indexIndustryInfo.json'), 'r', encoding='utf-8') as f: self.swIndexInfos = json.loads(f.read()) self.result_df = self.result_df.rename(columns=self.inputRenameColumns) self.generateEchartsModels(self.result_df) self.generateJSObjectFile( '全家') # 这里暂时没有使用 strategyName 作为输出标识符,后面应该想想更好的办法 # 打开 if sys.platform.startswith('win'): os.startfile( os.path.join(self.pm.echartsPath, u'FamilyStockIndustry.html'))