hqchartPy2 data docking tutorial 2-equity data, chip distribution function

Total equity acquisition interface function

# TOTALCAPITAL  当前总股本(手)
def GetTotalCapital(self,symbol, period, right, kcount,jobID):

Interface function for obtaining tradable equity

# CAPITAL 最新流通股本(手)
def GetCapital(self,symbol, period, right, kcount,jobID):

Interface function for obtaining historical circulating equity

Historical circulating equity is the data needed to calculate the distribution of chips. If you want to support the chip distribution function, you must
connect this data. The chip distribution functions include WINNER, WINNERB, COST, COSTEX, LWINNER, LWINNERB, PWINNER, PWINNERB, PPART

# 历史所有的流通股本 时间序列
def GetHisCapital(self,symbol, period, right, kcount,jobID):

Parameter Description

symol

Stock code

period

Cycle
0=daily line 1=weekly line 2=monthly line 3=annual line 4=1 minute 5=5 minutes 6=15 minutes 7=30 minutes 8=60 minutes 9=seasonal line 10=minutes

right

Restoration
0=No restoration 1=Previous restoration 2=Post restoration

kcount

Number of k lines

jobID

Task id

Return data format

Return a dictionary type data

Singular value type

Such as: TOTALCAPITAL, CAPITAL both return the latest data
format
{'type':0, data:data}

Time series data

GetHisCapital returns the historical circulating equity, a time series data, sorted in descending order.
Format
{'type': 2, data: data array, date: date array (numerical type)}

Tushare data docking example

The data uses the daily_basic data interface of tushare, see https://waditu.com/document/2?doc_id=32 for the interface document

class TushareHQChartData(IHQData) :
.....................
   # 历史所有的流通股 
   def GetHisCapital(self,symbol, period, right, kcount, jobID):
        df=self.TusharePro.daily_basic(ts_code=symbol,start_date=str(self.StartDate), end_date=str(self.EndDate), fields='trade_date,float_share')
        df=df.sort_index(ascending=False) # 数据要降序排
        print(df)

        aryDate=df["trade_date"]
        aryDate[aryDate == ''] = 0
        aryDate = aryDate.astype(np.int).tolist()

        aryShare=np.multiply(df["float_share"],10000).tolist()

        result={
    
    "type": 2}  # 类型2 根据'date'自动合并到K线数据上
        result["data"]=aryShare
        result["date"]=aryDate
        return result

    # TOTALCAPITAL  当前总股本
    def GetTotalCapital(self,symbol, period, right, kcount, jobID) :
        df=self.TusharePro.daily_basic(ts_code=symbol, trade_date=str(self.EndDate), fields='trade_date,total_share')
        print(df)

        result={
    
    "type": 0}  # 类型0 单值数据
        result["data"]=df["total_share"]*10000/100
        return result

    # CAPITAL 最新流通股本(手)
    def GetCapital(self,symbol, period, right, kcount,jobID):
        df=self.TusharePro.daily_basic(ts_code=symbol, trade_date=str(self.EndDate), fields='trade_date,float_share')
        print(df)

        result={
    
    "type": 0}  # 类型0 单值数据
        result["data"]=df["float_share"]*10000/100
        return result

Exchange QQ group

If you have any questions or needs, you can join the exchange QQ group: 950092318** Contact the owner (QQ48274798)

hqchartPy dynamic library address

https://github.com/jones2000/HQChart/tree/master/C++ indicator calculation engine/py version

HQChart code address

Address: https://github.com/jones2000/HQChart

Guess you like

Origin blog.csdn.net/jones2000/article/details/112060761