def mkTradeStat(): data = w.wset("mkttradestatsec", "startdate=" + tradedate(365)[0], "enddate=" + tradedate(0)[1], "sectorid=a001010100000000") df = pd.DataFrame(data.Data, index=data.Fields, columns=data.Codes).T df = df.sort_values(by='date', ascending=False) print(df.head()) return df
def marketScaleStat(): data = w.wset("marketscalestatisticbywind", "reporttype=y1;startdate=" + tradedate(90)[0], "enddate=" + tradedate(0)[1]) df = pd.DataFrame(data.Data, index=data.Fields, columns=data.Codes).T print(df.head()) return df
def blockTradeRecord(): data = w.wset("blocktraderecord", "startdate=" + tradedate(20)[0], "enddate=" + tradedate(20)[1], "sectorid=a001010100000000") df = pd.DataFrame(data=data.Data, index=data.Fields, columns=data.Codes).T df = df.sort_values(by='trade_date', ascending=False) #print(df.head(30)) return df
def iForecast(code, startdate=tradedate(180)[0], year=datetime.strptime(tradedate(0)[1], "%Y-%m-%d").year): data = w.wset("institutionforecasts", "year=" + str(year), "startdate=" + startdate, "windcode=" + code, "orgname=all") #print(data) df = pd.DataFrame(data.Data, index=data.Fields, columns=data.Codes).T #print(df.head()) df = df.sort_values(by='last_rating_date', ascending=False) return df
def stockWest(code, startdate=tradedate(180)[0], year=datetime.strptime(tradedate(0)[1], "%Y-%m-%d").year): data = w.wset( "stockwest", "startdate=" + startdate, "windcode=" + code, "orgname=全部", "field=date,organization,researcher,epsa0,epse1,epse2,epse3,netprofita0,netprofite1,netprofite2,netprofite3,incomea0,incomee1,incomee2,incomee3" ) #print(data) df = pd.DataFrame(data.Data, index=data.Fields, columns=data.Codes).T df = df.sort_values(by='date', ascending=False) return df
def valucationWind(stocklists): rm._write_msg('[Getting Data:]') df_V = pd.DataFrame() for code in stocklists: rm._write_inprogress() # sec_status,trade_code, data = w.wsd(code, "windcode,sec_name, close, ev,pe_ttm,val_pe_deducted_ttm,pe_lyr,pb_lf,pcf_ocflyr,west_eps_FY1,west_eps_FY2,estpe_FY1,estpe_FY2, estpeg_FTM,estpeg_FY1, industry_sw,concept", tradedate(0)[0], tradedate(0)[1], "index=4;industryType=3") df = pd.DataFrame(data.Data, columns=data.Codes, index=data.Fields).T #df['ev'] = df['ev']/1.0E+8 df_V = pd.concat([df_V, df]) df_V = df_V.sort_values(by='INDUSTRY_SW') #df_V.to_excel("D:/Stock/tushare/stocklists.xlsx", sheet_name = tradedate(0)[-1]) #rm._play_wav() print(len(df_V)) return df_V
def dfToExcel(df, filename, sheet_name=tradedate(0)[-1]): df.to_excel("D:/Stock/wind/" + str(filename) + ".xlsx", sheet_name) print(" df save to {} .".format(filename))
def companyScopeView(): data = w.wset("companyscopegeneralview", "enddate=" + tradedate(0)[1], "year=2016", "sectorid=a001010100000000") df = pd.DataFrame(data=data.Data, index=data.Fields, columns=data.Codes).T print(df.head()) return df
def dfToExcel(df, filename): df.to_excel("D:/Stock/wind/" + str(filename) + ".xlsx", sheet_name=tradedate(0)[-1]) print(" df to_excel filename .") pass
def indScaleStat(): data = w.wset("indscalestatbywind", "industrytype=证监会行业;enddate=" + tradedate(0)[1]) df = pd.DataFrame(data.Data, index=data.Fields, columns=data.Codes).T print(df.head()) return df
# test scripts in project import pandas as pd from WindPy import w w.start() from windpyplus.utils.tradedate import tradedate from windpyplus.fundamental.performanceExpress import performance_express from windpyplus.fundamental.financialReport import financial_report from windpyplus.stockSector.StockSector import allAstock allstocks = list(allAstock().index.values) print(allstocks) print(tradedate()) #print(performance_express(allstocks)) #print(financial_report(allstocks))
def Concept(stocklists): data = w.wss(stocklists, "sec_name,concept", "tradeDate=" + tradedate(0)[1]) df = pd.DataFrame(data.Data, columns=data.Codes, index=data.Fields).T return df
def Industry(stocklists): data = w.wss(stocklists, "sec_name,industry_gics,industry_citic,industry_sw", "industryType=1;tradeDate=" + tradedate(0)[1]) df = pd.DataFrame(data.Data, columns=data.Codes, index=data.Fields).T return df