Python沪深300成分股价值分析

 

# 导入DataApi
from jaqs.data import DataApi
import math
import datetime
# 初始化api
api = DataApi('tcp://data.quantos.org:8910')
# 获取用户名和密码
import os
user  = os.environ.get("QUANTOS_USER")
token = os.environ.get("QUANTOS_TOKEN")
# 登录
info, msg = api.login(user, token)
print(info, msg)
# 获得HS300指数20180322的成份股
def get_pe_ttm(date):
    pe=[]
    df, msg = api.query(
        view = 'lb.indexCons', 
        filter="index_code=000300.SH&start_date="+date+"&end_date="+date
    )
    stock_list=df["symbol"]
    symbols = ",".join(df['symbol'])
    #print(stock_list)
    # 获得HS300成份股的日估值数据
    df_data, msg = api.query(
        view = 'lb.secDailyIndicator', 
        filter="start_date="+date+"&end_date="+date+"&symbol="

你可能感兴趣的:(Python沪深300成分股价值分析)