nwo
stringlengths 10
28
| sha
stringlengths 40
40
| path
stringlengths 11
97
| identifier
stringlengths 1
64
| parameters
stringlengths 2
2.24k
| return_statement
stringlengths 0
2.17k
| docstring
stringlengths 0
5.45k
| docstring_summary
stringlengths 0
3.83k
| func_begin
int64 1
13.4k
| func_end
int64 2
13.4k
| function
stringlengths 28
56.4k
| url
stringlengths 106
209
| project
int64 1
48
| executed_lines
list | executed_lines_pc
float64 0
153
| missing_lines
list | missing_lines_pc
float64 0
100
| covered
bool 2
classes | filecoverage
float64 2.53
100
| function_lines
int64 2
1.46k
| mccabe
int64 1
253
| coverage
float64 0
100
| docstring_lines
int64 0
112
| function_nodoc
stringlengths 9
56.4k
| id
int64 0
29.8k
|
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_yjyg_em.py
|
stock_yjkb_em
|
(date: str = "20211231")
|
return big_df
|
东方财富-数据中心-年报季报-业绩快报
https://data.eastmoney.com/bbsj/202003/yjkb.html
:param date: "20200331", "20200630", "20200930", "20201231"; 从 20100331 开始
:type date: str
:return: 业绩快报
:rtype: pandas.DataFrame
|
东方财富-数据中心-年报季报-业绩快报
https://data.eastmoney.com/bbsj/202003/yjkb.html
:param date: "20200331", "20200630", "20200930", "20201231"; 从 20100331 开始
:type date: str
:return: 业绩快报
:rtype: pandas.DataFrame
| 16 | 116 |
def stock_yjkb_em(date: str = "20211231") -> pd.DataFrame:
"""
东方财富-数据中心-年报季报-业绩快报
https://data.eastmoney.com/bbsj/202003/yjkb.html
:param date: "20200331", "20200630", "20200930", "20201231"; 从 20100331 开始
:type date: str
:return: 业绩快报
:rtype: pandas.DataFrame
"""
url = "https://datacenter.eastmoney.com/securities/api/data/v1/get"
params = {
"sortColumns": "UPDATE_DATE,SECURITY_CODE",
"sortTypes": "-1,-1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_FCI_PERFORMANCEE",
"columns": "ALL",
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
}
r = requests.get(url, params=params)
data_json = r.json()
big_df = pd.DataFrame()
total_page = data_json["result"]["pages"]
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"市场板块",
"_",
"证券类型",
"_",
"公告日期",
"_",
"每股收益",
"营业收入-营业收入",
"营业收入-去年同期",
"净利润-净利润",
"净利润-去年同期",
"每股净资产",
"净资产收益率",
"营业收入-同比增长",
"净利润-同比增长",
"营业收入-季度环比增长",
"净利润-季度环比增长",
"所处行业",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"每股收益",
"营业收入-营业收入",
"营业收入-去年同期",
"营业收入-同比增长",
"营业收入-季度环比增长",
"净利润-净利润",
"净利润-去年同期",
"净利润-同比增长",
"净利润-季度环比增长",
"每股净资产",
"净资产收益率",
"所处行业",
"公告日期",
]
]
big_df["每股收益"] = pd.to_numeric(big_df["每股收益"], errors="coerce")
big_df["营业收入-营业收入"] = pd.to_numeric(big_df["营业收入-营业收入"], errors="coerce")
big_df["营业收入-去年同期"] = pd.to_numeric(big_df["营业收入-去年同期"], errors="coerce")
big_df["营业收入-同比增长"] = pd.to_numeric(big_df["营业收入-同比增长"], errors="coerce")
big_df["营业收入-季度环比增长"] = pd.to_numeric(big_df["营业收入-季度环比增长"], errors="coerce")
big_df["净利润-净利润"] = pd.to_numeric(big_df["净利润-净利润"], errors="coerce")
big_df["净利润-去年同期"] = pd.to_numeric(big_df["净利润-去年同期"], errors="coerce")
big_df["净利润-同比增长"] = pd.to_numeric(big_df["净利润-同比增长"], errors="coerce")
big_df["净利润-季度环比增长"] = pd.to_numeric(big_df["净利润-季度环比增长"], errors="coerce")
big_df["每股净资产"] = pd.to_numeric(big_df["每股净资产"], errors="coerce")
big_df["净资产收益率"] = pd.to_numeric(big_df["净资产收益率"], errors="coerce")
big_df["净资产收益率"] = pd.to_numeric(big_df["净资产收益率"], errors="coerce")
big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_yjyg_em.py#L16-L116
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 8.910891 |
[
9,
10,
19,
20,
21,
22,
23,
24,
29,
30,
31,
32,
34,
35,
36,
67,
87,
88,
89,
90,
91,
92,
93,
94,
95,
96,
97,
98,
99,
100
] | 29.70297 | false | 8.080808 | 101 | 2 | 70.29703 | 6 |
def stock_yjkb_em(date: str = "20211231") -> pd.DataFrame:
url = "https://datacenter.eastmoney.com/securities/api/data/v1/get"
params = {
"sortColumns": "UPDATE_DATE,SECURITY_CODE",
"sortTypes": "-1,-1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_FCI_PERFORMANCEE",
"columns": "ALL",
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
}
r = requests.get(url, params=params)
data_json = r.json()
big_df = pd.DataFrame()
total_page = data_json["result"]["pages"]
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"市场板块",
"_",
"证券类型",
"_",
"公告日期",
"_",
"每股收益",
"营业收入-营业收入",
"营业收入-去年同期",
"净利润-净利润",
"净利润-去年同期",
"每股净资产",
"净资产收益率",
"营业收入-同比增长",
"净利润-同比增长",
"营业收入-季度环比增长",
"净利润-季度环比增长",
"所处行业",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"每股收益",
"营业收入-营业收入",
"营业收入-去年同期",
"营业收入-同比增长",
"营业收入-季度环比增长",
"净利润-净利润",
"净利润-去年同期",
"净利润-同比增长",
"净利润-季度环比增长",
"每股净资产",
"净资产收益率",
"所处行业",
"公告日期",
]
]
big_df["每股收益"] = pd.to_numeric(big_df["每股收益"], errors="coerce")
big_df["营业收入-营业收入"] = pd.to_numeric(big_df["营业收入-营业收入"], errors="coerce")
big_df["营业收入-去年同期"] = pd.to_numeric(big_df["营业收入-去年同期"], errors="coerce")
big_df["营业收入-同比增长"] = pd.to_numeric(big_df["营业收入-同比增长"], errors="coerce")
big_df["营业收入-季度环比增长"] = pd.to_numeric(big_df["营业收入-季度环比增长"], errors="coerce")
big_df["净利润-净利润"] = pd.to_numeric(big_df["净利润-净利润"], errors="coerce")
big_df["净利润-去年同期"] = pd.to_numeric(big_df["净利润-去年同期"], errors="coerce")
big_df["净利润-同比增长"] = pd.to_numeric(big_df["净利润-同比增长"], errors="coerce")
big_df["净利润-季度环比增长"] = pd.to_numeric(big_df["净利润-季度环比增长"], errors="coerce")
big_df["每股净资产"] = pd.to_numeric(big_df["每股净资产"], errors="coerce")
big_df["净资产收益率"] = pd.to_numeric(big_df["净资产收益率"], errors="coerce")
big_df["净资产收益率"] = pd.to_numeric(big_df["净资产收益率"], errors="coerce")
big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
return big_df
| 17,934 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_yjyg_em.py
|
stock_yjyg_em
|
(date: str = "20200331")
|
return big_df
|
东方财富-数据中心-年报季报-业绩预告
https://data.eastmoney.com/bbsj/202003/yjyg.html
:param date: "2020-03-31", "2020-06-30", "2020-09-30", "2020-12-31"; 从 2008-12-31 开始
:type date: str
:return: 业绩预告
:rtype: pandas.DataFrame
|
东方财富-数据中心-年报季报-业绩预告
https://data.eastmoney.com/bbsj/202003/yjyg.html
:param date: "2020-03-31", "2020-06-30", "2020-09-30", "2020-12-31"; 从 2008-12-31 开始
:type date: str
:return: 业绩预告
:rtype: pandas.DataFrame
| 119 | 204 |
def stock_yjyg_em(date: str = "20200331") -> pd.DataFrame:
"""
东方财富-数据中心-年报季报-业绩预告
https://data.eastmoney.com/bbsj/202003/yjyg.html
:param date: "2020-03-31", "2020-06-30", "2020-09-30", "2020-12-31"; 从 2008-12-31 开始
:type date: str
:return: 业绩预告
:rtype: pandas.DataFrame
"""
url = "https://datacenter.eastmoney.com/securities/api/data/v1/get"
params = {
"sortColumns": "NOTICE_DATE,SECURITY_CODE",
"sortTypes": "-1,-1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_PUBLIC_OP_NEWPREDICT",
"columns": "ALL",
"filter": f" (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')",
}
r = requests.get(url, params=params)
data_json = r.json()
big_df = pd.DataFrame()
total_page = data_json["result"]["pages"]
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"_",
"股票代码",
"股票简称",
"_",
"公告日期",
"报告日期",
"_",
"预测指标",
"_",
"_",
"_",
"_",
"业绩变动",
"业绩变动原因",
"预告类型",
"上年同期值",
"_",
"_",
"_",
"_",
"业绩变动幅度",
"预测数值",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"预测指标",
"业绩变动",
"预测数值",
"业绩变动幅度",
"业绩变动原因",
"预告类型",
"上年同期值",
"公告日期",
]
]
big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
big_df["业绩变动幅度"] = pd.to_numeric(big_df["业绩变动幅度"], errors="coerce")
big_df["预测数值"] = pd.to_numeric(big_df["预测数值"], errors="coerce")
big_df["上年同期值"] = pd.to_numeric(big_df["上年同期值"], errors="coerce")
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_yjyg_em.py#L119-L204
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 10.465116 |
[
9,
10,
19,
20,
21,
22,
23,
24,
29,
30,
31,
32,
34,
35,
36,
66,
81,
82,
83,
84,
85
] | 24.418605 | false | 8.080808 | 86 | 2 | 75.581395 | 6 |
def stock_yjyg_em(date: str = "20200331") -> pd.DataFrame:
url = "https://datacenter.eastmoney.com/securities/api/data/v1/get"
params = {
"sortColumns": "NOTICE_DATE,SECURITY_CODE",
"sortTypes": "-1,-1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_PUBLIC_OP_NEWPREDICT",
"columns": "ALL",
"filter": f" (REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')",
}
r = requests.get(url, params=params)
data_json = r.json()
big_df = pd.DataFrame()
total_page = data_json["result"]["pages"]
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"_",
"股票代码",
"股票简称",
"_",
"公告日期",
"报告日期",
"_",
"预测指标",
"_",
"_",
"_",
"_",
"业绩变动",
"业绩变动原因",
"预告类型",
"上年同期值",
"_",
"_",
"_",
"_",
"业绩变动幅度",
"预测数值",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"预测指标",
"业绩变动",
"预测数值",
"业绩变动幅度",
"业绩变动原因",
"预告类型",
"上年同期值",
"公告日期",
]
]
big_df["公告日期"] = pd.to_datetime(big_df["公告日期"]).dt.date
big_df["业绩变动幅度"] = pd.to_numeric(big_df["业绩变动幅度"], errors="coerce")
big_df["预测数值"] = pd.to_numeric(big_df["预测数值"], errors="coerce")
big_df["上年同期值"] = pd.to_numeric(big_df["上年同期值"], errors="coerce")
return big_df
| 17,935 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_yjyg_em.py
|
stock_yysj_em
|
(symbol: str = "沪深A股", date: str = "20200331") -> pd
|
return big_df
|
东方财富-数据中心-年报季报-预约披露时间
https://data.eastmoney.com/bbsj/202003/yysj.html
:param symbol: choice of {'沪深A股', '沪市A股', '科创板', '深市A股', '创业板', '京市A股', 'ST板'}
:type symbol: str
:param date: "20190331", "20190630", "20190930", "20191231"; 从 20081231 开始
:type date: str
:return: 指定时间的上市公司预约披露时间数据
:rtype: pandas.DataFrame
|
东方财富-数据中心-年报季报-预约披露时间
https://data.eastmoney.com/bbsj/202003/yysj.html
:param symbol: choice of {'沪深A股', '沪市A股', '科创板', '深市A股', '创业板', '京市A股', 'ST板'}
:type symbol: str
:param date: "20190331", "20190630", "20190930", "20191231"; 从 20081231 开始
:type date: str
:return: 指定时间的上市公司预约披露时间数据
:rtype: pandas.DataFrame
| 207 | 322 |
def stock_yysj_em(symbol: str = "沪深A股", date: str = "20200331") -> pd.DataFrame:
"""
东方财富-数据中心-年报季报-预约披露时间
https://data.eastmoney.com/bbsj/202003/yysj.html
:param symbol: choice of {'沪深A股', '沪市A股', '科创板', '深市A股', '创业板', '京市A股', 'ST板'}
:type symbol: str
:param date: "20190331", "20190630", "20190930", "20191231"; 从 20081231 开始
:type date: str
:return: 指定时间的上市公司预约披露时间数据
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"sortColumns": "FIRST_APPOINT_DATE,SECURITY_CODE",
"sortTypes": "1,1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_PUBLIC_BS_APPOIN",
"columns": "ALL",
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
}
if symbol == "沪市A股":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE in ("069001001001","069001001003","069001001006"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "科创板":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE="069001001006")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "深市A股":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE="058001001")(TRADE_MARKET_CODE in ("069001002001","069001002002","069001002003","069001002005"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "创业板":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE="058001001")(TRADE_MARKET_CODE="069001002002")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "京市A股":
params.update(
{
"filter": f"""(TRADE_MARKET_CODE="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "ST板":
params.update(
{
"filter": f"""(TRADE_MARKET_CODE in("069001001003","069001002005"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["result"]["pages"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"_",
"_",
"首次预约时间",
"一次变更日期",
"二次变更日期",
"三次变更日期",
"实际披露时间",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"首次预约时间",
"一次变更日期",
"二次变更日期",
"三次变更日期",
"实际披露时间",
]
]
big_df["首次预约时间"] = pd.to_datetime(big_df["首次预约时间"]).dt.date
big_df["一次变更日期"] = pd.to_datetime(big_df["一次变更日期"]).dt.date
big_df["二次变更日期"] = pd.to_datetime(big_df["二次变更日期"]).dt.date
big_df["三次变更日期"] = pd.to_datetime(big_df["三次变更日期"]).dt.date
big_df["实际披露时间"] = pd.to_datetime(big_df["实际披露时间"]).dt.date
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_yjyg_em.py#L207-L322
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 9.482759 |
[
11,
12,
21,
22,
27,
28,
33,
34,
39,
40,
45,
46,
51,
52,
57,
58,
59,
60,
61,
62,
67,
68,
69,
70,
72,
73,
74,
98,
110,
111,
112,
113,
114,
115
] | 29.310345 | false | 8.080808 | 116 | 8 | 70.689655 | 8 |
def stock_yysj_em(symbol: str = "沪深A股", date: str = "20200331") -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"sortColumns": "FIRST_APPOINT_DATE,SECURITY_CODE",
"sortTypes": "1,1",
"pageSize": "500",
"pageNumber": "1",
"reportName": "RPT_PUBLIC_BS_APPOIN",
"columns": "ALL",
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE!="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')""",
}
if symbol == "沪市A股":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE in ("069001001001","069001001003","069001001006"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "科创板":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE in ("058001001","058001008"))(TRADE_MARKET_CODE="069001001006")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "深市A股":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE="058001001")(TRADE_MARKET_CODE in ("069001002001","069001002002","069001002003","069001002005"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "创业板":
params.update(
{
"filter": f"""(SECURITY_TYPE_CODE="058001001")(TRADE_MARKET_CODE="069001002002")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "京市A股":
params.update(
{
"filter": f"""(TRADE_MARKET_CODE="069001017")(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
elif symbol == "ST板":
params.update(
{
"filter": f"""(TRADE_MARKET_CODE in("069001001003","069001002005"))(REPORT_DATE='{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
)
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["result"]["pages"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"_",
"_",
"首次预约时间",
"一次变更日期",
"二次变更日期",
"三次变更日期",
"实际披露时间",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
]
big_df = big_df[
[
"序号",
"股票代码",
"股票简称",
"首次预约时间",
"一次变更日期",
"二次变更日期",
"三次变更日期",
"实际披露时间",
]
]
big_df["首次预约时间"] = pd.to_datetime(big_df["首次预约时间"]).dt.date
big_df["一次变更日期"] = pd.to_datetime(big_df["一次变更日期"]).dt.date
big_df["二次变更日期"] = pd.to_datetime(big_df["二次变更日期"]).dt.date
big_df["三次变更日期"] = pd.to_datetime(big_df["三次变更日期"]).dt.date
big_df["实际披露时间"] = pd.to_datetime(big_df["实际披露时间"]).dt.date
return big_df
| 17,936 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_jgdy_em.py
|
stock_jgdy_tj_em
|
(date: str = "20220101")
|
return big_df
|
东方财富网-数据中心-特色数据-机构调研-机构调研统计
http://data.eastmoney.com/jgdy/tj.html
:param date: 开始时间
:type date: str
:return: 机构调研统计
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-机构调研-机构调研统计
http://data.eastmoney.com/jgdy/tj.html
:param date: 开始时间
:type date: str
:return: 机构调研统计
:rtype: pandas.DataFrame
| 15 | 104 |
def stock_jgdy_tj_em(date: str = "20220101") -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-机构调研-机构调研统计
http://data.eastmoney.com/jgdy/tj.html
:param date: 开始时间
:type date: str
:return: 机构调研统计
:rtype: pandas.DataFrame
"""
url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
'sortColumns': 'NOTICE_DATE,SUM,RECEIVE_START_DATE,SECURITY_CODE',
'sortTypes': '-1,-1,-1,1',
'pageSize': '500',
'pageNumber': '1',
'reportName': 'RPT_ORG_SURVEYNEW',
'columns': 'ALL',
'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE',
'source': 'WEB',
'client': 'WEB',
'filter': f"""(NUMBERNEW="1")(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json['result']['pages']
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
params.update({"pageNumber": page})
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json['result']['data'])
big_df = pd.concat([big_df, temp_df])
big_df.reset_index(inplace=True)
big_df["index"] = list(range(1, len(big_df) + 1))
big_df.columns = [
"序号",
"_",
"代码",
"名称",
"_",
"公告日期",
"接待日期",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"接待地点",
"_",
"接待方式",
"_",
"接待人员",
"_",
"_",
"_",
"_",
"_",
"接待机构数量",
"_",
"_",
"_",
"_",
"_",
"_",
"最新价",
"涨跌幅",
]
big_df = big_df[
[
"序号",
"代码",
"名称",
"最新价",
"涨跌幅",
"接待机构数量",
"接待方式",
"接待人员",
"接待地点",
"接待日期",
"公告日期",
]
]
big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce")
big_df['接待机构数量'] = pd.to_numeric(big_df['接待机构数量'], errors="coerce")
big_df['接待日期'] = pd.to_datetime(big_df['接待日期']).dt.date
big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_jgdy_em.py#L15-L104
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 10 |
[
9,
10,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
69,
84,
85,
86,
87,
88,
89
] | 24.444444 | false | 12.962963 | 90 | 2 | 75.555556 | 6 |
def stock_jgdy_tj_em(date: str = "20220101") -> pd.DataFrame:
url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
'sortColumns': 'NOTICE_DATE,SUM,RECEIVE_START_DATE,SECURITY_CODE',
'sortTypes': '-1,-1,-1,1',
'pageSize': '500',
'pageNumber': '1',
'reportName': 'RPT_ORG_SURVEYNEW',
'columns': 'ALL',
'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE',
'source': 'WEB',
'client': 'WEB',
'filter': f"""(NUMBERNEW="1")(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json['result']['pages']
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
params.update({"pageNumber": page})
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json['result']['data'])
big_df = pd.concat([big_df, temp_df])
big_df.reset_index(inplace=True)
big_df["index"] = list(range(1, len(big_df) + 1))
big_df.columns = [
"序号",
"_",
"代码",
"名称",
"_",
"公告日期",
"接待日期",
"_",
"_",
"_",
"_",
"_",
"_",
"_",
"接待地点",
"_",
"接待方式",
"_",
"接待人员",
"_",
"_",
"_",
"_",
"_",
"接待机构数量",
"_",
"_",
"_",
"_",
"_",
"_",
"最新价",
"涨跌幅",
]
big_df = big_df[
[
"序号",
"代码",
"名称",
"最新价",
"涨跌幅",
"接待机构数量",
"接待方式",
"接待人员",
"接待地点",
"接待日期",
"公告日期",
]
]
big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce")
big_df['接待机构数量'] = pd.to_numeric(big_df['接待机构数量'], errors="coerce")
big_df['接待日期'] = pd.to_datetime(big_df['接待日期']).dt.date
big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date
return big_df
| 17,937 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_jgdy_em.py
|
stock_jgdy_detail_em
|
(date: str = "20220101")
|
return big_df
|
东方财富网-数据中心-特色数据-机构调研-机构调研详细
http://data.eastmoney.com/jgdy/xx.html
:param date: 开始时间
:type date: str
:return: 机构调研详细
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-机构调研-机构调研详细
http://data.eastmoney.com/jgdy/xx.html
:param date: 开始时间
:type date: str
:return: 机构调研详细
:rtype: pandas.DataFrame
| 107 | 178 |
def stock_jgdy_detail_em(date: str = "20220101") -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-机构调研-机构调研详细
http://data.eastmoney.com/jgdy/xx.html
:param date: 开始时间
:type date: str
:return: 机构调研详细
:rtype: pandas.DataFrame
"""
url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
'sortColumns': 'NOTICE_DATE,RECEIVE_START_DATE,SECURITY_CODE,NUMBERNEW',
'sortTypes': '-1,-1,1,-1',
'pageSize': '50000',
'pageNumber': '1',
'reportName': 'RPT_ORG_SURVEY',
'columns': 'SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,NOTICE_DATE,RECEIVE_START_DATE,RECEIVE_OBJECT,RECEIVE_PLACE,RECEIVE_WAY_EXPLAIN,INVESTIGATORS,RECEPTIONIST,ORG_TYPE',
'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE',
'source': 'WEB',
'client': 'WEB',
'filter': f"""(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json['result']['pages']
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
params.update({"pageNumber": page})
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json['result']['data'])
big_df = pd.concat([big_df, temp_df])
big_df.reset_index(inplace=True)
big_df["index"] = list(range(1, len(big_df) + 1))
big_df.columns = [
"序号",
"_",
"代码",
"名称",
"公告日期",
"调研日期",
"调研机构",
"接待地点",
"接待方式",
"调研人员",
"接待人员",
"机构类型",
"最新价",
"涨跌幅",
]
big_df = big_df[
[
"序号",
"代码",
"名称",
"最新价",
"涨跌幅",
"调研机构",
"机构类型",
"调研人员",
"接待方式",
"接待人员",
"接待地点",
"调研日期",
"公告日期",
]
]
big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce")
big_df['调研日期'] = pd.to_datetime(big_df['调研日期']).dt.date
big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_jgdy_em.py#L107-L178
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 12.5 |
[
9,
10,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
50,
67,
68,
69,
70,
71
] | 29.166667 | false | 12.962963 | 72 | 2 | 70.833333 | 6 |
def stock_jgdy_detail_em(date: str = "20220101") -> pd.DataFrame:
url = "http://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
'sortColumns': 'NOTICE_DATE,RECEIVE_START_DATE,SECURITY_CODE,NUMBERNEW',
'sortTypes': '-1,-1,1,-1',
'pageSize': '50000',
'pageNumber': '1',
'reportName': 'RPT_ORG_SURVEY',
'columns': 'SECUCODE,SECURITY_CODE,SECURITY_NAME_ABBR,NOTICE_DATE,RECEIVE_START_DATE,RECEIVE_OBJECT,RECEIVE_PLACE,RECEIVE_WAY_EXPLAIN,INVESTIGATORS,RECEPTIONIST,ORG_TYPE',
'quoteColumns': 'f2~01~SECURITY_CODE~CLOSE_PRICE,f3~01~SECURITY_CODE~CHANGE_RATE',
'source': 'WEB',
'client': 'WEB',
'filter': f"""(IS_SOURCE="1")(RECEIVE_START_DATE>'{'-'.join([date[:4], date[4:6], date[6:]])}')"""
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json['result']['pages']
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
params.update({"pageNumber": page})
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json['result']['data'])
big_df = pd.concat([big_df, temp_df])
big_df.reset_index(inplace=True)
big_df["index"] = list(range(1, len(big_df) + 1))
big_df.columns = [
"序号",
"_",
"代码",
"名称",
"公告日期",
"调研日期",
"调研机构",
"接待地点",
"接待方式",
"调研人员",
"接待人员",
"机构类型",
"最新价",
"涨跌幅",
]
big_df = big_df[
[
"序号",
"代码",
"名称",
"最新价",
"涨跌幅",
"调研机构",
"机构类型",
"调研人员",
"接待方式",
"接待人员",
"接待地点",
"调研日期",
"公告日期",
]
]
big_df['最新价'] = pd.to_numeric(big_df['最新价'], errors="coerce")
big_df['涨跌幅'] = pd.to_numeric(big_df['涨跌幅'], errors="coerce")
big_df['调研日期'] = pd.to_datetime(big_df['调研日期']).dt.date
big_df['公告日期'] = pd.to_datetime(big_df['公告日期']).dt.date
return big_df
| 17,938 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_fund_flow.py
|
_get_file_content_ths
|
(file: str = "ths.js")
|
return file_data
|
获取 JS 文件的内容
:param file: JS 文件名
:type file: str
:return: 文件内容
:rtype: str
|
获取 JS 文件的内容
:param file: JS 文件名
:type file: str
:return: 文件内容
:rtype: str
| 25 | 36 |
def _get_file_content_ths(file: str = "ths.js") -> str:
"""
获取 JS 文件的内容
:param file: JS 文件名
:type file: str
:return: 文件内容
:rtype: str
"""
setting_file_path = get_ths_js(file)
with open(setting_file_path) as f:
file_data = f.read()
return file_data
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_fund_flow.py#L25-L36
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 66.666667 |
[
8,
9,
10,
11
] | 33.333333 | false | 6.878307 | 12 | 2 | 66.666667 | 5 |
def _get_file_content_ths(file: str = "ths.js") -> str:
setting_file_path = get_ths_js(file)
with open(setting_file_path) as f:
file_data = f.read()
return file_data
| 17,939 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_fund_flow.py
|
stock_fund_flow_individual
|
(symbol: str = "即时") ->
|
return big_df
|
同花顺-数据中心-资金流向-个股资金流
http://data.10jqka.com.cn/funds/ggzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 个股资金流
:rtype: pandas.DataFrame
|
同花顺-数据中心-资金流向-个股资金流
http://data.10jqka.com.cn/funds/ggzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 个股资金流
:rtype: pandas.DataFrame
| 39 | 129 |
def stock_fund_flow_individual(symbol: str = "即时") -> pd.DataFrame:
"""
同花顺-数据中心-资金流向-个股资金流
http://data.10jqka.com.cn/funds/ggzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 个股资金流
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "http://data.10jqka.com.cn/funds/ggzjl/field/zdf/order/desc/ajax/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/3/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/5/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/10/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/20/field/zdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/ggzjl/field/zdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"最新价",
"涨跌幅",
"换手率",
"流入资金",
"流出资金",
"净额",
"成交额",
]
else:
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"最新价",
"阶段涨跌幅",
"连续换手率",
"资金流入净额",
]
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_fund_flow.py#L39-L129
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 9.89011 |
[
9,
10,
11,
12,
13,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
40,
41,
42,
43,
44,
45,
46,
47,
60,
61,
62,
64,
65,
66,
67,
68,
81,
90
] | 39.56044 | false | 6.878307 | 91 | 7 | 60.43956 | 6 |
def stock_fund_flow_individual(symbol: str = "即时") -> pd.DataFrame:
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "http://data.10jqka.com.cn/funds/ggzjl/field/zdf/order/desc/ajax/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/3/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/5/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/10/field/zdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/ggzjl/board/20/field/zdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/ggzjl/field/zdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"最新价",
"涨跌幅",
"换手率",
"流入资金",
"流出资金",
"净额",
"成交额",
]
else:
big_df.columns = [
"序号",
"股票代码",
"股票简称",
"最新价",
"阶段涨跌幅",
"连续换手率",
"资金流入净额",
]
return big_df
| 17,940 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_fund_flow.py
|
stock_fund_flow_concept
|
(symbol: str = "即时") ->
|
return big_df
|
同花顺-数据中心-资金流向-概念资金流
http://data.10jqka.com.cn/funds/gnzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 概念资金流
:rtype: pandas.DataFrame
|
同花顺-数据中心-资金流向-概念资金流
http://data.10jqka.com.cn/funds/gnzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 概念资金流
:rtype: pandas.DataFrame
| 132 | 230 |
def stock_fund_flow_concept(symbol: str = "即时") -> pd.DataFrame:
"""
同花顺-数据中心-资金流向-概念资金流
http://data.10jqka.com.cn/funds/gnzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 概念资金流
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/gnzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = (
"http://data.10jqka.com.cn/funds/gnzjl/field/tradezdf/order/desc/ajax/1/free/1/"
)
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/3/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/5/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/10/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/20/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/gnzjl/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/gnzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"行业",
"行业指数",
"行业-涨跌幅",
"流入资金",
"流出资金",
"净额",
"公司家数",
"领涨股",
"领涨股-涨跌幅",
"当前价",
]
big_df["行业-涨跌幅"] = big_df["行业-涨跌幅"].str.strip("%")
big_df["领涨股-涨跌幅"] = big_df["领涨股-涨跌幅"].str.strip("%")
big_df["行业-涨跌幅"] = pd.to_numeric(big_df["行业-涨跌幅"], errors="coerce")
big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
else:
big_df.columns = [
"序号",
"行业",
"公司家数",
"行业指数",
"阶段涨跌幅",
"流入资金",
"流出资金",
"净额",
]
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_fund_flow.py#L132-L230
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 9.090909 |
[
9,
10,
11,
12,
13,
26,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
42,
43,
44,
45,
46,
47,
48,
49,
62,
63,
64,
66,
67,
68,
69,
70,
83,
84,
85,
86,
88,
98
] | 40.40404 | false | 6.878307 | 99 | 7 | 59.59596 | 6 |
def stock_fund_flow_concept(symbol: str = "即时") -> pd.DataFrame:
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/gnzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = (
"http://data.10jqka.com.cn/funds/gnzjl/field/tradezdf/order/desc/ajax/1/free/1/"
)
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/3/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/5/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/10/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/gnzjl/board/20/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/gnzjl/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/gnzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"行业",
"行业指数",
"行业-涨跌幅",
"流入资金",
"流出资金",
"净额",
"公司家数",
"领涨股",
"领涨股-涨跌幅",
"当前价",
]
big_df["行业-涨跌幅"] = big_df["行业-涨跌幅"].str.strip("%")
big_df["领涨股-涨跌幅"] = big_df["领涨股-涨跌幅"].str.strip("%")
big_df["行业-涨跌幅"] = pd.to_numeric(big_df["行业-涨跌幅"], errors="coerce")
big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
else:
big_df.columns = [
"序号",
"行业",
"公司家数",
"行业指数",
"阶段涨跌幅",
"流入资金",
"流出资金",
"净额",
]
return big_df
| 17,941 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_fund_flow.py
|
stock_fund_flow_industry
|
(symbol: str = "即时") ->
|
return big_df
|
同花顺-数据中心-资金流向-行业资金流
http://data.10jqka.com.cn/funds/hyzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 行业资金流
:rtype: pandas.DataFrame
|
同花顺-数据中心-资金流向-行业资金流
http://data.10jqka.com.cn/funds/hyzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 行业资金流
:rtype: pandas.DataFrame
| 233 | 331 |
def stock_fund_flow_industry(symbol: str = "即时") -> pd.DataFrame:
"""
同花顺-数据中心-资金流向-行业资金流
http://data.10jqka.com.cn/funds/hyzjl/#refCountId=data_55f13c2c_254
:param symbol: choice of {“即时”, "3日排行", "5日排行", "10日排行", "20日排行"}
:type symbol: str
:return: 行业资金流
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = (
"http://data.10jqka.com.cn/funds/hyzjl/field/tradezdf/order/desc/ajax/1/free/1/"
)
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/3/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/5/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/10/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/20/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/hyzjl/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"行业",
"行业指数",
"行业-涨跌幅",
"流入资金",
"流出资金",
"净额",
"公司家数",
"领涨股",
"领涨股-涨跌幅",
"当前价",
]
big_df["行业-涨跌幅"] = big_df["行业-涨跌幅"].str.strip("%")
big_df["领涨股-涨跌幅"] = big_df["领涨股-涨跌幅"].str.strip("%")
big_df["行业-涨跌幅"] = pd.to_numeric(big_df["行业-涨跌幅"], errors="coerce")
big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
else:
big_df.columns = [
"序号",
"行业",
"公司家数",
"行业指数",
"阶段涨跌幅",
"流入资金",
"流出资金",
"净额",
]
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_fund_flow.py#L233-L331
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 9.090909 |
[
9,
10,
11,
12,
13,
26,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
42,
43,
44,
45,
46,
47,
48,
49,
62,
63,
64,
66,
67,
68,
69,
70,
83,
84,
85,
86,
88,
98
] | 40.40404 | false | 6.878307 | 99 | 7 | 59.59596 | 6 |
def stock_fund_flow_industry(symbol: str = "即时") -> pd.DataFrame:
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = (
"http://data.10jqka.com.cn/funds/hyzjl/field/tradezdf/order/desc/ajax/1/free/1/"
)
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
if symbol == "3日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/3/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "5日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/5/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "10日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/10/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
elif symbol == "20日排行":
url = "http://data.10jqka.com.cn/funds/hyzjl/board/20/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
else:
url = "http://data.10jqka.com.cn/funds/hyzjl/field/tradezdf/order/desc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
del big_df["序号"]
big_df.reset_index(inplace=True)
big_df["index"] = range(1, len(big_df) + 1)
if symbol == "即时":
big_df.columns = [
"序号",
"行业",
"行业指数",
"行业-涨跌幅",
"流入资金",
"流出资金",
"净额",
"公司家数",
"领涨股",
"领涨股-涨跌幅",
"当前价",
]
big_df["行业-涨跌幅"] = big_df["行业-涨跌幅"].str.strip("%")
big_df["领涨股-涨跌幅"] = big_df["领涨股-涨跌幅"].str.strip("%")
big_df["行业-涨跌幅"] = pd.to_numeric(big_df["行业-涨跌幅"], errors="coerce")
big_df["领涨股-涨跌幅"] = pd.to_numeric(big_df["领涨股-涨跌幅"], errors="coerce")
else:
big_df.columns = [
"序号",
"行业",
"公司家数",
"行业指数",
"阶段涨跌幅",
"流入资金",
"流出资金",
"净额",
]
return big_df
| 17,942 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_fund_flow.py
|
stock_fund_flow_big_deal
|
()
|
return big_df
|
同花顺-数据中心-资金流向-大单追踪
http://data.10jqka.com.cn/funds/ddzz/###
:return: 大单追踪
:rtype: pandas.DataFrame
|
同花顺-数据中心-资金流向-大单追踪
http://data.10jqka.com.cn/funds/ddzz/###
:return: 大单追踪
:rtype: pandas.DataFrame
| 334 | 400 |
def stock_fund_flow_big_deal() -> pd.DataFrame:
"""
同花顺-数据中心-资金流向-大单追踪
http://data.10jqka.com.cn/funds/ddzz/###
:return: 大单追踪
:rtype: pandas.DataFrame
"""
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "http://data.10jqka.com.cn/funds/ddzz/order/desc/ajax/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
url = "http://data.10jqka.com.cn/funds/ddzz/order/asc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"成交时间",
"股票代码",
"股票简称",
"成交价格",
"成交量",
"成交额",
"大单性质",
"涨跌幅",
"涨跌额",
"详细",
]
del big_df["详细"]
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_fund_flow.py#L334-L400
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 10.447761 |
[
7,
8,
9,
10,
11,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
49,
50,
51,
53,
65,
66
] | 35.820896 | false | 6.878307 | 67 | 2 | 64.179104 | 4 |
def stock_fund_flow_big_deal() -> pd.DataFrame:
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "http://data.10jqka.com.cn/funds/ddzz/order/desc/ajax/1/free/1/"
r = requests.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
raw_page = soup.find("span", attrs={"class": "page_info"}).text
page_num = raw_page.split("/")[1]
url = "http://data.10jqka.com.cn/funds/ddzz/order/asc/page/{}/ajax/1/free/1/"
big_df = pd.DataFrame()
for page in tqdm(range(1, int(page_num) + 1)):
js_code = py_mini_racer.MiniRacer()
js_content = _get_file_content_ths("ths.js")
js_code.eval(js_content)
v_code = js_code.call("v")
headers = {
"Accept": "text/html, */*; q=0.01",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"hexin-v": v_code,
"Host": "data.10jqka.com.cn",
"Pragma": "no-cache",
"Referer": "http://data.10jqka.com.cn/funds/hyzjl/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url.format(page), headers=headers)
temp_df = pd.read_html(r.text)[0]
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"成交时间",
"股票代码",
"股票简称",
"成交价格",
"成交量",
"成交额",
"大单性质",
"涨跌幅",
"涨跌额",
"详细",
]
del big_df["详细"]
return big_df
| 17,943 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_szse_margin.py
|
stock_margin_underlying_info_szse
|
(date: str = "20221129")
|
return temp_df
|
深圳证券交易所-融资融券数据-标的证券信息
https://www.szse.cn/disclosure/margin/object/index.html
:param date: 交易日
:type date: str
:return: 标的证券信息
:rtype: pandas.DataFrame
|
深圳证券交易所-融资融券数据-标的证券信息
https://www.szse.cn/disclosure/margin/object/index.html
:param date: 交易日
:type date: str
:return: 标的证券信息
:rtype: pandas.DataFrame
| 14 | 40 |
def stock_margin_underlying_info_szse(date: str = "20221129") -> pd.DataFrame:
"""
深圳证券交易所-融资融券数据-标的证券信息
https://www.szse.cn/disclosure/margin/object/index.html
:param date: 交易日
:type date: str
:return: 标的证券信息
:rtype: pandas.DataFrame
"""
url = "http://www.szse.cn/api/report/ShowReport"
params = {
"SHOWTYPE": "xlsx",
"CATALOGID": "1834_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab1PAGENO": "1",
"random": "0.7425245522795993",
'TABKEY': 'tab1',
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/object/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
temp_df = pd.read_excel(r.content, engine="openpyxl", dtype={"证券代码": str})
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_szse_margin.py#L14-L40
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 33.333333 |
[
9,
10,
18,
22,
23,
24,
25,
26
] | 29.62963 | false | 12.5 | 27 | 2 | 70.37037 | 6 |
def stock_margin_underlying_info_szse(date: str = "20221129") -> pd.DataFrame:
url = "http://www.szse.cn/api/report/ShowReport"
params = {
"SHOWTYPE": "xlsx",
"CATALOGID": "1834_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab1PAGENO": "1",
"random": "0.7425245522795993",
'TABKEY': 'tab1',
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/object/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
temp_df = pd.read_excel(r.content, engine="openpyxl", dtype={"证券代码": str})
return temp_df
| 17,944 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_szse_margin.py
|
stock_margin_szse
|
(date: str = "20221129")
|
return temp_df
|
深圳证券交易所-融资融券数据-融资融券汇总
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日
:type date: str
:return: 融资融券汇总
:rtype: pandas.DataFrame
|
深圳证券交易所-融资融券数据-融资融券汇总
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日
:type date: str
:return: 融资融券汇总
:rtype: pandas.DataFrame
| 43 | 87 |
def stock_margin_szse(date: str = "20221129") -> pd.DataFrame:
"""
深圳证券交易所-融资融券数据-融资融券汇总
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日
:type date: str
:return: 融资融券汇总
:rtype: pandas.DataFrame
"""
url = "http://www.szse.cn/api/report/ShowReport/data"
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "1837_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab1PAGENO": "1",
"random": "0.7425245522795993",
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/object/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json[0]["data"])
temp_df.columns = [
"融资买入额",
"融资余额",
"融券卖出量",
"融券余量",
"融券余额",
"融资融券余额",
]
temp_df["融资买入额"] = temp_df["融资买入额"].str.replace(",", "")
temp_df["融资买入额"] = pd.to_numeric(temp_df["融资买入额"])
temp_df["融资余额"] = temp_df["融资余额"].str.replace(",", "")
temp_df["融资余额"] = pd.to_numeric(temp_df["融资余额"])
temp_df["融券卖出量"] = temp_df["融券卖出量"].str.replace(",", "")
temp_df["融券卖出量"] = pd.to_numeric(temp_df["融券卖出量"])
temp_df["融券余量"] = temp_df["融券余量"].str.replace(",", "")
temp_df["融券余量"] = pd.to_numeric(temp_df["融券余量"])
temp_df["融券余额"] = temp_df["融券余额"].str.replace(",", "")
temp_df["融券余额"] = pd.to_numeric(temp_df["融券余额"])
temp_df["融资融券余额"] = temp_df["融资融券余额"].str.replace(",", "")
temp_df["融资融券余额"] = pd.to_numeric(temp_df["融资融券余额"])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_szse_margin.py#L43-L87
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 20 |
[
9,
10,
17,
21,
22,
23,
24,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44
] | 44.444444 | false | 12.5 | 45 | 1 | 55.555556 | 6 |
def stock_margin_szse(date: str = "20221129") -> pd.DataFrame:
url = "http://www.szse.cn/api/report/ShowReport/data"
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "1837_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab1PAGENO": "1",
"random": "0.7425245522795993",
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/object/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json[0]["data"])
temp_df.columns = [
"融资买入额",
"融资余额",
"融券卖出量",
"融券余量",
"融券余额",
"融资融券余额",
]
temp_df["融资买入额"] = temp_df["融资买入额"].str.replace(",", "")
temp_df["融资买入额"] = pd.to_numeric(temp_df["融资买入额"])
temp_df["融资余额"] = temp_df["融资余额"].str.replace(",", "")
temp_df["融资余额"] = pd.to_numeric(temp_df["融资余额"])
temp_df["融券卖出量"] = temp_df["融券卖出量"].str.replace(",", "")
temp_df["融券卖出量"] = pd.to_numeric(temp_df["融券卖出量"])
temp_df["融券余量"] = temp_df["融券余量"].str.replace(",", "")
temp_df["融券余量"] = pd.to_numeric(temp_df["融券余量"])
temp_df["融券余额"] = temp_df["融券余额"].str.replace(",", "")
temp_df["融券余额"] = pd.to_numeric(temp_df["融券余额"])
temp_df["融资融券余额"] = temp_df["融资融券余额"].str.replace(",", "")
temp_df["融资融券余额"] = pd.to_numeric(temp_df["融资融券余额"])
return temp_df
| 17,945 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_szse_margin.py
|
stock_margin_detail_szse
|
(date: str = "20221128")
|
return temp_df
|
深证证券交易所-融资融券数据-融资融券交易明细
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日期
:type date: str
:return: 融资融券明细
:rtype: pandas.DataFrame
|
深证证券交易所-融资融券数据-融资融券交易明细
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日期
:type date: str
:return: 融资融券明细
:rtype: pandas.DataFrame
| 90 | 140 |
def stock_margin_detail_szse(date: str = "20221128") -> pd.DataFrame:
"""
深证证券交易所-融资融券数据-融资融券交易明细
https://www.szse.cn/disclosure/margin/margin/index.html
:param date: 交易日期
:type date: str
:return: 融资融券明细
:rtype: pandas.DataFrame
"""
url = "http://www.szse.cn/api/report/ShowReport"
params = {
"SHOWTYPE": "xlsx",
"CATALOGID": "1837_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab2PAGENO": "1",
"random": "0.24279342734085696",
"TABKEY": "tab2",
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/margin/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
temp_df = pd.read_excel(r.content, engine="openpyxl", dtype={"证券代码": str})
temp_df.columns = [
"证券代码",
"证券简称",
"融资买入额",
"融资余额",
"融券卖出量",
"融券余量",
"融券余额",
"融资融券余额",
]
temp_df["证券简称"] = temp_df["证券简称"].str.replace(" ", "")
temp_df["融资买入额"] = temp_df["融资买入额"].str.replace(",", "")
temp_df["融资买入额"] = pd.to_numeric(temp_df["融资买入额"], errors="coerce")
temp_df["融资余额"] = temp_df["融资余额"].str.replace(",", "")
temp_df["融资余额"] = pd.to_numeric(temp_df["融资余额"], errors="coerce")
temp_df["融券卖出量"] = temp_df["融券卖出量"].str.replace(",", "")
temp_df["融券卖出量"] = pd.to_numeric(temp_df["融券卖出量"], errors="coerce")
temp_df["融券余量"] = temp_df["融券余量"].str.replace(",", "")
temp_df["融券余量"] = pd.to_numeric(temp_df["融券余量"], errors="coerce")
temp_df["融券余额"] = temp_df["融券余额"].str.replace(",", "")
temp_df["融券余额"] = pd.to_numeric(temp_df["融券余额"], errors="coerce")
temp_df["融资融券余额"] = temp_df["融资融券余额"].str.replace(",", "")
temp_df["融资融券余额"] = pd.to_numeric(temp_df["融资融券余额"], errors="coerce")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_szse_margin.py#L90-L140
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 17.647059 |
[
9,
10,
18,
23,
24,
25,
26,
27,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50
] | 43.137255 | false | 12.5 | 51 | 2 | 56.862745 | 6 |
def stock_margin_detail_szse(date: str = "20221128") -> pd.DataFrame:
url = "http://www.szse.cn/api/report/ShowReport"
params = {
"SHOWTYPE": "xlsx",
"CATALOGID": "1837_xxpl",
"txtDate": "-".join([date[:4], date[4:6], date[6:]]),
"tab2PAGENO": "1",
"random": "0.24279342734085696",
"TABKEY": "tab2",
}
headers = {
"Referer": "http://www.szse.cn/disclosure/margin/margin/index.html",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.150 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
with warnings.catch_warnings(record=True):
warnings.simplefilter("always")
temp_df = pd.read_excel(r.content, engine="openpyxl", dtype={"证券代码": str})
temp_df.columns = [
"证券代码",
"证券简称",
"融资买入额",
"融资余额",
"融券卖出量",
"融券余量",
"融券余额",
"融资融券余额",
]
temp_df["证券简称"] = temp_df["证券简称"].str.replace(" ", "")
temp_df["融资买入额"] = temp_df["融资买入额"].str.replace(",", "")
temp_df["融资买入额"] = pd.to_numeric(temp_df["融资买入额"], errors="coerce")
temp_df["融资余额"] = temp_df["融资余额"].str.replace(",", "")
temp_df["融资余额"] = pd.to_numeric(temp_df["融资余额"], errors="coerce")
temp_df["融券卖出量"] = temp_df["融券卖出量"].str.replace(",", "")
temp_df["融券卖出量"] = pd.to_numeric(temp_df["融券卖出量"], errors="coerce")
temp_df["融券余量"] = temp_df["融券余量"].str.replace(",", "")
temp_df["融券余量"] = pd.to_numeric(temp_df["融券余量"], errors="coerce")
temp_df["融券余额"] = temp_df["融券余额"].str.replace(",", "")
temp_df["融券余额"] = pd.to_numeric(temp_df["融券余额"], errors="coerce")
temp_df["融资融券余额"] = temp_df["融资融券余额"].str.replace(",", "")
temp_df["融资融券余额"] = pd.to_numeric(temp_df["融资融券余额"], errors="coerce")
return temp_df
| 17,946 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_us_hist_futunn.py
|
stock_us_code_table_fu
|
()
|
return big_df
|
富途牛牛-行情-美股-美股代码表
https://www.futunn.com/stock/HON-US
:return: 美股代码表
:rtype: pandas.DataFrame
|
富途牛牛-行情-美股-美股代码表
https://www.futunn.com/stock/HON-US
:return: 美股代码表
:rtype: pandas.DataFrame
| 16 | 97 |
def stock_us_code_table_fu() -> pd.DataFrame:
"""
富途牛牛-行情-美股-美股代码表
https://www.futunn.com/stock/HON-US
:return: 美股代码表
:rtype: pandas.DataFrame
"""
url = "https://www.futunn.com/quote/list/us/1/694"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find('{"prefetch') : data_text.find(",window._params")]
)
pd.DataFrame(data_json["prefetch"]["stockList"]["list"])
total_page = data_json["prefetch"]["stockList"]["page"]["page_count"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
url = f"https://www.futunn.com/quote/list/us/1/{page}"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find('{"prefetch') : data_text.find(",window._params")]
)
temp_df = pd.DataFrame(data_json["prefetch"]["stockList"]["list"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"代码",
"最新价",
"成交额",
"成交量",
"换手率",
"振幅",
"涨跌额",
"涨跌幅",
"-",
"股票名称",
"股票简称",
"-",
]
big_df = big_df[
[
"代码",
"股票名称",
"股票简称",
"最新价",
"涨跌额",
"涨跌幅",
"成交量",
"成交额",
"换手率",
"振幅",
]
]
big_df["最新价"] = pd.to_numeric(big_df["最新价"])
big_df["涨跌额"] = pd.to_numeric(big_df["涨跌额"])
big_df["涨跌幅"] = big_df["涨跌幅"].str.strip("%")
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
big_df["换手率"] = big_df["换手率"].str.strip("%")
big_df["换手率"] = pd.to_numeric(big_df["换手率"])
big_df["振幅"] = big_df["振幅"].str.strip("%")
big_df["振幅"] = pd.to_numeric(big_df["振幅"])
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_us_hist_futunn.py#L16-L97
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 8.536585 |
[
7,
8,
18,
19,
20,
23,
24,
25,
26,
27,
28,
38,
39,
40,
43,
44,
45,
59,
73,
74,
75,
76,
77,
78,
79,
80,
81
] | 32.926829 | false | 14.285714 | 82 | 2 | 67.073171 | 4 |
def stock_us_code_table_fu() -> pd.DataFrame:
url = "https://www.futunn.com/quote/list/us/1/694"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find('{"prefetch') : data_text.find(",window._params")]
)
pd.DataFrame(data_json["prefetch"]["stockList"]["list"])
total_page = data_json["prefetch"]["stockList"]["page"]["page_count"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
url = f"https://www.futunn.com/quote/list/us/1/{page}"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find('{"prefetch') : data_text.find(",window._params")]
)
temp_df = pd.DataFrame(data_json["prefetch"]["stockList"]["list"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"代码",
"最新价",
"成交额",
"成交量",
"换手率",
"振幅",
"涨跌额",
"涨跌幅",
"-",
"股票名称",
"股票简称",
"-",
]
big_df = big_df[
[
"代码",
"股票名称",
"股票简称",
"最新价",
"涨跌额",
"涨跌幅",
"成交量",
"成交额",
"换手率",
"振幅",
]
]
big_df["最新价"] = pd.to_numeric(big_df["最新价"])
big_df["涨跌额"] = pd.to_numeric(big_df["涨跌额"])
big_df["涨跌幅"] = big_df["涨跌幅"].str.strip("%")
big_df["涨跌幅"] = pd.to_numeric(big_df["涨跌幅"])
big_df["换手率"] = big_df["换手率"].str.strip("%")
big_df["换手率"] = pd.to_numeric(big_df["换手率"])
big_df["振幅"] = big_df["振幅"].str.strip("%")
big_df["振幅"] = pd.to_numeric(big_df["振幅"])
return big_df
| 17,947 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_us_hist_futunn.py
|
stock_us_hist_fu
|
(
symbol: str = "202545",
start_date: str = "19700101",
end_date: str = "22220101",
)
|
return temp_df
|
富途牛牛-行情-美股-每日行情
https://www.futunn.com/stock/HON-US
:param symbol: 股票代码; 此股票代码可以通过调用 ak.stock_us_code_table_fu() 的 `代码` 字段获取
:type symbol: str
:param start_date: 开始日期
:type start_date: str
:param end_date: 结束日期
:type end_date: str
:return: 每日行情
:rtype: pandas.DataFrame
|
富途牛牛-行情-美股-每日行情
https://www.futunn.com/stock/HON-US
:param symbol: 股票代码; 此股票代码可以通过调用 ak.stock_us_code_table_fu() 的 `代码` 字段获取
:type symbol: str
:param start_date: 开始日期
:type start_date: str
:param end_date: 结束日期
:type end_date: str
:return: 每日行情
:rtype: pandas.DataFrame
| 100 | 187 |
def stock_us_hist_fu(
symbol: str = "202545",
start_date: str = "19700101",
end_date: str = "22220101",
) -> pd.DataFrame:
"""
富途牛牛-行情-美股-每日行情
https://www.futunn.com/stock/HON-US
:param symbol: 股票代码; 此股票代码可以通过调用 ak.stock_us_code_table_fu() 的 `代码` 字段获取
:type symbol: str
:param start_date: 开始日期
:type start_date: str
:param end_date: 结束日期
:type end_date: str
:return: 每日行情
:rtype: pandas.DataFrame
"""
url = "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
session_ = requests.session()
r = session_.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
url = "https://www.futunn.com/quote-api/get-kline"
params = {
"stock_id": symbol,
"market_type": "2",
"type": "2",
}
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": soup.find("meta")["content"],
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
}
r = session_.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
temp_df.columns = [
"日期",
"今开",
"今收",
"最高",
"最低",
"成交量",
"成交额",
"换手率",
"-",
"昨收",
]
temp_df = temp_df[
[
"日期",
"今开",
"今收",
"最高",
"最低",
"成交量",
"成交额",
"换手率",
"昨收",
]
]
temp_df.index = pd.to_datetime(temp_df["日期"], unit="s")
temp_df = temp_df[start_date:end_date]
temp_df.reset_index(inplace=True, drop=True)
temp_df["日期"] = pd.to_datetime(temp_df["日期"], unit="s").dt.date
temp_df["今开"] = pd.to_numeric(temp_df["今开"]) / 100
temp_df["最高"] = pd.to_numeric(temp_df["最高"]) / 100
temp_df["最低"] = pd.to_numeric(temp_df["最低"]) / 100
temp_df["今收"] = pd.to_numeric(temp_df["今收"]) / 100
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"]) / 100
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_us_hist_futunn.py#L100-L187
| 25 |
[
0
] | 1.136364 |
[
17,
18,
28,
29,
30,
31,
32,
37,
50,
51,
52,
53,
65,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87
] | 26.136364 | false | 14.285714 | 88 | 1 | 73.863636 | 10 |
def stock_us_hist_fu(
symbol: str = "202545",
start_date: str = "19700101",
end_date: str = "22220101",
) -> pd.DataFrame:
url = "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth"
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": "FM5ZhxYFQsZM4k9rXk3TMA==-O4oTw/tuNRp5DlJNWo/TNEEfMt8=",
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36",
}
session_ = requests.session()
r = session_.get(url, headers=headers)
soup = BeautifulSoup(r.text, "lxml")
url = "https://www.futunn.com/quote-api/get-kline"
params = {
"stock_id": symbol,
"market_type": "2",
"type": "2",
}
headers = {
"accept": "application/json, text/plain, */*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"futu-x-csrf-token": soup.find("meta")["content"],
"pragma": "no-cache",
"referer": "https://www.futunn.com/stock/HON-US?seo_redirect=1&channel=1244&subchannel=2&from=BaiduAladdin&utm_source=alading_user&utm_medium=website_growth",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1",
}
r = session_.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
temp_df.columns = [
"日期",
"今开",
"今收",
"最高",
"最低",
"成交量",
"成交额",
"换手率",
"-",
"昨收",
]
temp_df = temp_df[
[
"日期",
"今开",
"今收",
"最高",
"最低",
"成交量",
"成交额",
"换手率",
"昨收",
]
]
temp_df.index = pd.to_datetime(temp_df["日期"], unit="s")
temp_df = temp_df[start_date:end_date]
temp_df.reset_index(inplace=True, drop=True)
temp_df["日期"] = pd.to_datetime(temp_df["日期"], unit="s").dt.date
temp_df["今开"] = pd.to_numeric(temp_df["今开"]) / 100
temp_df["最高"] = pd.to_numeric(temp_df["最高"]) / 100
temp_df["最低"] = pd.to_numeric(temp_df["最低"]) / 100
temp_df["今收"] = pd.to_numeric(temp_df["今收"]) / 100
temp_df["昨收"] = pd.to_numeric(temp_df["昨收"]) / 100
return temp_df
| 17,948 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/stock_feature/stock_inner_trade_xq.py
|
stock_inner_trade_xq
|
()
|
return temp_df
|
雪球-行情中心-沪深股市-内部交易
https://xueqiu.com/hq/insider
:return: 内部交易
:rtype: pandas.DataFrame
|
雪球-行情中心-沪深股市-内部交易
https://xueqiu.com/hq/insider
:return: 内部交易
:rtype: pandas.DataFrame
| 12 | 74 |
def stock_inner_trade_xq() -> pd.DataFrame:
"""
雪球-行情中心-沪深股市-内部交易
https://xueqiu.com/hq/insider
:return: 内部交易
:rtype: pandas.DataFrame
"""
url = "https://xueqiu.com/service/v5/stock/f10/cn/skholderchg"
params = {
'size': '100000',
'page': '1',
'extend': 'true',
'_': '1651223013040',
}
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "xueqiu.com",
"Pragma": "no-cache",
"Referer": "https://xueqiu.com/hq",
"sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["items"])
temp_df.columns = [
'股票代码',
'股票名称',
'变动人',
'-',
'变动日期',
'变动股数',
'成交均价',
'变动后持股数',
'与董监高关系',
'董监高职务',
]
temp_df = temp_df[[
'股票代码',
'股票名称',
'变动日期',
'变动人',
'变动股数',
'成交均价',
'变动后持股数',
'与董监高关系',
'董监高职务',
]]
temp_df['变动日期'] = pd.to_datetime(temp_df['变动日期'], unit="ms").dt.date
temp_df['变动股数'] = pd.to_numeric(temp_df['变动股数'])
temp_df['成交均价'] = pd.to_numeric(temp_df['成交均价'])
temp_df['变动后持股数'] = pd.to_numeric(temp_df['变动后持股数'])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/stock_feature/stock_inner_trade_xq.py#L12-L74
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 11.111111 |
[
7,
8,
14,
32,
33,
34,
35,
47,
58,
59,
60,
61,
62
] | 20.634921 | false | 25 | 63 | 1 | 79.365079 | 4 |
def stock_inner_trade_xq() -> pd.DataFrame:
url = "https://xueqiu.com/service/v5/stock/f10/cn/skholderchg"
params = {
'size': '100000',
'page': '1',
'extend': 'true',
'_': '1651223013040',
}
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "xueqiu.com",
"Pragma": "no-cache",
"Referer": "https://xueqiu.com/hq",
"sec-ch-ua": '" Not A;Brand";v="99", "Chromium";v="100", "Google Chrome";v="100"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "empty",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Site": "same-origin",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.127 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["items"])
temp_df.columns = [
'股票代码',
'股票名称',
'变动人',
'-',
'变动日期',
'变动股数',
'成交均价',
'变动后持股数',
'与董监高关系',
'董监高职务',
]
temp_df = temp_df[[
'股票代码',
'股票名称',
'变动日期',
'变动人',
'变动股数',
'成交均价',
'变动后持股数',
'与董监高关系',
'董监高职务',
]]
temp_df['变动日期'] = pd.to_datetime(temp_df['变动日期'], unit="ms").dt.date
temp_df['变动股数'] = pd.to_numeric(temp_df['变动股数'])
temp_df['成交均价'] = pd.to_numeric(temp_df['成交均价'])
temp_df['变动后持股数'] = pd.to_numeric(temp_df['变动后持股数'])
return temp_df
| 17,949 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/sport/sport_olympic_winter.py
|
sport_olympic_winter_hist
|
()
|
return temp_df
|
腾讯运动-冬奥会-历届奖牌榜
:return: 历届奖牌榜
:rtype: pandas.DataFrame
|
腾讯运动-冬奥会-历届奖牌榜
:return: 历届奖牌榜
:rtype: pandas.DataFrame
| 12 | 34 |
def sport_olympic_winter_hist() -> pd.DataFrame:
"""
腾讯运动-冬奥会-历届奖牌榜
:return: 历届奖牌榜
:rtype: pandas.DataFrame
"""
url = "https://app.sports.qq.com/m/oly/historyMedal"
r = requests.get(url)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
temp_df = temp_df.explode("list")
temp_df["国家及地区"] = temp_df["list"].apply(lambda x: (x["noc"]))
temp_df["金牌数"] = temp_df["list"].apply(lambda x: (int(x["gold"])))
temp_df["总奖牌数"] = temp_df["list"].apply(lambda x: (int(x["total"])))
temp_df["举办年份"] = temp_df["year"].astype("str")
temp_df["届数"] = temp_df["no"].astype("str")
temp_df["举办地点"] = temp_df["country"]
temp_df = temp_df[["举办年份", "届数", "举办地点", "国家及地区", "金牌数", "总奖牌数"]]
temp_df = temp_df.replace("俄罗斯奥委会", "俄罗斯")
temp_df.reset_index(inplace=True)
temp_df["index"] = range(1, len(temp_df) + 1)
temp_df.rename(columns={"index": "序号"}, inplace=True)
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/sport/sport_olympic_winter.py#L12-L34
| 25 |
[
0,
1,
2,
3,
4,
5
] | 26.086957 |
[
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22
] | 73.913043 | false | 20.833333 | 23 | 1 | 26.086957 | 3 |
def sport_olympic_winter_hist() -> pd.DataFrame:
url = "https://app.sports.qq.com/m/oly/historyMedal"
r = requests.get(url)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["list"])
temp_df = temp_df.explode("list")
temp_df["国家及地区"] = temp_df["list"].apply(lambda x: (x["noc"]))
temp_df["金牌数"] = temp_df["list"].apply(lambda x: (int(x["gold"])))
temp_df["总奖牌数"] = temp_df["list"].apply(lambda x: (int(x["total"])))
temp_df["举办年份"] = temp_df["year"].astype("str")
temp_df["届数"] = temp_df["no"].astype("str")
temp_df["举办地点"] = temp_df["country"]
temp_df = temp_df[["举办年份", "届数", "举办地点", "国家及地区", "金牌数", "总奖牌数"]]
temp_df = temp_df.replace("俄罗斯奥委会", "俄罗斯")
temp_df.reset_index(inplace=True)
temp_df["index"] = range(1, len(temp_df) + 1)
temp_df.rename(columns={"index": "序号"}, inplace=True)
return temp_df
| 17,950 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/sport/sport_olympic.py
|
sport_olympic_hist
|
()
|
return temp_df
|
运动-奥运会-奖牌数据
https://www.kaggle.com/marcogdepinto/let-s-discover-more-about-the-olympic-games
:return: 奥运会-奖牌数据
:rtype: pandas.DataFrame
|
运动-奥运会-奖牌数据
https://www.kaggle.com/marcogdepinto/let-s-discover-more-about-the-olympic-games
:return: 奥运会-奖牌数据
:rtype: pandas.DataFrame
| 11 | 22 |
def sport_olympic_hist() -> pd.DataFrame:
"""
运动-奥运会-奖牌数据
https://www.kaggle.com/marcogdepinto/let-s-discover-more-about-the-olympic-games
:return: 奥运会-奖牌数据
:rtype: pandas.DataFrame
"""
url = "https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/data/data_olympic/athlete_events.zip"
temp_df = pd.read_csv(url)
columns_list = [item.lower() for item in temp_df.columns.tolist()]
temp_df.columns = columns_list
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/sport/sport_olympic.py#L11-L22
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 58.333333 |
[
7,
8,
9,
10,
11
] | 41.666667 | false | 36.363636 | 12 | 2 | 58.333333 | 4 |
def sport_olympic_hist() -> pd.DataFrame:
url = "https://jfds-1252952517.cos.ap-chengdu.myqcloud.com/akshare/data/data_olympic/athlete_events.zip"
temp_df = pd.read_csv(url)
columns_list = [item.lower() for item in temp_df.columns.tolist()]
temp_df.columns = columns_list
return temp_df
| 17,951 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_em.py
|
option_current_em
|
()
|
return temp_df
|
东方财富网-行情中心-期权市场
http://quote.eastmoney.com/center
:return: 期权价格
:rtype: pandas.DataFrame
|
东方财富网-行情中心-期权市场
http://quote.eastmoney.com/center
:return: 期权价格
:rtype: pandas.DataFrame
| 14 | 105 |
def option_current_em() -> pd.DataFrame:
"""
东方财富网-行情中心-期权市场
http://quote.eastmoney.com/center
:return: 期权价格
:rtype: pandas.DataFrame
"""
url = 'http://23.push2.eastmoney.com/api/qt/clist/get'
params = {
'cb': 'jQuery112409395946290628259_1606225274048',
'pn': '1',
'pz': '200000',
'po': '1',
'np': '1',
'ut': 'bd1d9ddb04089700cf9c27f6f7426281',
'fltt': '2',
'invt': '2',
'fid': 'f3',
'fs': 'm:10,m:140,m:141,m:151',
'fields': 'f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f28,f11,f62,f128,f136,f115,f152,f133,f108,f163,f161,f162',
'_': '1606225274063',
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(data_text[data_text.find('{'):-2])
temp_df = pd.DataFrame(data_json['data']['diff'])
temp_df.columns = [
'_',
'最新价',
'涨跌幅',
'涨跌额',
'成交量',
'成交额',
'_',
'_',
'_',
'_',
'_',
'代码',
'_',
'名称',
'_',
'_',
'今开',
'_',
'_',
'_',
'_',
'_',
'_',
'_',
'昨结',
'_',
'持仓量',
'_',
'_',
'_',
'_',
'_',
'_',
'_',
'行权价',
'剩余日',
'日增'
]
temp_df = temp_df[[
'代码',
'名称',
'最新价',
'涨跌额',
'涨跌幅',
'成交量',
'成交额',
'持仓量',
'行权价',
'剩余日',
'日增',
'昨结',
'今开'
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors='coerce')
temp_df['涨跌额'] = pd.to_numeric(temp_df['涨跌额'], errors='coerce')
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors='coerce')
temp_df['成交量'] = pd.to_numeric(temp_df['成交量'], errors='coerce')
temp_df['成交额'] = pd.to_numeric(temp_df['成交额'], errors='coerce')
temp_df['持仓量'] = pd.to_numeric(temp_df['持仓量'], errors='coerce')
temp_df['行权价'] = pd.to_numeric(temp_df['行权价'], errors='coerce')
temp_df['剩余日'] = pd.to_numeric(temp_df['剩余日'], errors='coerce')
temp_df['日增'] = pd.to_numeric(temp_df['日增'], errors='coerce')
temp_df['昨结'] = pd.to_numeric(temp_df['昨结'], errors='coerce')
temp_df['今开'] = pd.to_numeric(temp_df['今开'], errors='coerce')
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_em.py#L14-L105
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 7.608696 |
[
7,
8,
22,
23,
24,
25,
26,
65,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91
] | 21.73913 | false | 21.428571 | 92 | 1 | 78.26087 | 4 |
def option_current_em() -> pd.DataFrame:
url = 'http://23.push2.eastmoney.com/api/qt/clist/get'
params = {
'cb': 'jQuery112409395946290628259_1606225274048',
'pn': '1',
'pz': '200000',
'po': '1',
'np': '1',
'ut': 'bd1d9ddb04089700cf9c27f6f7426281',
'fltt': '2',
'invt': '2',
'fid': 'f3',
'fs': 'm:10,m:140,m:141,m:151',
'fields': 'f1,f2,f3,f4,f5,f6,f7,f8,f9,f10,f12,f13,f14,f15,f16,f17,f18,f20,f21,f23,f24,f25,f22,f28,f11,f62,f128,f136,f115,f152,f133,f108,f163,f161,f162',
'_': '1606225274063',
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(data_text[data_text.find('{'):-2])
temp_df = pd.DataFrame(data_json['data']['diff'])
temp_df.columns = [
'_',
'最新价',
'涨跌幅',
'涨跌额',
'成交量',
'成交额',
'_',
'_',
'_',
'_',
'_',
'代码',
'_',
'名称',
'_',
'_',
'今开',
'_',
'_',
'_',
'_',
'_',
'_',
'_',
'昨结',
'_',
'持仓量',
'_',
'_',
'_',
'_',
'_',
'_',
'_',
'行权价',
'剩余日',
'日增'
]
temp_df = temp_df[[
'代码',
'名称',
'最新价',
'涨跌额',
'涨跌幅',
'成交量',
'成交额',
'持仓量',
'行权价',
'剩余日',
'日增',
'昨结',
'今开'
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors='coerce')
temp_df['涨跌额'] = pd.to_numeric(temp_df['涨跌额'], errors='coerce')
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors='coerce')
temp_df['成交量'] = pd.to_numeric(temp_df['成交量'], errors='coerce')
temp_df['成交额'] = pd.to_numeric(temp_df['成交额'], errors='coerce')
temp_df['持仓量'] = pd.to_numeric(temp_df['持仓量'], errors='coerce')
temp_df['行权价'] = pd.to_numeric(temp_df['行权价'], errors='coerce')
temp_df['剩余日'] = pd.to_numeric(temp_df['剩余日'], errors='coerce')
temp_df['日增'] = pd.to_numeric(temp_df['日增'], errors='coerce')
temp_df['昨结'] = pd.to_numeric(temp_df['昨结'], errors='coerce')
temp_df['今开'] = pd.to_numeric(temp_df['今开'], errors='coerce')
return temp_df
| 17,952 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_value_analysis_em.py
|
option_value_analysis_em
|
()
|
return temp_df
|
东方财富网-数据中心-特色数据-期权价值分析
https://data.eastmoney.com/other/valueAnal.html
:return: 期权价值分析
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-期权价值分析
https://data.eastmoney.com/other/valueAnal.html
:return: 期权价值分析
:rtype: pandas.DataFrame
| 12 | 77 |
def option_value_analysis_em() -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-期权价值分析
https://data.eastmoney.com/other/valueAnal.html
:return: 期权价值分析
:rtype: pandas.DataFrame
"""
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f301',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f298,f299,f249,f300,f330,f331,f332,f333,f334,f335,f336,f301,f152',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'-',
'期权代码',
'-',
'期权名称',
'-',
'隐含波动率',
'时间价值',
'内在价值',
'理论价格',
'到期日',
'-',
'-',
'-',
'标的名称',
'标的最新价',
'-',
'标的近一年波动率',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'时间价值',
'内在价值',
'隐含波动率',
'理论价格',
'标的名称',
'标的最新价',
'标的近一年波动率',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['时间价值'] = pd.to_numeric(temp_df['时间价值'])
temp_df['内在价值'] = pd.to_numeric(temp_df['内在价值'])
temp_df['隐含波动率'] = pd.to_numeric(temp_df['隐含波动率'])
temp_df['理论价格'] = pd.to_numeric(temp_df['理论价格'], errors="coerce")
temp_df['标的最新价'] = pd.to_numeric(temp_df['标的最新价'])
temp_df['标的近一年波动率'] = pd.to_numeric(temp_df['标的近一年波动率'])
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_value_analysis_em.py#L12-L77
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 10.606061 |
[
7,
8,
20,
21,
22,
23,
44,
57,
58,
59,
60,
61,
62,
63,
64,
65
] | 24.242424 | false | 21.73913 | 66 | 1 | 75.757576 | 4 |
def option_value_analysis_em() -> pd.DataFrame:
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f301',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f298,f299,f249,f300,f330,f331,f332,f333,f334,f335,f336,f301,f152',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'-',
'期权代码',
'-',
'期权名称',
'-',
'隐含波动率',
'时间价值',
'内在价值',
'理论价格',
'到期日',
'-',
'-',
'-',
'标的名称',
'标的最新价',
'-',
'标的近一年波动率',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'时间价值',
'内在价值',
'隐含波动率',
'理论价格',
'标的名称',
'标的最新价',
'标的近一年波动率',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['时间价值'] = pd.to_numeric(temp_df['时间价值'])
temp_df['内在价值'] = pd.to_numeric(temp_df['内在价值'])
temp_df['隐含波动率'] = pd.to_numeric(temp_df['隐含波动率'])
temp_df['理论价格'] = pd.to_numeric(temp_df['理论价格'], errors="coerce")
temp_df['标的最新价'] = pd.to_numeric(temp_df['标的最新价'])
temp_df['标的近一年波动率'] = pd.to_numeric(temp_df['标的近一年波动率'])
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
| 17,953 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_sz50_list_sina
|
()
|
return {symbol: contract}
|
新浪财经-中金所-上证 50 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有上证 50 指数,沪深 300 指数和中证 1000 指数
:return: 中金所-上证 50 指数-所有合约
:rtype: dict
|
新浪财经-中金所-上证 50 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有上证 50 指数,沪深 300 指数和中证 1000 指数
:return: 中金所-上证 50 指数-所有合约
:rtype: dict
| 23 | 36 |
def option_cffex_sz50_list_sina() -> Dict[str, List[str]]:
"""
新浪财经-中金所-上证 50 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有上证 50 指数,沪深 300 指数和中证 1000 指数
:return: 中金所-上证 50 指数-所有合约
:rtype: dict
"""
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/ho/cffex"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[0].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L23-L36
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 50 |
[
7,
8,
9,
10,
11,
12,
13
] | 50 | false | 8.469055 | 14 | 2 | 50 | 4 |
def option_cffex_sz50_list_sina() -> Dict[str, List[str]]:
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/ho/cffex"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[0].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
| 17,954 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_hs300_list_sina
|
()
|
return {symbol: contract}
|
新浪财经-中金所-沪深 300 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-沪深300指数-所有合约
:rtype: dict
|
新浪财经-中金所-沪深 300 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-沪深300指数-所有合约
:rtype: dict
| 40 | 53 |
def option_cffex_hs300_list_sina() -> Dict[str, List[str]]:
"""
新浪财经-中金所-沪深 300 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-沪深300指数-所有合约
:rtype: dict
"""
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[1].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L40-L53
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 50 |
[
7,
8,
9,
10,
11,
12,
13
] | 50 | false | 8.469055 | 14 | 2 | 50 | 4 |
def option_cffex_hs300_list_sina() -> Dict[str, List[str]]:
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[1].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
| 17,955 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_zz1000_list_sina
|
()
|
return {symbol: contract}
|
新浪财经-中金所-中证 1000 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-中证 1000 指数-所有合约
:rtype: dict
|
新浪财经-中金所-中证 1000 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-中证 1000 指数-所有合约
:rtype: dict
| 56 | 69 |
def option_cffex_zz1000_list_sina() -> Dict[str, List[str]]:
"""
新浪财经-中金所-中证 1000 指数-所有合约, 返回的第一个合约为主力合约
目前新浪财经-中金所有沪深 300 指数和中证 1000 指数
:return: 中金所-中证 1000 指数-所有合约
:rtype: dict
"""
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/mo/cffex"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[2].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L56-L69
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 50 |
[
7,
8,
9,
10,
11,
12,
13
] | 50 | false | 8.469055 | 14 | 2 | 50 | 4 |
def option_cffex_zz1000_list_sina() -> Dict[str, List[str]]:
url = "https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/mo/cffex"
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = soup.find(attrs={"id": "option_symbol"}).find_all("li")[2].text
temp_attr = soup.find(attrs={"id": "option_suffix"}).find_all("li")
contract = [item.text for item in temp_attr]
return {symbol: contract}
| 17,956 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_sz50_spot_sina
|
(symbol: str = "ho2303")
|
return data_df
|
中金所-上证 50 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/ho/cffex
:param symbol: 合约代码; 用 ak.option_cffex_sz300_list_sina() 函数查看
:type symbol: str
:return: 中金所-上证 50 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
|
中金所-上证 50 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/ho/cffex
:param symbol: 合约代码; 用 ak.option_cffex_sz300_list_sina() 函数查看
:type symbol: str
:return: 中金所-上证 50 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
| 72 | 136 |
def option_cffex_sz50_spot_sina(symbol: str = "ho2303") -> pd.DataFrame:
"""
中金所-上证 50 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php/ho/cffex
:param symbol: 合约代码; 用 ak.option_cffex_sz300_list_sina() 函数查看
:type symbol: str
:return: 中金所-上证 50 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "ho",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L72-L136
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 13.846154 |
[
9,
10,
16,
17,
18,
21,
35,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64
] | 36.923077 | false | 8.469055 | 65 | 1 | 63.076923 | 6 |
def option_cffex_sz50_spot_sina(symbol: str = "ho2303") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "ho",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
| 17,957 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_hs300_spot_sina
|
(symbol: str = "io2204")
|
return data_df
|
中金所-沪深 300 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_hs300_list_sina 函数查看
:type symbol: str
:return: 中金所-沪深300指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
|
中金所-沪深 300 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_hs300_list_sina 函数查看
:type symbol: str
:return: 中金所-沪深300指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
| 139 | 203 |
def option_cffex_hs300_spot_sina(symbol: str = "io2204") -> pd.DataFrame:
"""
中金所-沪深 300 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_hs300_list_sina 函数查看
:type symbol: str
:return: 中金所-沪深300指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "io",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L139-L203
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 13.846154 |
[
9,
10,
16,
17,
18,
21,
35,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64
] | 36.923077 | false | 8.469055 | 65 | 1 | 63.076923 | 6 |
def option_cffex_hs300_spot_sina(symbol: str = "io2204") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "io",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
| 17,958 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_zz1000_spot_sina
|
(symbol: str = "mo2208")
|
return data_df
|
中金所-中证 1000 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_zz1000_list_sina 函数查看
:type symbol: str
:return: 中金所-中证 1000 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
|
中金所-中证 1000 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_zz1000_list_sina 函数查看
:type symbol: str
:return: 中金所-中证 1000 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
| 206 | 270 |
def option_cffex_zz1000_spot_sina(symbol: str = "mo2208") -> pd.DataFrame:
"""
中金所-中证 1000 指数-指定合约-实时行情
https://stock.finance.sina.com.cn/futures/view/optionsCffexDP.php
:param symbol: 合约代码; 用 option_cffex_zz1000_list_sina 函数查看
:type symbol: str
:return: 中金所-中证 1000 指数-指定合约-看涨看跌实时行情
:rtype: pd.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "mo",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L206-L270
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 13.846154 |
[
9,
10,
16,
17,
18,
21,
35,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64
] | 36.923077 | false | 8.469055 | 65 | 1 | 63.076923 | 6 |
def option_cffex_zz1000_spot_sina(symbol: str = "mo2208") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": "mo",
"exchange": "cffex",
"pinzhong": symbol,
}
r = requests.get(url, params=params)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("{") : data_text.rfind("}") + 1]
)
option_call_df = pd.DataFrame(
data_json["result"]["data"]["up"],
columns=[
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-标识",
],
)
option_put_df = pd.DataFrame(
data_json["result"]["data"]["down"],
columns=[
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-标识",
],
)
data_df = pd.concat([option_call_df, option_put_df], axis=1)
data_df["看涨合约-买量"] = pd.to_numeric(data_df["看涨合约-买量"], errors="coerce")
data_df["看涨合约-买价"] = pd.to_numeric(data_df["看涨合约-买价"], errors="coerce")
data_df["看涨合约-最新价"] = pd.to_numeric(data_df["看涨合约-最新价"], errors="coerce")
data_df["看涨合约-卖价"] = pd.to_numeric(data_df["看涨合约-卖价"], errors="coerce")
data_df["看涨合约-卖量"] = pd.to_numeric(data_df["看涨合约-卖量"], errors="coerce")
data_df["看涨合约-持仓量"] = pd.to_numeric(data_df["看涨合约-持仓量"], errors="coerce")
data_df["看涨合约-涨跌"] = pd.to_numeric(data_df["看涨合约-涨跌"], errors="coerce")
data_df["行权价"] = pd.to_numeric(data_df["行权价"], errors="coerce")
data_df["看跌合约-买量"] = pd.to_numeric(data_df["看跌合约-买量"], errors="coerce")
data_df["看跌合约-买价"] = pd.to_numeric(data_df["看跌合约-买价"], errors="coerce")
data_df["看跌合约-最新价"] = pd.to_numeric(data_df["看跌合约-最新价"], errors="coerce")
data_df["看跌合约-卖价"] = pd.to_numeric(data_df["看跌合约-卖价"], errors="coerce")
data_df["看跌合约-卖量"] = pd.to_numeric(data_df["看跌合约-卖量"], errors="coerce")
data_df["看跌合约-持仓量"] = pd.to_numeric(data_df["看跌合约-持仓量"], errors="coerce")
data_df["看跌合约-涨跌"] = pd.to_numeric(data_df["看跌合约-涨跌"], errors="coerce")
return data_df
| 17,959 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_sz50_daily_sina
|
(symbol: str = "ho2303P2350")
|
return data_df
|
新浪财经-中金所-上证 50 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_sz50_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
|
新浪财经-中金所-上证 50 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_sz50_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
| 273 | 308 |
def option_cffex_sz50_daily_sina(symbol: str = "ho2303P2350") -> pd.DataFrame:
"""
新浪财经-中金所-上证 50 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_sz50_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
"""
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L273-L308
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 22.222222 |
[
8,
9,
10,
11,
12,
13,
14,
15,
18,
19,
29,
30,
31,
32,
33,
34,
35
] | 47.222222 | false | 8.469055 | 36 | 1 | 52.777778 | 5 |
def option_cffex_sz50_daily_sina(symbol: str = "ho2303P2350") -> pd.DataFrame:
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
| 17,960 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_hs300_daily_sina
|
(symbol: str = "io2202P4350")
|
return data_df
|
新浪财经-中金所-沪深300指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_hs300_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
|
新浪财经-中金所-沪深300指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_hs300_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
| 311 | 346 |
def option_cffex_hs300_daily_sina(symbol: str = "io2202P4350") -> pd.DataFrame:
"""
新浪财经-中金所-沪深300指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_hs300_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
"""
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L311-L346
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 22.222222 |
[
8,
9,
10,
11,
12,
13,
14,
15,
18,
19,
29,
30,
31,
32,
33,
34,
35
] | 47.222222 | false | 8.469055 | 36 | 1 | 52.777778 | 5 |
def option_cffex_hs300_daily_sina(symbol: str = "io2202P4350") -> pd.DataFrame:
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
| 17,961 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_cffex_zz1000_daily_sina
|
(
symbol: str = "mo2208P6200",
)
|
return data_df
|
新浪财经-中金所-中证 1000 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_zz1000_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
|
新浪财经-中金所-中证 1000 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_zz1000_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
| 349 | 386 |
def option_cffex_zz1000_daily_sina(
symbol: str = "mo2208P6200",
) -> pd.DataFrame:
"""
新浪财经-中金所-中证 1000 指数-指定合约-日频行情
:param symbol: 具体合约代码(包括看涨和看跌标识), 可以通过 ak.option_cffex_zz1000_spot_sina 中的 call-标识 获取
:type symbol: str
:return: 日频率数据
:rtype: pd.DataFrame
"""
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L349-L386
| 25 |
[
0
] | 2.631579 |
[
10,
11,
12,
13,
14,
15,
16,
17,
20,
21,
31,
32,
33,
34,
35,
36,
37
] | 44.736842 | false | 8.469055 | 38 | 1 | 55.263158 | 5 |
def option_cffex_zz1000_daily_sina(
symbol: str = "mo2208P6200",
) -> pd.DataFrame:
year = datetime.datetime.now().year
month = datetime.datetime.now().month
day = datetime.datetime.now().day
url = f"https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_{symbol}{year}_{month}_{day}=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_df = pd.DataFrame(
eval(data_text[data_text.find("[") : data_text.rfind("]") + 1])
)
data_df.columns = ["open", "high", "low", "close", "volume", "date"]
data_df = data_df[
[
"date",
"open",
"high",
"low",
"close",
"volume",
]
]
data_df["date"] = pd.to_datetime(data_df["date"]).dt.date
data_df["open"] = pd.to_numeric(data_df["open"])
data_df["high"] = pd.to_numeric(data_df["high"])
data_df["low"] = pd.to_numeric(data_df["low"])
data_df["close"] = pd.to_numeric(data_df["close"])
data_df["volume"] = pd.to_numeric(data_df["volume"])
return data_df
| 17,962 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_list_sina
|
(
symbol: str = "50ETF", exchange: str = "null"
)
|
return ["".join(i.split("-")) for i in date_list][1:]
|
新浪财经-期权-上交所-50ETF-合约到期月份列表
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: 合约到期时间
:rtype: list
|
新浪财经-期权-上交所-50ETF-合约到期月份列表
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: 合约到期时间
:rtype: list
| 390 | 408 |
def option_sse_list_sina(
symbol: str = "50ETF", exchange: str = "null"
) -> List[str]:
"""
新浪财经-期权-上交所-50ETF-合约到期月份列表
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: 合约到期时间
:rtype: list
"""
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName"
params = {"exchange": f"{exchange}", "cate": f"{symbol}"}
r = requests.get(url, params=params)
data_json = r.json()
date_list = data_json["result"]["data"]["contractMonth"]
return ["".join(i.split("-")) for i in date_list][1:]
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L390-L408
| 25 |
[
0
] | 5.263158 |
[
13,
14,
15,
16,
17,
18
] | 31.578947 | false | 8.469055 | 19 | 2 | 68.421053 | 8 |
def option_sse_list_sina(
symbol: str = "50ETF", exchange: str = "null"
) -> List[str]:
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getStockName"
params = {"exchange": f"{exchange}", "cate": f"{symbol}"}
r = requests.get(url, params=params)
data_json = r.json()
date_list = data_json["result"]["data"]["contractMonth"]
return ["".join(i.split("-")) for i in date_list][1:]
| 17,963 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_expire_day_sina
|
(
trade_date: str = "202102", symbol: str = "50ETF", exchange: str = "null"
)
|
return data["expireDay"], int(data["remainderDays"])
|
指定到期月份指定品种的剩余到期时间
:param trade_date: 到期月份: 202002, 20203, 20206, 20209
:type trade_date: str
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: (到期时间, 剩余时间)
:rtype: tuple
|
指定到期月份指定品种的剩余到期时间
:param trade_date: 到期月份: 202002, 20203, 20206, 20209
:type trade_date: str
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: (到期时间, 剩余时间)
:rtype: tuple
| 411 | 444 |
def option_sse_expire_day_sina(
trade_date: str = "202102", symbol: str = "50ETF", exchange: str = "null"
) -> Tuple[str, int]:
"""
指定到期月份指定品种的剩余到期时间
:param trade_date: 到期月份: 202002, 20203, 20206, 20209
:type trade_date: str
:param symbol: 50ETF or 300ETF
:type symbol: str
:param exchange: null
:type exchange: str
:return: (到期时间, 剩余时间)
:rtype: tuple
"""
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay"
params = {
"exchange": f"{exchange}",
"cate": f"{symbol}",
"date": f"{trade_date[:4]}-{trade_date[4:]}",
}
r = requests.get(url, params=params)
data_json = r.json()
data = data_json["result"]["data"]
if int(data["remainderDays"]) < 0:
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay"
params = {
"exchange": f"{exchange}",
"cate": f"{'XD' + symbol}",
"date": f"{trade_date[:4]}-{trade_date[4:]}",
}
r = requests.get(url, params=params)
data_json = r.json()
data = data_json["result"]["data"]
return data["expireDay"], int(data["remainderDays"])
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L411-L444
| 25 |
[
0
] | 2.941176 |
[
14,
15,
20,
21,
22,
23,
24,
25,
30,
31,
32,
33
] | 35.294118 | false | 8.469055 | 34 | 2 | 64.705882 | 9 |
def option_sse_expire_day_sina(
trade_date: str = "202102", symbol: str = "50ETF", exchange: str = "null"
) -> Tuple[str, int]:
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay"
params = {
"exchange": f"{exchange}",
"cate": f"{symbol}",
"date": f"{trade_date[:4]}-{trade_date[4:]}",
}
r = requests.get(url, params=params)
data_json = r.json()
data = data_json["result"]["data"]
if int(data["remainderDays"]) < 0:
url = "http://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionService.getRemainderDay"
params = {
"exchange": f"{exchange}",
"cate": f"{'XD' + symbol}",
"date": f"{trade_date[:4]}-{trade_date[4:]}",
}
r = requests.get(url, params=params)
data_json = r.json()
data = data_json["result"]["data"]
return data["expireDay"], int(data["remainderDays"])
| 17,964 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_codes_sina
|
(
symbol: str = "看涨期权",
trade_date: str = "202202",
underlying: str = "510050",
)
|
return temp_df
|
上海证券交易所-所有看涨和看跌合约的代码
:param symbol: choice of {"看涨期权", "看跌期权"}
:type symbol: str
:param trade_date: 期权到期月份
:type trade_date: "202002"
:param underlying: 标的产品代码 华夏上证 50ETF: 510050 or 华泰柏瑞沪深 300ETF: 510300
:type underlying: str
:return: 看涨看跌合约的代码
:rtype: Tuple[List, List]
|
上海证券交易所-所有看涨和看跌合约的代码
| 447 | 508 |
def option_sse_codes_sina(
symbol: str = "看涨期权",
trade_date: str = "202202",
underlying: str = "510050",
) -> pd.DataFrame:
"""
上海证券交易所-所有看涨和看跌合约的代码
:param symbol: choice of {"看涨期权", "看跌期权"}
:type symbol: str
:param trade_date: 期权到期月份
:type trade_date: "202002"
:param underlying: 标的产品代码 华夏上证 50ETF: 510050 or 华泰柏瑞沪深 300ETF: 510300
:type underlying: str
:return: 看涨看跌合约的代码
:rtype: Tuple[List, List]
"""
if symbol == "看涨期权":
url = "".join(
[
"http://hq.sinajs.cn/list=OP_UP_",
underlying,
str(trade_date)[-4:],
]
)
else:
url = "".join(
[
"http://hq.sinajs.cn/list=OP_DOWN_",
underlying,
str(trade_date)[-4:],
]
)
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Referer": "https://stock.finance.sina.com.cn/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "script",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_temp = data_text.replace('"', ",").split(",")
temp_list = [i[7:] for i in data_temp if i.startswith("CON_OP_")]
temp_df = pd.DataFrame(temp_list)
temp_df.reset_index(inplace=True)
temp_df["index"] = temp_df.index + 1
temp_df.columns = [
"序号",
"期权代码",
]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L447-L508
| 25 |
[
0
] | 1.612903 |
[
17,
18,
26,
33,
50,
51,
52,
53,
54,
55,
56,
57,
61
] | 20.967742 | false | 8.469055 | 62 | 3 | 79.032258 | 10 |
def option_sse_codes_sina(
symbol: str = "看涨期权",
trade_date: str = "202202",
underlying: str = "510050",
) -> pd.DataFrame:
if symbol == "看涨期权":
url = "".join(
[
"http://hq.sinajs.cn/list=OP_UP_",
underlying,
str(trade_date)[-4:],
]
)
else:
url = "".join(
[
"http://hq.sinajs.cn/list=OP_DOWN_",
underlying,
str(trade_date)[-4:],
]
)
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Referer": "https://stock.finance.sina.com.cn/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "script",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_temp = data_text.replace('"', ",").split(",")
temp_list = [i[7:] for i in data_temp if i.startswith("CON_OP_")]
temp_df = pd.DataFrame(temp_list)
temp_df.reset_index(inplace=True)
temp_df["index"] = temp_df.index + 1
temp_df.columns = [
"序号",
"期权代码",
]
return temp_df
| 17,965 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_spot_price_sina
|
(symbol: str = "10003720")
|
return data_df
|
新浪财经-期权-期权实时数据
:param symbol: 期权代码
:type symbol: str
:return: 期权量价数据
:rtype: pandas.DataFrame
|
新浪财经-期权-期权实时数据
:param symbol: 期权代码
:type symbol: str
:return: 期权量价数据
:rtype: pandas.DataFrame
| 511 | 590 |
def option_sse_spot_price_sina(symbol: str = "10003720") -> pd.DataFrame:
"""
新浪财经-期权-期权实时数据
:param symbol: 期权代码
:type symbol: str
:return: 期权量价数据
:rtype: pandas.DataFrame
"""
url = f"http://hq.sinajs.cn/list=CON_OP_{symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Referer": "https://stock.finance.sina.com.cn/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "script",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"买量",
"买价",
"最新价",
"卖价",
"卖量",
"持仓量",
"涨幅",
"行权价",
"昨收价",
"开盘价",
"涨停价",
"跌停价",
"申卖价五",
"申卖量五",
"申卖价四",
"申卖量四",
"申卖价三",
"申卖量三",
"申卖价二",
"申卖量二",
"申卖价一",
"申卖量一",
"申买价一",
"申买量一 ",
"申买价二",
"申买量二",
"申买价三",
"申买量三",
"申买价四",
"申买量四",
"申买价五",
"申买量五",
"行情时间",
"主力合约标识",
"状态码",
"标的证券类型",
"标的股票",
"期权合约简称",
"振幅",
"最高价",
"最低价",
"成交量",
"成交额",
]
data_df = pd.DataFrame(
list(zip(field_list, data_list)), columns=["字段", "值"]
)
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L511-L590
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 10 |
[
8,
9,
26,
27,
28,
31,
76,
79
] | 10 | false | 8.469055 | 80 | 1 | 90 | 5 |
def option_sse_spot_price_sina(symbol: str = "10003720") -> pd.DataFrame:
url = f"http://hq.sinajs.cn/list=CON_OP_{symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Referer": "https://stock.finance.sina.com.cn/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"Sec-Fetch-Dest": "script",
"Sec-Fetch-Mode": "no-cors",
"Sec-Fetch-Site": "cross-site",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"买量",
"买价",
"最新价",
"卖价",
"卖量",
"持仓量",
"涨幅",
"行权价",
"昨收价",
"开盘价",
"涨停价",
"跌停价",
"申卖价五",
"申卖量五",
"申卖价四",
"申卖量四",
"申卖价三",
"申卖量三",
"申卖价二",
"申卖量二",
"申卖价一",
"申卖量一",
"申买价一",
"申买量一 ",
"申买价二",
"申买量二",
"申买价三",
"申买量三",
"申买价四",
"申买量四",
"申买价五",
"申买量五",
"行情时间",
"主力合约标识",
"状态码",
"标的证券类型",
"标的股票",
"期权合约简称",
"振幅",
"最高价",
"最低价",
"成交量",
"成交额",
]
data_df = pd.DataFrame(
list(zip(field_list, data_list)), columns=["字段", "值"]
)
return data_df
| 17,966 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_underlying_spot_price_sina
|
(
symbol: str = "sh510300",
)
|
return data_df
|
期权标的物的实时数据
:param symbol: sh510050 or sh510300
:type symbol: str
:return: 期权标的物的信息
:rtype: pandas.DataFrame
|
期权标的物的实时数据
:param symbol: sh510050 or sh510300
:type symbol: str
:return: 期权标的物的信息
:rtype: pandas.DataFrame
| 593 | 658 |
def option_sse_underlying_spot_price_sina(
symbol: str = "sh510300",
) -> pd.DataFrame:
"""
期权标的物的实时数据
:param symbol: sh510050 or sh510300
:type symbol: str
:return: 期权标的物的信息
:rtype: pandas.DataFrame
"""
url = f"http://hq.sinajs.cn/list={symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Proxy-Connection": "keep-alive",
"Referer": "http://vip.stock.finance.sina.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"证券简称",
"今日开盘价",
"昨日收盘价",
"最近成交价",
"最高成交价",
"最低成交价",
"买入价",
"卖出价",
"成交数量",
"成交金额",
"买数量一",
"买价位一",
"买数量二",
"买价位二",
"买数量三",
"买价位三",
"买数量四",
"买价位四",
"买数量五",
"买价位五",
"卖数量一",
"卖价位一",
"卖数量二",
"卖价位二",
"卖数量三",
"卖价位三",
"卖数量四",
"卖价位四",
"卖数量五",
"卖价位五",
"行情日期",
"行情时间",
"停牌状态",
]
data_df = pd.DataFrame(
list(zip(field_list, data_list)), columns=["字段", "值"]
)
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L593-L658
| 25 |
[
0
] | 1.515152 |
[
10,
11,
22,
23,
24,
27,
62,
65
] | 12.121212 | false | 8.469055 | 66 | 1 | 87.878788 | 5 |
def option_sse_underlying_spot_price_sina(
symbol: str = "sh510300",
) -> pd.DataFrame:
url = f"http://hq.sinajs.cn/list={symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Proxy-Connection": "keep-alive",
"Referer": "http://vip.stock.finance.sina.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"证券简称",
"今日开盘价",
"昨日收盘价",
"最近成交价",
"最高成交价",
"最低成交价",
"买入价",
"卖出价",
"成交数量",
"成交金额",
"买数量一",
"买价位一",
"买数量二",
"买价位二",
"买数量三",
"买价位三",
"买数量四",
"买价位四",
"买数量五",
"买价位五",
"卖数量一",
"卖价位一",
"卖数量二",
"卖价位二",
"卖数量三",
"卖价位三",
"卖数量四",
"卖价位四",
"卖数量五",
"卖价位五",
"行情日期",
"行情时间",
"停牌状态",
]
data_df = pd.DataFrame(
list(zip(field_list, data_list)), columns=["字段", "值"]
)
return data_df
| 17,967 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_greeks_sina
|
(symbol: str = "10003045")
|
return data_df
|
期权基本信息表
:param symbol: 合约代码
:type symbol: str
:return: 期权基本信息表
:rtype: pandas.DataFrame
|
期权基本信息表
:param symbol: 合约代码
:type symbol: str
:return: 期权基本信息表
:rtype: pandas.DataFrame
| 661 | 705 |
def option_sse_greeks_sina(symbol: str = "10003045") -> pd.DataFrame:
"""
期权基本信息表
:param symbol: 合约代码
:type symbol: str
:return: 期权基本信息表
:rtype: pandas.DataFrame
"""
url = f"http://hq.sinajs.cn/list=CON_SO_{symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Proxy-Connection": "keep-alive",
"Referer": "http://vip.stock.finance.sina.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"期权合约简称",
"成交量",
"Delta",
"Gamma",
"Theta",
"Vega",
"隐含波动率",
"最高价",
"最低价",
"交易代码",
"行权价",
"最新价",
"理论价值",
]
data_df = pd.DataFrame(
list(zip(field_list, [data_list[0]] + data_list[4:])),
columns=["字段", "值"],
)
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L661-L705
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 17.777778 |
[
8,
9,
20,
21,
22,
25,
40,
44
] | 17.777778 | false | 8.469055 | 45 | 1 | 82.222222 | 5 |
def option_sse_greeks_sina(symbol: str = "10003045") -> pd.DataFrame:
url = f"http://hq.sinajs.cn/list=CON_SO_{symbol}"
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Host": "hq.sinajs.cn",
"Pragma": "no-cache",
"Proxy-Connection": "keep-alive",
"Referer": "http://vip.stock.finance.sina.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, headers=headers)
data_text = r.text
data_list = data_text[
data_text.find('"') + 1 : data_text.rfind('"')
].split(",")
field_list = [
"期权合约简称",
"成交量",
"Delta",
"Gamma",
"Theta",
"Vega",
"隐含波动率",
"最高价",
"最低价",
"交易代码",
"行权价",
"最新价",
"理论价值",
]
data_df = pd.DataFrame(
list(zip(field_list, [data_list[0]] + data_list[4:])),
columns=["字段", "值"],
)
return data_df
| 17,968 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_minute_sina
|
(symbol: str = "10003720")
|
return data_df
|
指定期权品种在当前交易日的分钟数据, 只能获取当前交易日的数据, 不能获取历史分钟数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的当前交易日的分钟数据
:rtype: pandas.DataFrame
|
指定期权品种在当前交易日的分钟数据, 只能获取当前交易日的数据, 不能获取历史分钟数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的当前交易日的分钟数据
:rtype: pandas.DataFrame
| 708 | 746 |
def option_sse_minute_sina(symbol: str = "10003720") -> pd.DataFrame:
"""
指定期权品种在当前交易日的分钟数据, 只能获取当前交易日的数据, 不能获取历史分钟数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的当前交易日的分钟数据
:rtype: pandas.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline"
params = {"symbol": f"CON_OP_{symbol}"}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = data_json["result"]["data"]
data_df = pd.DataFrame(temp_df)
data_df.columns = ["时间", "价格", "成交", "持仓", "均价", "日期"]
data_df = data_df[["日期", "时间", "价格", "成交", "持仓", "均价"]]
data_df["日期"] = pd.to_datetime(data_df["日期"]).dt.date
data_df["日期"].ffill(inplace=True)
data_df["价格"] = pd.to_numeric(data_df["价格"])
data_df["成交"] = pd.to_numeric(data_df["成交"])
data_df["持仓"] = pd.to_numeric(data_df["持仓"])
data_df["均价"] = pd.to_numeric(data_df["均价"])
return data_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L708-L746
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 23.076923 |
[
9,
10,
11,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38
] | 41.025641 | false | 8.469055 | 39 | 1 | 58.974359 | 6 |
def option_sse_minute_sina(symbol: str = "10003720") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getOptionMinline"
params = {"symbol": f"CON_OP_{symbol}"}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = data_json["result"]["data"]
data_df = pd.DataFrame(temp_df)
data_df.columns = ["时间", "价格", "成交", "持仓", "均价", "日期"]
data_df = data_df[["日期", "时间", "价格", "成交", "持仓", "均价"]]
data_df["日期"] = pd.to_datetime(data_df["日期"]).dt.date
data_df["日期"].ffill(inplace=True)
data_df["价格"] = pd.to_numeric(data_df["价格"])
data_df["成交"] = pd.to_numeric(data_df["成交"])
data_df["持仓"] = pd.to_numeric(data_df["持仓"])
data_df["均价"] = pd.to_numeric(data_df["均价"])
return data_df
| 17,969 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_sse_daily_sina
|
(symbol: str = "10003889")
|
return temp_df
|
指定期权的日频率数据
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的所有日频率历史数据
:rtype: pandas.DataFrame
|
指定期权的日频率数据
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的所有日频率历史数据
:rtype: pandas.DataFrame
| 749 | 787 |
def option_sse_daily_sina(symbol: str = "10003889") -> pd.DataFrame:
"""
指定期权的日频率数据
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的所有日频率历史数据
:rtype: pandas.DataFrame
"""
url = "http://stock.finance.sina.com.cn/futures/api/jsonp_v2.php//StockOptionDaylineService.getSymbolInfo"
params = {"symbol": f"CON_OP_{symbol}"}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("(") + 1 : data_text.rfind(")")]
)
temp_df = pd.DataFrame(data_json)
temp_df.columns = ["日期", "开盘", "最高", "最低", "收盘", "成交量"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["开盘"] = pd.to_numeric(temp_df["开盘"])
temp_df["最高"] = pd.to_numeric(temp_df["最高"])
temp_df["最低"] = pd.to_numeric(temp_df["最低"])
temp_df["收盘"] = pd.to_numeric(temp_df["收盘"])
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L749-L787
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 20.512821 |
[
8,
9,
10,
25,
26,
27,
30,
31,
32,
33,
34,
35,
36,
37,
38
] | 38.461538 | false | 8.469055 | 39 | 1 | 61.538462 | 5 |
def option_sse_daily_sina(symbol: str = "10003889") -> pd.DataFrame:
url = "http://stock.finance.sina.com.cn/futures/api/jsonp_v2.php//StockOptionDaylineService.getSymbolInfo"
params = {"symbol": f"CON_OP_{symbol}"}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_text = r.text
data_json = json.loads(
data_text[data_text.find("(") + 1 : data_text.rfind(")")]
)
temp_df = pd.DataFrame(data_json)
temp_df.columns = ["日期", "开盘", "最高", "最低", "收盘", "成交量"]
temp_df["日期"] = pd.to_datetime(temp_df["日期"]).dt.date
temp_df["开盘"] = pd.to_numeric(temp_df["开盘"])
temp_df["最高"] = pd.to_numeric(temp_df["最高"])
temp_df["最低"] = pd.to_numeric(temp_df["最低"])
temp_df["收盘"] = pd.to_numeric(temp_df["收盘"])
temp_df["成交量"] = pd.to_numeric(temp_df["成交量"])
return temp_df
| 17,970 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance_sina.py
|
option_finance_minute_sina
|
(symbol: str = "10002530")
|
return temp_df
|
指定期权的分钟频率数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的分钟频率数据
:rtype: pandas.DataFrame
|
指定期权的分钟频率数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的分钟频率数据
:rtype: pandas.DataFrame
| 790 | 829 |
def option_finance_minute_sina(symbol: str = "10002530") -> pd.DataFrame:
"""
指定期权的分钟频率数据
https://stock.finance.sina.com.cn/option/quotes.html
:param symbol: 期权代码
:type symbol: str
:return: 指定期权的分钟频率数据
:rtype: pandas.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine"
params = {
"symbol": f"CON_OP_{symbol}",
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_text = r.json()
temp_df = pd.DataFrame()
for item in data_text["result"]["data"]:
temp_df = pd.concat([temp_df, pd.DataFrame(item)], ignore_index=True)
temp_df.fillna(method="ffill", inplace=True)
temp_df.columns = ["time", "price", "volume", "_", "average_price", "date"]
temp_df = temp_df[["date", "time", "price", "average_price", "volume"]]
temp_df["price"] = pd.to_numeric(temp_df["price"])
temp_df["average_price"] = pd.to_numeric(temp_df["average_price"])
temp_df["volume"] = pd.to_numeric(temp_df["volume"])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance_sina.py#L790-L829
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 22.5 |
[
9,
10,
13,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39
] | 37.5 | false | 8.469055 | 40 | 2 | 62.5 | 6 |
def option_finance_minute_sina(symbol: str = "10002530") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/StockOptionDaylineService.getFiveDayLine"
params = {
"symbol": f"CON_OP_{symbol}",
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"pragma": "no-cache",
"referer": "https://stock.finance.sina.com.cn/option/quotes.html",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"',
"sec-ch-ua-mobile": "?0",
"sec-ch-ua-platform": '"Windows"',
"sec-fetch-dest": "script",
"sec-fetch-mode": "no-cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/97.0.4692.71 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_text = r.json()
temp_df = pd.DataFrame()
for item in data_text["result"]["data"]:
temp_df = pd.concat([temp_df, pd.DataFrame(item)], ignore_index=True)
temp_df.fillna(method="ffill", inplace=True)
temp_df.columns = ["time", "price", "volume", "_", "average_price", "date"]
temp_df = temp_df[["date", "time", "price", "average_price", "volume"]]
temp_df["price"] = pd.to_numeric(temp_df["price"])
temp_df["average_price"] = pd.to_numeric(temp_df["average_price"])
temp_df["volume"] = pd.to_numeric(temp_df["volume"])
return temp_df
| 17,971 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance.py
|
option_finance_underlying
|
(symbol: str = "50ETF")
|
期权标的当日行情, 目前只有 华夏上证 50 ETF, 华泰柏瑞沪深 300 ETF 两个产品
http://www.sse.com.cn/assortment/options/price/
:param symbol: 50ETF 或 300ETF
:type symbol: str
:return: 期权标的当日行情
:rtype: pandas.DataFrame
|
期权标的当日行情, 目前只有 华夏上证 50 ETF, 华泰柏瑞沪深 300 ETF 两个产品
http://www.sse.com.cn/assortment/options/price/
:param symbol: 50ETF 或 300ETF
:type symbol: str
:return: 期权标的当日行情
:rtype: pandas.DataFrame
| 22 | 72 |
def option_finance_underlying(symbol: str = "50ETF") -> pd.DataFrame:
"""
期权标的当日行情, 目前只有 华夏上证 50 ETF, 华泰柏瑞沪深 300 ETF 两个产品
http://www.sse.com.cn/assortment/options/price/
:param symbol: 50ETF 或 300ETF
:type symbol: str
:return: 期权标的当日行情
:rtype: pandas.DataFrame
"""
if symbol == "50ETF":
res = requests.get(SH_OPTION_URL_50, params=SH_OPTION_PAYLOAD)
data_json = res.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.at[0, 0] = "510050"
raw_data.at[0, 8] = pd.to_datetime(
str(data_json["date"]) + str(data_json["time"]),
format="%Y%m%d%H%M%S",
)
raw_data.columns = [
"代码",
"名称",
"当前价",
"涨跌",
"涨跌幅",
"振幅",
"成交量(手)",
"成交额(万元)",
"更新日期",
]
return raw_data
else:
res = requests.get(SH_OPTION_URL_300, params=SH_OPTION_PAYLOAD)
data_json = res.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.at[0, 0] = "510300"
raw_data.at[0, 8] = pd.to_datetime(
str(data_json["date"]) + str(data_json["time"]),
format="%Y%m%d%H%M%S",
)
raw_data.columns = [
"代码",
"名称",
"当前价",
"涨跌",
"涨跌幅",
"振幅",
"成交量(手)",
"成交额(万元)",
"更新日期",
]
return raw_data
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance.py#L22-L72
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 17.647059 |
[
9,
10,
11,
12,
13,
14,
18,
29,
31,
32,
33,
34,
35,
39,
50
] | 29.411765 | false | 7.777778 | 51 | 2 | 70.588235 | 6 |
def option_finance_underlying(symbol: str = "50ETF") -> pd.DataFrame:
if symbol == "50ETF":
res = requests.get(SH_OPTION_URL_50, params=SH_OPTION_PAYLOAD)
data_json = res.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.at[0, 0] = "510050"
raw_data.at[0, 8] = pd.to_datetime(
str(data_json["date"]) + str(data_json["time"]),
format="%Y%m%d%H%M%S",
)
raw_data.columns = [
"代码",
"名称",
"当前价",
"涨跌",
"涨跌幅",
"振幅",
"成交量(手)",
"成交额(万元)",
"更新日期",
]
return raw_data
else:
res = requests.get(SH_OPTION_URL_300, params=SH_OPTION_PAYLOAD)
data_json = res.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.at[0, 0] = "510300"
raw_data.at[0, 8] = pd.to_datetime(
str(data_json["date"]) + str(data_json["time"]),
format="%Y%m%d%H%M%S",
)
raw_data.columns = [
"代码",
"名称",
"当前价",
"涨跌",
"涨跌幅",
"振幅",
"成交量(手)",
"成交额(万元)",
"更新日期",
]
return raw_data
| 17,972 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_finance.py
|
option_finance_board
|
(
symbol: str = "嘉实沪深300ETF期权", end_month: str = "2212"
)
|
期权的当日具体的行情数据, 主要为三个: 华夏上证50ETF期权, 华泰柏瑞沪深300ETF期权, 嘉实沪深300ETF期权, 沪深300股指期权, 中证1000股指期权
http://www.sse.com.cn/assortment/options/price/
http://www.szse.cn/market/product/option/index.html
http://www.cffex.com.cn/hs300gzqq/
http://www.cffex.com.cn/zz1000gzqq/
:param symbol: choice of {"华夏上证50ETF期权", "华泰柏瑞沪深300ETF期权", "嘉实沪深300ETF期权", "沪深300股指期权", "中证1000股指期权"}
:type symbol: str
:param end_month: 2003; 2020年3月到期的期权
:type end_month: str
:return: 当日行情
:rtype: pandas.DataFrame
|
期权的当日具体的行情数据, 主要为三个: 华夏上证50ETF期权, 华泰柏瑞沪深300ETF期权, 嘉实沪深300ETF期权, 沪深300股指期权, 中证1000股指期权
http://www.sse.com.cn/assortment/options/price/
http://www.szse.cn/market/product/option/index.html
http://www.cffex.com.cn/hs300gzqq/
http://www.cffex.com.cn/zz1000gzqq/
:param symbol: choice of {"华夏上证50ETF期权", "华泰柏瑞沪深300ETF期权", "嘉实沪深300ETF期权", "沪深300股指期权", "中证1000股指期权"}
:type symbol: str
:param end_month: 2003; 2020年3月到期的期权
:type end_month: str
:return: 当日行情
:rtype: pandas.DataFrame
| 75 | 192 |
def option_finance_board(
symbol: str = "嘉实沪深300ETF期权", end_month: str = "2212"
) -> pd.DataFrame:
"""
期权的当日具体的行情数据, 主要为三个: 华夏上证50ETF期权, 华泰柏瑞沪深300ETF期权, 嘉实沪深300ETF期权, 沪深300股指期权, 中证1000股指期权
http://www.sse.com.cn/assortment/options/price/
http://www.szse.cn/market/product/option/index.html
http://www.cffex.com.cn/hs300gzqq/
http://www.cffex.com.cn/zz1000gzqq/
:param symbol: choice of {"华夏上证50ETF期权", "华泰柏瑞沪深300ETF期权", "嘉实沪深300ETF期权", "沪深300股指期权", "中证1000股指期权"}
:type symbol: str
:param end_month: 2003; 2020年3月到期的期权
:type end_month: str
:return: 当日行情
:rtype: pandas.DataFrame
"""
end_month = end_month[-2:]
if symbol == "华夏上证50ETF期权":
r = requests.get(
SH_OPTION_URL_KING_50.format(end_month),
params=SH_OPTION_PAYLOAD_OTHER,
)
data_json = r.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.index = [
str(data_json["date"]) + str(data_json["time"])
] * data_json["total"]
raw_data.columns = ["合约交易代码", "当前价", "涨跌幅", "前结价", "行权价"]
raw_data["数量"] = [data_json["total"]] * data_json["total"]
raw_data.reset_index(inplace=True)
raw_data.columns = ["日期", "合约交易代码", "当前价", "涨跌幅", "前结价", "行权价", "数量"]
return raw_data
elif symbol == "华泰柏瑞沪深300ETF期权":
r = requests.get(
SH_OPTION_URL_KING_300.format(end_month),
params=SH_OPTION_PAYLOAD_OTHER,
)
data_json = r.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.index = [
str(data_json["date"]) + str(data_json["time"])
] * data_json["total"]
raw_data.columns = ["合约交易代码", "当前价", "涨跌幅", "前结价", "行权价"]
raw_data["数量"] = [data_json["total"]] * data_json["total"]
raw_data.reset_index(inplace=True)
raw_data.columns = ["日期", "合约交易代码", "当前价", "涨跌幅", "前结价", "行权价", "数量"]
return raw_data
elif symbol == "嘉实沪深300ETF期权":
url = "http://www.szse.cn/api/report/ShowReport/data"
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "ysplbrb",
"TABKEY": "tab1",
"PAGENO": "1",
"random": "0.10642298535346595",
}
r = requests.get(url, params=params)
data_json = r.json()
page_num = data_json[0]["metadata"]["pagecount"]
big_df = pd.DataFrame()
for page in range(1, page_num + 1):
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "ysplbrb",
"TABKEY": "tab1",
"PAGENO": page,
"random": "0.10642298535346595",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json[0]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"合约编码",
"合约简称",
"标的名称",
"类型",
"行权价",
"合约单位",
"期权行权日",
"行权交收日",
]
big_df["期权行权日"] = pd.to_datetime(big_df["期权行权日"])
big_df["end_month"] = big_df["期权行权日"].dt.month.astype(str).str.zfill(2)
big_df = big_df[big_df["end_month"] == end_month]
del big_df["end_month"]
big_df.reset_index(inplace=True, drop=True)
return big_df
elif symbol == "沪深300股指期权":
raw_df = pd.read_table(CFFEX_OPTION_URL_300, sep=",")
raw_df["end_month"] = (
raw_df["instrument"]
.str.split("-", expand=True)
.iloc[:, 0]
.str.slice(
4,
)
)
raw_df = raw_df[raw_df["end_month"] == end_month]
del raw_df["end_month"]
raw_df.reset_index(inplace=True, drop=True)
return raw_df
elif symbol == "中证1000股指期权":
url = "http://www.cffex.com.cn/quote_MO.txt"
raw_df = pd.read_table(url, sep=",")
raw_df["end_month"] = (
raw_df["instrument"]
.str.split("-", expand=True)
.iloc[:, 0]
.str.slice(
4,
)
)
raw_df = raw_df[raw_df["end_month"] == end_month]
del raw_df["end_month"]
raw_df.reset_index(inplace=True, drop=True)
return raw_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_finance.py#L75-L192
| 25 |
[
0
] | 0.847458 |
[
16,
17,
18,
22,
23,
24,
27,
28,
29,
30,
31,
32,
33,
37,
38,
39,
42,
43,
44,
45,
46,
47,
48,
49,
56,
57,
58,
59,
60,
61,
68,
69,
70,
71,
73,
83,
84,
85,
86,
87,
88,
89,
90,
91,
99,
100,
101,
102,
103,
104,
105,
106,
114,
115,
116,
117
] | 47.457627 | false | 7.777778 | 118 | 7 | 52.542373 | 11 |
def option_finance_board(
symbol: str = "嘉实沪深300ETF期权", end_month: str = "2212"
) -> pd.DataFrame:
end_month = end_month[-2:]
if symbol == "华夏上证50ETF期权":
r = requests.get(
SH_OPTION_URL_KING_50.format(end_month),
params=SH_OPTION_PAYLOAD_OTHER,
)
data_json = r.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.index = [
str(data_json["date"]) + str(data_json["time"])
] * data_json["total"]
raw_data.columns = ["合约交易代码", "当前价", "涨跌幅", "前结价", "行权价"]
raw_data["数量"] = [data_json["total"]] * data_json["total"]
raw_data.reset_index(inplace=True)
raw_data.columns = ["日期", "合约交易代码", "当前价", "涨跌幅", "前结价", "行权价", "数量"]
return raw_data
elif symbol == "华泰柏瑞沪深300ETF期权":
r = requests.get(
SH_OPTION_URL_KING_300.format(end_month),
params=SH_OPTION_PAYLOAD_OTHER,
)
data_json = r.json()
raw_data = pd.DataFrame(data_json["list"])
raw_data.index = [
str(data_json["date"]) + str(data_json["time"])
] * data_json["total"]
raw_data.columns = ["合约交易代码", "当前价", "涨跌幅", "前结价", "行权价"]
raw_data["数量"] = [data_json["total"]] * data_json["total"]
raw_data.reset_index(inplace=True)
raw_data.columns = ["日期", "合约交易代码", "当前价", "涨跌幅", "前结价", "行权价", "数量"]
return raw_data
elif symbol == "嘉实沪深300ETF期权":
url = "http://www.szse.cn/api/report/ShowReport/data"
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "ysplbrb",
"TABKEY": "tab1",
"PAGENO": "1",
"random": "0.10642298535346595",
}
r = requests.get(url, params=params)
data_json = r.json()
page_num = data_json[0]["metadata"]["pagecount"]
big_df = pd.DataFrame()
for page in range(1, page_num + 1):
params = {
"SHOWTYPE": "JSON",
"CATALOGID": "ysplbrb",
"TABKEY": "tab1",
"PAGENO": page,
"random": "0.10642298535346595",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json[0]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"合约编码",
"合约简称",
"标的名称",
"类型",
"行权价",
"合约单位",
"期权行权日",
"行权交收日",
]
big_df["期权行权日"] = pd.to_datetime(big_df["期权行权日"])
big_df["end_month"] = big_df["期权行权日"].dt.month.astype(str).str.zfill(2)
big_df = big_df[big_df["end_month"] == end_month]
del big_df["end_month"]
big_df.reset_index(inplace=True, drop=True)
return big_df
elif symbol == "沪深300股指期权":
raw_df = pd.read_table(CFFEX_OPTION_URL_300, sep=",")
raw_df["end_month"] = (
raw_df["instrument"]
.str.split("-", expand=True)
.iloc[:, 0]
.str.slice(
4,
)
)
raw_df = raw_df[raw_df["end_month"] == end_month]
del raw_df["end_month"]
raw_df.reset_index(inplace=True, drop=True)
return raw_df
elif symbol == "中证1000股指期权":
url = "http://www.cffex.com.cn/quote_MO.txt"
raw_df = pd.read_table(url, sep=",")
raw_df["end_month"] = (
raw_df["instrument"]
.str.split("-", expand=True)
.iloc[:, 0]
.str.slice(
4,
)
)
raw_df = raw_df[raw_df["end_month"] == end_month]
del raw_df["end_month"]
raw_df.reset_index(inplace=True, drop=True)
return raw_df
| 17,973 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_risk_analysis_em.py
|
option_risk_analysis_em
|
()
|
return temp_df
|
东方财富网-数据中心-特色数据-期权风险分析
https://data.eastmoney.com/other/riskanal.html
:return: 期权风险分析
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-期权风险分析
https://data.eastmoney.com/other/riskanal.html
:return: 期权风险分析
:rtype: pandas.DataFrame
| 12 | 77 |
def option_risk_analysis_em() -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-期权风险分析
https://data.eastmoney.com/other/riskanal.html
:return: 期权风险分析
:rtype: pandas.DataFrame
"""
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f3',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f302,f303,f325,f326,f327,f329,f328,f301,f152,f154',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'涨跌幅',
'期权代码',
'-',
'期权名称',
'-',
'-',
'到期日',
'杠杆比率',
'实际杠杆比率',
'Delta',
'Gamma',
'Vega',
'Theta',
'Rho',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'涨跌幅',
'杠杆比率',
'实际杠杆比率',
'Delta',
'Gamma',
'Vega',
'Rho',
'Theta',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors="coerce")
temp_df['杠杆比率'] = pd.to_numeric(temp_df['杠杆比率'], errors="coerce")
temp_df['实际杠杆比率'] = pd.to_numeric(temp_df['实际杠杆比率'], errors="coerce")
temp_df['Delta'] = pd.to_numeric(temp_df['Delta'], errors="coerce")
temp_df['Gamma'] = pd.to_numeric(temp_df['Gamma'], errors="coerce")
temp_df['Vega'] = pd.to_numeric(temp_df['Vega'], errors="coerce")
temp_df['Rho'] = pd.to_numeric(temp_df['Rho'], errors="coerce")
temp_df['Theta'] = pd.to_numeric(temp_df['Theta'], errors="coerce")
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_risk_analysis_em.py#L12-L77
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 10.606061 |
[
7,
8,
20,
21,
22,
23,
41,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65
] | 27.272727 | false | 20 | 66 | 1 | 72.727273 | 4 |
def option_risk_analysis_em() -> pd.DataFrame:
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f3',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f302,f303,f325,f326,f327,f329,f328,f301,f152,f154',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'涨跌幅',
'期权代码',
'-',
'期权名称',
'-',
'-',
'到期日',
'杠杆比率',
'实际杠杆比率',
'Delta',
'Gamma',
'Vega',
'Theta',
'Rho',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'涨跌幅',
'杠杆比率',
'实际杠杆比率',
'Delta',
'Gamma',
'Vega',
'Rho',
'Theta',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors="coerce")
temp_df['杠杆比率'] = pd.to_numeric(temp_df['杠杆比率'], errors="coerce")
temp_df['实际杠杆比率'] = pd.to_numeric(temp_df['实际杠杆比率'], errors="coerce")
temp_df['Delta'] = pd.to_numeric(temp_df['Delta'], errors="coerce")
temp_df['Gamma'] = pd.to_numeric(temp_df['Gamma'], errors="coerce")
temp_df['Vega'] = pd.to_numeric(temp_df['Vega'], errors="coerce")
temp_df['Rho'] = pd.to_numeric(temp_df['Rho'], errors="coerce")
temp_df['Theta'] = pd.to_numeric(temp_df['Theta'], errors="coerce")
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
| 17,974 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_czce.py
|
option_czce_hist
|
(symbol: str = "SR", year: str = "2021")
|
return option_df
|
郑州商品交易所-交易数据-历史行情下载-期权历史行情下载
http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
:param symbol: choice of {"白糖": "SR", "棉花": "CF", "PTA": "TA", "甲醇": "MA", "菜籽粕": "RM", "动力煤": "ZC"}
:type symbol: str
:param year: 需要获取数据的年份, 注意品种的上市时间
:type year: str
:return: 指定年份的日频期权数据
:rtype: pandas.DataFrame
|
郑州商品交易所-交易数据-历史行情下载-期权历史行情下载
http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
:param symbol: choice of {"白糖": "SR", "棉花": "CF", "PTA": "TA", "甲醇": "MA", "菜籽粕": "RM", "动力煤": "ZC"}
:type symbol: str
:param year: 需要获取数据的年份, 注意品种的上市时间
:type year: str
:return: 指定年份的日频期权数据
:rtype: pandas.DataFrame
| 23 | 49 |
def option_czce_hist(symbol: str = "SR", year: str = "2021") -> pd.DataFrame:
"""
郑州商品交易所-交易数据-历史行情下载-期权历史行情下载
http://www.czce.com.cn/cn/jysj/lshqxz/H770319index_1.htm
:param symbol: choice of {"白糖": "SR", "棉花": "CF", "PTA": "TA", "甲醇": "MA", "菜籽粕": "RM", "动力煤": "ZC"}
:type symbol: str
:param year: 需要获取数据的年份, 注意品种的上市时间
:type year: str
:return: 指定年份的日频期权数据
:rtype: pandas.DataFrame
"""
symbol_year_dict = {
"SR": "2017",
"CF": "2019",
"TA": "2019",
"MA": "2019",
"RM": "2020",
"ZC": "2020",
}
if int(symbol_year_dict[symbol]) > int(year):
warnings.warn(f"{year} year, symbol {symbol} is not on trade")
return None
warnings.warn("正在下载中, 请稍等")
url = f'http://www.czce.com.cn/cn/DFSStaticFiles/Option/2021/OptionDataAllHistory/{symbol}OPTIONS{year}.txt'
r = requests.get(url)
option_df = pd.read_table(StringIO(r.text), skiprows=1, sep="|", low_memory=False)
return option_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_czce.py#L23-L49
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
] | 40.740741 |
[
11,
19,
20,
21,
22,
23,
24,
25,
26
] | 33.333333 | false | 38.888889 | 27 | 2 | 66.666667 | 8 |
def option_czce_hist(symbol: str = "SR", year: str = "2021") -> pd.DataFrame:
symbol_year_dict = {
"SR": "2017",
"CF": "2019",
"TA": "2019",
"MA": "2019",
"RM": "2020",
"ZC": "2020",
}
if int(symbol_year_dict[symbol]) > int(year):
warnings.warn(f"{year} year, symbol {symbol} is not on trade")
return None
warnings.warn("正在下载中, 请稍等")
url = f'http://www.czce.com.cn/cn/DFSStaticFiles/Option/2021/OptionDataAllHistory/{symbol}OPTIONS{year}.txt'
r = requests.get(url)
option_df = pd.read_table(StringIO(r.text), skiprows=1, sep="|", low_memory=False)
return option_df
| 17,975 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_qvix.py
|
option_50etf_qvix
|
()
|
return temp_df
|
50ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
|
50ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
| 13 | 30 |
def option_50etf_qvix() -> pd.DataFrame:
"""
50ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
"""
url = "http://1.optbbs.com/d/csv/d/k.csv"
temp_df = pd.read_csv(url).iloc[:, :5]
temp_df.columns = [
"date",
"open",
"high",
"low",
"close",
]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_qvix.py#L13-L30
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 38.888889 |
[
7,
8,
9,
16,
17
] | 27.777778 | false | 21.212121 | 18 | 1 | 72.222222 | 4 |
def option_50etf_qvix() -> pd.DataFrame:
url = "http://1.optbbs.com/d/csv/d/k.csv"
temp_df = pd.read_csv(url).iloc[:, :5]
temp_df.columns = [
"date",
"open",
"high",
"low",
"close",
]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
return temp_df
| 17,976 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_qvix.py
|
option_50etf_min_qvix
|
()
|
return temp_df
|
50 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
|
50 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
| 33 | 46 |
def option_50etf_min_qvix() -> pd.DataFrame:
"""
50 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?50ETF
:return: 50 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
"""
url = "http://1.optbbs.com/d/csv/d/vix50.csv"
temp_df = pd.read_csv(url).iloc[:, :2]
temp_df.columns = [
"time",
"qvix",
]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_qvix.py#L33-L46
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 50 |
[
7,
8,
9,
13
] | 28.571429 | false | 21.212121 | 14 | 1 | 71.428571 | 4 |
def option_50etf_min_qvix() -> pd.DataFrame:
url = "http://1.optbbs.com/d/csv/d/vix50.csv"
temp_df = pd.read_csv(url).iloc[:, :2]
temp_df.columns = [
"time",
"qvix",
]
return temp_df
| 17,977 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_qvix.py
|
option_300etf_qvix
|
()
|
return temp_df
|
300 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
|
300 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
| 49 | 66 |
def option_300etf_qvix() -> pd.DataFrame:
"""
300 ETF 期权波动率指数 QVIX
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX
:rtype: pandas.DataFrame
"""
url = "http://1.optbbs.com/d/csv/d/k.csv"
temp_df = pd.read_csv(url).iloc[:, [0, 9, 10, 11, 12]]
temp_df.columns = [
"date",
"open",
"high",
"low",
"close",
]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_qvix.py#L49-L66
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 38.888889 |
[
7,
8,
9,
16,
17
] | 27.777778 | false | 21.212121 | 18 | 1 | 72.222222 | 4 |
def option_300etf_qvix() -> pd.DataFrame:
url = "http://1.optbbs.com/d/csv/d/k.csv"
temp_df = pd.read_csv(url).iloc[:, [0, 9, 10, 11, 12]]
temp_df.columns = [
"date",
"open",
"high",
"low",
"close",
]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
return temp_df
| 17,978 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_qvix.py
|
option_300etf_min_qvix
|
()
|
return temp_df
|
300 ETF 期权波动率指数 QVIX-分时
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX-分时
:rtype: pandas.DataFrame
|
300 ETF 期权波动率指数 QVIX-分时
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX-分时
:rtype: pandas.DataFrame
| 69 | 82 |
def option_300etf_min_qvix() -> pd.DataFrame:
"""
300 ETF 期权波动率指数 QVIX-分时
http://1.optbbs.com/s/vix.shtml?300ETF
:return: 300 ETF 期权波动率指数 QVIX-分时
:rtype: pandas.DataFrame
"""
url = "http://1.optbbs.com/d/csv/d/vix300.csv"
temp_df = pd.read_csv(url).iloc[:, :2]
temp_df.columns = [
"time",
"qvix",
]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_qvix.py#L69-L82
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 50 |
[
7,
8,
9,
13
] | 28.571429 | false | 21.212121 | 14 | 1 | 71.428571 | 4 |
def option_300etf_min_qvix() -> pd.DataFrame:
url = "http://1.optbbs.com/d/csv/d/vix300.csv"
temp_df = pd.read_csv(url).iloc[:, :2]
temp_df.columns = [
"time",
"qvix",
]
return temp_df
| 17,979 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_risk_indicator_sse.py
|
option_risk_indicator_sse
|
(date: str = "20220516")
|
return temp_df
|
上海证券交易所-产品-股票期权-期权风险指标
http://www.sse.com.cn/assortment/options/risk/
:param date: 日期; 20150209 开始
:type date: str
:return: 期权风险指标
:rtype: pandas.DataFrame
|
上海证券交易所-产品-股票期权-期权风险指标
http://www.sse.com.cn/assortment/options/risk/
:param date: 日期; 20150209 开始
:type date: str
:return: 期权风险指标
:rtype: pandas.DataFrame
| 11 | 63 |
def option_risk_indicator_sse(date: str = "20220516") -> pd.DataFrame:
"""
上海证券交易所-产品-股票期权-期权风险指标
http://www.sse.com.cn/assortment/options/risk/
:param date: 日期; 20150209 开始
:type date: str
:return: 期权风险指标
:rtype: pandas.DataFrame
"""
url = "http://query.sse.com.cn/commonQuery.do"
params = {
"isPagination": "false",
"trade_date": date,
"sqlId": "SSE_ZQPZ_YSP_GGQQZSXT_YSHQ_QQFXZB_DATE_L",
"contractSymbol": "",
"_": "1652877575590",
}
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "query.sse.com.cn",
"Pragma": "no-cache",
"Referer": "http://www.sse.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"])
temp_df = temp_df[
[
"TRADE_DATE",
"SECURITY_ID",
"CONTRACT_ID",
"CONTRACT_SYMBOL",
"DELTA_VALUE",
"THETA_VALUE",
"GAMMA_VALUE",
"VEGA_VALUE",
"RHO_VALUE",
"IMPLC_VOLATLTY",
]
]
temp_df["TRADE_DATE"] = pd.to_datetime(temp_df["TRADE_DATE"]).dt.date
temp_df["DELTA_VALUE"] = pd.to_numeric(temp_df["DELTA_VALUE"])
temp_df["THETA_VALUE"] = pd.to_numeric(temp_df["THETA_VALUE"])
temp_df["GAMMA_VALUE"] = pd.to_numeric(temp_df["GAMMA_VALUE"])
temp_df["VEGA_VALUE"] = pd.to_numeric(temp_df["VEGA_VALUE"])
temp_df["RHO_VALUE"] = pd.to_numeric(temp_df["RHO_VALUE"])
temp_df["IMPLC_VOLATLTY"] = pd.to_numeric(temp_df["IMPLC_VOLATLTY"])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_risk_indicator_sse.py#L11-L63
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 16.981132 |
[
9,
10,
17,
28,
29,
30,
31,
45,
46,
47,
48,
49,
50,
51,
52
] | 28.301887 | false | 20.833333 | 53 | 1 | 71.698113 | 6 |
def option_risk_indicator_sse(date: str = "20220516") -> pd.DataFrame:
url = "http://query.sse.com.cn/commonQuery.do"
params = {
"isPagination": "false",
"trade_date": date,
"sqlId": "SSE_ZQPZ_YSP_GGQQZSXT_YSHQ_QQFXZB_DATE_L",
"contractSymbol": "",
"_": "1652877575590",
}
headers = {
"Accept": "*/*",
"Accept-Encoding": "gzip, deflate",
"Accept-Language": "zh-CN,zh;q=0.9,en;q=0.8",
"Cache-Control": "no-cache",
"Connection": "keep-alive",
"Host": "query.sse.com.cn",
"Pragma": "no-cache",
"Referer": "http://www.sse.com.cn/",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.67 Safari/537.36",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"])
temp_df = temp_df[
[
"TRADE_DATE",
"SECURITY_ID",
"CONTRACT_ID",
"CONTRACT_SYMBOL",
"DELTA_VALUE",
"THETA_VALUE",
"GAMMA_VALUE",
"VEGA_VALUE",
"RHO_VALUE",
"IMPLC_VOLATLTY",
]
]
temp_df["TRADE_DATE"] = pd.to_datetime(temp_df["TRADE_DATE"]).dt.date
temp_df["DELTA_VALUE"] = pd.to_numeric(temp_df["DELTA_VALUE"])
temp_df["THETA_VALUE"] = pd.to_numeric(temp_df["THETA_VALUE"])
temp_df["GAMMA_VALUE"] = pd.to_numeric(temp_df["GAMMA_VALUE"])
temp_df["VEGA_VALUE"] = pd.to_numeric(temp_df["VEGA_VALUE"])
temp_df["RHO_VALUE"] = pd.to_numeric(temp_df["RHO_VALUE"])
temp_df["IMPLC_VOLATLTY"] = pd.to_numeric(temp_df["IMPLC_VOLATLTY"])
return temp_df
| 17,980 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/cons.py
|
convert_date
|
(date)
|
return None
|
transform a date string to datetime.date object
:param date, string, e.g. 2016-01-01, 20160101 or 2016/01/01
:return: object of datetime.date(such as 2016-01-01) or None
|
transform a date string to datetime.date object
:param date, string, e.g. 2016-01-01, 20160101 or 2016/01/01
:return: object of datetime.date(such as 2016-01-01) or None
| 52 | 70 |
def convert_date(date):
"""
transform a date string to datetime.date object
:param date, string, e.g. 2016-01-01, 20160101 or 2016/01/01
:return: object of datetime.date(such as 2016-01-01) or None
"""
if isinstance(date, datetime.date):
return date
elif isinstance(date, str):
match = DATE_PATTERN.match(date)
if match:
groups = match.groups()
if len(groups) == 3:
return datetime.date(
year=int(
groups[0]), month=int(
groups[1]), day=int(
groups[2]))
return None
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/cons.py#L52-L70
| 25 |
[
0,
1,
2,
3,
4,
5
] | 31.578947 |
[
6,
7,
8,
9,
10,
11,
12,
13,
18
] | 47.368421 | false | 37.313433 | 19 | 5 | 52.631579 | 3 |
def convert_date(date):
if isinstance(date, datetime.date):
return date
elif isinstance(date, str):
match = DATE_PATTERN.match(date)
if match:
groups = match.groups()
if len(groups) == 3:
return datetime.date(
year=int(
groups[0]), month=int(
groups[1]), day=int(
groups[2]))
return None
| 17,981 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/cons.py
|
get_json_path
|
(name, module_file)
|
return module_json_path
|
获取 JSON 配置文件的路径(从模块所在目录查找)
:param name: 文件名
:param module_file: filename
:return: str json_file_path
|
获取 JSON 配置文件的路径(从模块所在目录查找)
:param name: 文件名
:param module_file: filename
:return: str json_file_path
| 73 | 82 |
def get_json_path(name, module_file):
"""
获取 JSON 配置文件的路径(从模块所在目录查找)
:param name: 文件名
:param module_file: filename
:return: str json_file_path
"""
module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file)))
module_json_path = os.path.join(module_folder, "file_fold", name)
return module_json_path
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/cons.py#L73-L82
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 70 |
[
7,
8,
9
] | 30 | false | 37.313433 | 10 | 1 | 70 | 4 |
def get_json_path(name, module_file):
module_folder = os.path.abspath(os.path.dirname(os.path.dirname(module_file)))
module_json_path = os.path.join(module_folder, "file_fold", name)
return module_json_path
| 17,982 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/cons.py
|
get_calendar
|
()
|
return json.load(open(setting_file_path, "r"))
|
获取交易日历至 2019 年结束, 这里的交易日历需要按年更新
:return: json
|
获取交易日历至 2019 年结束, 这里的交易日历需要按年更新
:return: json
| 85 | 92 |
def get_calendar():
"""
获取交易日历至 2019 年结束, 这里的交易日历需要按年更新
:return: json
"""
setting_file_name = "calendar.json"
setting_file_path = get_json_path(setting_file_name, __file__)
return json.load(open(setting_file_path, "r"))
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/cons.py#L85-L92
| 25 |
[
0,
1,
2,
3,
4
] | 62.5 |
[
5,
6,
7
] | 37.5 | false | 37.313433 | 8 | 1 | 62.5 | 2 |
def get_calendar():
setting_file_name = "calendar.json"
setting_file_path = get_json_path(setting_file_name, __file__)
return json.load(open(setting_file_path, "r"))
| 17,983 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/cons.py
|
last_trading_day
|
(day)
|
获取前一个交易日
:param day: "%Y%m%d" or datetime.date()
:return last_day: "%Y%m%d" or datetime.date()
|
获取前一个交易日
:param day: "%Y%m%d" or datetime.date()
:return last_day: "%Y%m%d" or datetime.date()
| 95 | 119 |
def last_trading_day(day):
"""
获取前一个交易日
:param day: "%Y%m%d" or datetime.date()
:return last_day: "%Y%m%d" or datetime.date()
"""
calendar = get_calendar()
if isinstance(day, str):
if day not in calendar:
print("Today is not trading day:" + day)
return False
pos = calendar.index(day)
last_day = calendar[pos - 1]
return last_day
elif isinstance(day, datetime.date):
d_str = day.strftime("%Y%m%d")
if d_str not in calendar:
print("Today is not working day:" + d_str)
return False
pos = calendar.index(d_str)
last_day = calendar[pos - 1]
last_day = datetime.datetime.strptime(last_day, "%Y%m%d").date()
return last_day
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/cons.py#L95-L119
| 25 |
[
0,
1,
2,
3,
4,
5
] | 24 |
[
6,
8,
9,
10,
11,
12,
13,
14,
16,
17,
18,
19,
20,
21,
22,
23,
24
] | 68 | false | 37.313433 | 25 | 5 | 32 | 3 |
def last_trading_day(day):
calendar = get_calendar()
if isinstance(day, str):
if day not in calendar:
print("Today is not trading day:" + day)
return False
pos = calendar.index(day)
last_day = calendar[pos - 1]
return last_day
elif isinstance(day, datetime.date):
d_str = day.strftime("%Y%m%d")
if d_str not in calendar:
print("Today is not working day:" + d_str)
return False
pos = calendar.index(d_str)
last_day = calendar[pos - 1]
last_day = datetime.datetime.strptime(last_day, "%Y%m%d").date()
return last_day
| 17,984 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_premium_analysis_em.py
|
option_premium_analysis_em
|
()
|
return temp_df
|
东方财富网-数据中心-特色数据-期权折溢价
https://data.eastmoney.com/other/premium.html
:return: 期权折溢价
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-期权折溢价
https://data.eastmoney.com/other/premium.html
:return: 期权折溢价
:rtype: pandas.DataFrame
| 12 | 75 |
def option_premium_analysis_em() -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-期权折溢价
https://data.eastmoney.com/other/premium.html
:return: 期权折溢价
:rtype: pandas.DataFrame
"""
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f250',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f161,f250,f330,f331,f332,f333,f334,f335,f337,f301,f152',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'涨跌幅',
'期权代码',
'-',
'期权名称',
'-',
'行权价',
'折溢价率',
'到期日',
'-',
'-',
'-',
'标的名称',
'标的最新价',
'标的涨跌幅',
'盈亏平衡价',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'涨跌幅',
'行权价',
'折溢价率',
'标的名称',
'标的最新价',
'标的涨跌幅',
'盈亏平衡价',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors="coerce")
temp_df['行权价'] = pd.to_numeric(temp_df['行权价'], errors="coerce")
temp_df['折溢价率'] = pd.to_numeric(temp_df['折溢价率'], errors="coerce")
temp_df['标的最新价'] = pd.to_numeric(temp_df['标的最新价'], errors="coerce")
temp_df['标的涨跌幅'] = pd.to_numeric(temp_df['标的涨跌幅'], errors="coerce")
temp_df['盈亏平衡价'] = pd.to_numeric(temp_df['盈亏平衡价'], errors="coerce")
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_premium_analysis_em.py#L12-L75
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 10.9375 |
[
7,
8,
20,
21,
22,
23,
42,
55,
56,
57,
58,
59,
60,
61,
62,
63
] | 25 | false | 21.73913 | 64 | 1 | 75 | 4 |
def option_premium_analysis_em() -> pd.DataFrame:
url = "https://push2.eastmoney.com/api/qt/clist/get"
params = {
'fid': 'f250',
'po': '1',
'pz': '5000',
'pn': '1',
'np': '1',
'fltt': '2',
'invt': '2',
'ut': 'b2884a393a59ad64002292a3e90d46a5',
'fields': 'f1,f2,f3,f12,f13,f14,f161,f250,f330,f331,f332,f333,f334,f335,f337,f301,f152',
'fs': 'm:10'
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["diff"])
temp_df.columns = [
'-',
'最新价',
'涨跌幅',
'期权代码',
'-',
'期权名称',
'-',
'行权价',
'折溢价率',
'到期日',
'-',
'-',
'-',
'标的名称',
'标的最新价',
'标的涨跌幅',
'盈亏平衡价',
]
temp_df = temp_df[[
'期权代码',
'期权名称',
'最新价',
'涨跌幅',
'行权价',
'折溢价率',
'标的名称',
'标的最新价',
'标的涨跌幅',
'盈亏平衡价',
'到期日',
]]
temp_df['最新价'] = pd.to_numeric(temp_df['最新价'], errors="coerce")
temp_df['涨跌幅'] = pd.to_numeric(temp_df['涨跌幅'], errors="coerce")
temp_df['行权价'] = pd.to_numeric(temp_df['行权价'], errors="coerce")
temp_df['折溢价率'] = pd.to_numeric(temp_df['折溢价率'], errors="coerce")
temp_df['标的最新价'] = pd.to_numeric(temp_df['标的最新价'], errors="coerce")
temp_df['标的涨跌幅'] = pd.to_numeric(temp_df['标的涨跌幅'], errors="coerce")
temp_df['盈亏平衡价'] = pd.to_numeric(temp_df['盈亏平衡价'], errors="coerce")
temp_df['到期日'] = pd.to_datetime(temp_df['到期日'].astype(str)).dt.date
return temp_df
| 17,985 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity.py
|
option_dce_daily
|
(
symbol: str = "聚乙烯期权", trade_date: str = "20210728"
)
|
大连商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"玉米期权", "豆粕期权", "铁矿石期权", "液化石油气期权", "聚乙烯期权", "聚氯乙烯期权", "聚丙烯期权", "棕榈油期权", "黄大豆1号期权", "黄大豆2号期权", "豆油期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
|
大连商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"玉米期权", "豆粕期权", "铁矿石期权", "液化石油气期权", "聚乙烯期权", "聚氯乙烯期权", "聚丙烯期权", "棕榈油期权", "黄大豆1号期权", "黄大豆2号期权", "豆油期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
| 34 | 161 |
def option_dce_daily(
symbol: str = "聚乙烯期权", trade_date: str = "20210728"
) -> Tuple[Any, Any]:
"""
大连商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"玉米期权", "豆粕期权", "铁矿石期权", "液化石油气期权", "聚乙烯期权", "聚氯乙烯期权", "聚丙烯期权", "棕榈油期权", "黄大豆1号期权", "黄大豆2号期权", "豆油期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
"""
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("%s非交易日" % day.strftime("%Y%m%d"))
return
url = DCE_DAILY_OPTION_URL
payload = {
"dayQuotes.variety": "all",
"dayQuotes.trade_type": "1",
"year": str(day.year),
"month": str(day.month - 1),
"day": str(day.day),
"exportFlag": "excel",
}
res = requests.post(url, data=payload)
table_df = pd.read_excel(BytesIO(res.content), header=0)
another_df = table_df.iloc[
table_df[table_df.iloc[:, 0].str.contains("合约")].iloc[-1].name :,
[0, 1],
]
another_df.reset_index(inplace=True, drop=True)
another_df.iloc[0] = another_df.iat[0, 0].split("\t")
another_df.columns = another_df.iloc[0]
another_df = another_df.iloc[1:, :]
if symbol == "豆粕期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "豆粕"],
another_df[another_df.iloc[:, 0].str.contains("m")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "玉米期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "玉米"],
another_df[another_df.iloc[:, 0].str.contains("c")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "铁矿石期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "铁矿石"],
another_df[another_df.iloc[:, 0].str.contains("i")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "液化石油气期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "液化石油气"],
another_df[another_df.iloc[:, 0].str.contains("pg")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚乙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚乙烯"],
another_df[another_df.iloc[:, 0].str.contains("l")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚氯乙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚氯乙烯"],
another_df[another_df.iloc[:, 0].str.contains("v")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚丙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚丙烯"],
another_df[another_df.iloc[:, 0].str.contains("pp")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "棕榈油期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "棕榈油"],
another_df[another_df.iloc[:, 0].str.contains(r"^p\d")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "黄大豆1号期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "黄大豆1号"],
another_df[another_df.iloc[:, 0].str.contains("a")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "黄大豆2号期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "黄大豆2号"],
another_df[another_df.iloc[:, 0].str.contains("b")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "豆油期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "豆油"],
another_df[another_df.iloc[:, 0].str.contains("y")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity.py#L34-L161
| 25 |
[
0
] | 0.78125 |
[
12,
13,
18,
19,
20,
21,
22,
30,
31,
32,
36,
37,
38,
39,
40,
41,
45,
46,
47,
48,
49,
53,
54,
55,
56,
57,
61,
62,
63,
64,
65,
69,
70,
71,
72,
73,
77,
78,
79,
80,
81,
85,
86,
87,
88,
89,
93,
94,
95,
96,
97,
101,
102,
103,
104,
105,
109,
110,
111,
112,
113,
117,
118,
119,
120,
121,
125,
126,
127
] | 53.90625 | false | 7.692308 | 128 | 13 | 46.09375 | 7 |
def option_dce_daily(
symbol: str = "聚乙烯期权", trade_date: str = "20210728"
) -> Tuple[Any, Any]:
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("%s非交易日" % day.strftime("%Y%m%d"))
return
url = DCE_DAILY_OPTION_URL
payload = {
"dayQuotes.variety": "all",
"dayQuotes.trade_type": "1",
"year": str(day.year),
"month": str(day.month - 1),
"day": str(day.day),
"exportFlag": "excel",
}
res = requests.post(url, data=payload)
table_df = pd.read_excel(BytesIO(res.content), header=0)
another_df = table_df.iloc[
table_df[table_df.iloc[:, 0].str.contains("合约")].iloc[-1].name :,
[0, 1],
]
another_df.reset_index(inplace=True, drop=True)
another_df.iloc[0] = another_df.iat[0, 0].split("\t")
another_df.columns = another_df.iloc[0]
another_df = another_df.iloc[1:, :]
if symbol == "豆粕期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "豆粕"],
another_df[another_df.iloc[:, 0].str.contains("m")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "玉米期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "玉米"],
another_df[another_df.iloc[:, 0].str.contains("c")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "铁矿石期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "铁矿石"],
another_df[another_df.iloc[:, 0].str.contains("i")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "液化石油气期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "液化石油气"],
another_df[another_df.iloc[:, 0].str.contains("pg")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚乙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚乙烯"],
another_df[another_df.iloc[:, 0].str.contains("l")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚氯乙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚氯乙烯"],
another_df[another_df.iloc[:, 0].str.contains("v")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "聚丙烯期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "聚丙烯"],
another_df[another_df.iloc[:, 0].str.contains("pp")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "棕榈油期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "棕榈油"],
another_df[another_df.iloc[:, 0].str.contains(r"^p\d")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "黄大豆1号期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "黄大豆1号"],
another_df[another_df.iloc[:, 0].str.contains("a")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "黄大豆2号期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "黄大豆2号"],
another_df[another_df.iloc[:, 0].str.contains("b")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
elif symbol == "豆油期权":
result_one_df, result_two_df = (
table_df[table_df["商品名称"] == "豆油"],
another_df[another_df.iloc[:, 0].str.contains("y")],
)
result_one_df.reset_index(inplace=True, drop=True)
result_two_df.reset_index(inplace=True, drop=True)
return result_one_df, result_two_df
| 17,986 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity.py
|
option_czce_daily
|
(
symbol: str = "白糖期权", trade_date: str = "20191017"
)
|
郑州商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"白糖期权", "棉花期权", "甲醇期权", "PTA期权", "菜籽粕期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
|
郑州商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"白糖期权", "棉花期权", "甲醇期权", "PTA期权", "菜籽粕期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
| 164 | 226 |
def option_czce_daily(
symbol: str = "白糖期权", trade_date: str = "20191017"
) -> pd.DataFrame:
"""
郑州商品交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"白糖期权", "棉花期权", "甲醇期权", "PTA期权", "菜籽粕期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
"""
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("{}非交易日".format(day.strftime("%Y%m%d")))
return
if day > datetime.date(2010, 8, 24):
url = CZCE_DAILY_OPTION_URL_3.format(
day.strftime("%Y"), day.strftime("%Y%m%d")
)
try:
r = requests.get(url)
f = StringIO(r.text)
table_df = pd.read_table(f, encoding="utf-8", skiprows=1, sep="|")
if symbol == "白糖期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("SR")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "PTA期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("TA")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "甲醇期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("MA")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "菜籽粕期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("RM")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "动力煤期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("ZC")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "菜籽油期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("OI")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "花生期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("PK")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
else:
temp_df = table_df[table_df.iloc[:, 0].str.contains("CF")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
except:
return
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity.py#L164-L226
| 25 |
[
0
] | 1.587302 |
[
12,
13,
18,
19,
20,
21,
22,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
58,
59,
60,
61,
62
] | 69.84127 | false | 7.692308 | 63 | 11 | 30.15873 | 7 |
def option_czce_daily(
symbol: str = "白糖期权", trade_date: str = "20191017"
) -> pd.DataFrame:
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("{}非交易日".format(day.strftime("%Y%m%d")))
return
if day > datetime.date(2010, 8, 24):
url = CZCE_DAILY_OPTION_URL_3.format(
day.strftime("%Y"), day.strftime("%Y%m%d")
)
try:
r = requests.get(url)
f = StringIO(r.text)
table_df = pd.read_table(f, encoding="utf-8", skiprows=1, sep="|")
if symbol == "白糖期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("SR")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "PTA期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("TA")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "甲醇期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("MA")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "菜籽粕期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("RM")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "动力煤期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("ZC")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "菜籽油期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("OI")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
elif symbol == "花生期权":
temp_df = table_df[table_df.iloc[:, 0].str.contains("PK")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
else:
temp_df = table_df[table_df.iloc[:, 0].str.contains("CF")]
temp_df.reset_index(inplace=True, drop=True)
return temp_df.iloc[:-1, :]
except:
return
| 17,987 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity.py
|
option_shfe_daily
|
(
symbol: str = "铝期权", trade_date: str = "20200827"
)
|
上海期货交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"铜期权", "天胶期权", "黄金期权", "铝期权", "锌期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
|
上海期货交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"铜期权", "天胶期权", "黄金期权", "铝期权", "锌期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
| 229 | 346 |
def option_shfe_daily(
symbol: str = "铝期权", trade_date: str = "20200827"
) -> pd.DataFrame:
"""
上海期货交易所-期权-日频行情数据
:param trade_date: 交易日
:type trade_date: str
:param symbol: choice of {"铜期权", "天胶期权", "黄金期权", "铝期权", "锌期权"}
:type symbol: str
:return: 日频行情数据
:rtype: pandas.DataFrame
"""
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("%s非交易日" % day.strftime("%Y%m%d"))
return
if day > datetime.date(2010, 8, 24):
url = SHFE_OPTION_URL.format(day.strftime("%Y%m%d"))
try:
r = requests.get(url, headers=SHFE_HEADERS)
json_data = r.json()
table_df = pd.DataFrame(
[
row
for row in json_data["o_curinstrument"]
if row["INSTRUMENTID"] not in ["小计", "合计"]
and row["INSTRUMENTID"] != ""
]
)
contract_df = table_df[
table_df["PRODUCTNAME"].str.strip() == symbol
]
product_df = pd.DataFrame(json_data["o_curproduct"])
product_df = product_df[
product_df["PRODUCTNAME"].str.strip() == symbol
]
volatility_df = pd.DataFrame(json_data["o_cursigma"])
volatility_df = volatility_df[
volatility_df["PRODUCTNAME"].str.strip() == symbol
]
contract_df.columns = [
"_",
"_",
"_",
"合约代码",
"前结算价",
"开盘价",
"最高价",
"最低价",
"收盘价",
"结算价",
"涨跌1",
"涨跌2",
"成交量",
"持仓量",
"持仓量变化",
"_",
"行权量",
"成交额",
"德尔塔",
"_",
"_",
"_",
"_",
]
contract_df = contract_df[
[
"合约代码",
"开盘价",
"最高价",
"最低价",
"收盘价",
"前结算价",
"结算价",
"涨跌1",
"涨跌2",
"成交量",
"持仓量",
"持仓量变化",
"成交额",
"德尔塔",
"行权量",
]
]
volatility_df.columns = [
"_",
"_",
"_",
"合约系列",
"成交量",
"持仓量",
"持仓量变化",
"行权量",
"成交额",
"隐含波动率",
"_",
]
volatility_df = volatility_df[
[
"合约系列",
"成交量",
"持仓量",
"持仓量变化",
"成交额",
"行权量",
"隐含波动率",
]
]
return contract_df, volatility_df
except:
return
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity.py#L229-L346
| 25 |
[
0
] | 0.847458 |
[
12,
13,
18,
19,
20,
21,
22,
23,
24,
25,
26,
34,
37,
38,
41,
42,
45,
70,
90,
104,
115,
116,
117
] | 19.491525 | false | 7.692308 | 118 | 6 | 80.508475 | 7 |
def option_shfe_daily(
symbol: str = "铝期权", trade_date: str = "20200827"
) -> pd.DataFrame:
calendar = get_calendar()
day = (
convert_date(trade_date)
if trade_date is not None
else datetime.date.today()
)
if day.strftime("%Y%m%d") not in calendar:
warnings.warn("%s非交易日" % day.strftime("%Y%m%d"))
return
if day > datetime.date(2010, 8, 24):
url = SHFE_OPTION_URL.format(day.strftime("%Y%m%d"))
try:
r = requests.get(url, headers=SHFE_HEADERS)
json_data = r.json()
table_df = pd.DataFrame(
[
row
for row in json_data["o_curinstrument"]
if row["INSTRUMENTID"] not in ["小计", "合计"]
and row["INSTRUMENTID"] != ""
]
)
contract_df = table_df[
table_df["PRODUCTNAME"].str.strip() == symbol
]
product_df = pd.DataFrame(json_data["o_curproduct"])
product_df = product_df[
product_df["PRODUCTNAME"].str.strip() == symbol
]
volatility_df = pd.DataFrame(json_data["o_cursigma"])
volatility_df = volatility_df[
volatility_df["PRODUCTNAME"].str.strip() == symbol
]
contract_df.columns = [
"_",
"_",
"_",
"合约代码",
"前结算价",
"开盘价",
"最高价",
"最低价",
"收盘价",
"结算价",
"涨跌1",
"涨跌2",
"成交量",
"持仓量",
"持仓量变化",
"_",
"行权量",
"成交额",
"德尔塔",
"_",
"_",
"_",
"_",
]
contract_df = contract_df[
[
"合约代码",
"开盘价",
"最高价",
"最低价",
"收盘价",
"前结算价",
"结算价",
"涨跌1",
"涨跌2",
"成交量",
"持仓量",
"持仓量变化",
"成交额",
"德尔塔",
"行权量",
]
]
volatility_df.columns = [
"_",
"_",
"_",
"合约系列",
"成交量",
"持仓量",
"持仓量变化",
"行权量",
"成交额",
"隐含波动率",
"_",
]
volatility_df = volatility_df[
[
"合约系列",
"成交量",
"持仓量",
"持仓量变化",
"成交额",
"行权量",
"隐含波动率",
]
]
return contract_df, volatility_df
except:
return
| 17,988 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_lhb_em.py
|
option_lhb_em
|
(
symbol: str = "510050",
indicator: str = "期权交易情况-认沽交易量",
trade_date: str = "20220121",
)
|
东方财富网-数据中心-特色数据-期权龙虎榜单
https://data.eastmoney.com/other/qqlhb.html
:param symbol: 期权代码; choice of {"510050", "510300", "159919"}
:type symbol: str
:param indicator: 需要获取的指标; choice of {"期权交易情况-认沽交易量","期权持仓情况-认沽持仓量", "期权交易情况-认购交易量", "期权持仓情况-认购持仓量"}
:type indicator: str
:param trade_date: 交易日期
:type trade_date: str
:return: 期权龙虎榜单
:rtype: pandas.DataFrame
|
东方财富网-数据中心-特色数据-期权龙虎榜单
https://data.eastmoney.com/other/qqlhb.html
:param symbol: 期权代码; choice of {"510050", "510300", "159919"}
:type symbol: str
:param indicator: 需要获取的指标; choice of {"期权交易情况-认沽交易量","期权持仓情况-认沽持仓量", "期权交易情况-认购交易量", "期权持仓情况-认购持仓量"}
:type indicator: str
:param trade_date: 交易日期
:type trade_date: str
:return: 期权龙虎榜单
:rtype: pandas.DataFrame
| 12 | 247 |
def option_lhb_em(
symbol: str = "510050",
indicator: str = "期权交易情况-认沽交易量",
trade_date: str = "20220121",
) -> pd.DataFrame:
"""
东方财富网-数据中心-特色数据-期权龙虎榜单
https://data.eastmoney.com/other/qqlhb.html
:param symbol: 期权代码; choice of {"510050", "510300", "159919"}
:type symbol: str
:param indicator: 需要获取的指标; choice of {"期权交易情况-认沽交易量","期权持仓情况-认沽持仓量", "期权交易情况-认购交易量", "期权持仓情况-认购持仓量"}
:type indicator: str
:param trade_date: 交易日期
:type trade_date: str
:return: 期权龙虎榜单
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/get"
params = {
"type": "RPT_IF_BILLBOARD_TD",
"sty": "ALL",
"filter": f"""(SECURITY_CODE="{symbol}")(TRADE_DATE='{'-'.join([trade_date[:4], trade_date[4:6], trade_date[6:]])}')""",
"p": "1",
"pss": "200",
"source": "IFBILLBOARD",
"client": "WEB",
"ut": "b2884a393a59ad64002292a3e90d46a5",
"_": "1642904215146",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
if indicator == "期权交易情况-认沽交易量":
temp_df = temp_df.iloc[:7, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"交易量",
"增减",
"净认沽量",
"占总交易量比例",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"交易量",
"增减",
"净认沽量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净认沽量"] = pd.to_numeric(temp_df["净认沽量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权持仓情况-认沽持仓量":
temp_df = temp_df.iloc[7:14, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-",
"-",
"-",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["持仓量"] = pd.to_numeric(temp_df["持仓量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净持仓量"] = pd.to_numeric(temp_df["净持仓量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权交易情况-认购交易量":
temp_df = temp_df.iloc[14:21, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"交易量",
"增减",
"净交易量",
"占总交易量比例",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"交易量",
"增减",
"净交易量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净交易量"] = pd.to_numeric(temp_df["净交易量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权持仓情况-认购持仓量":
temp_df = temp_df.iloc[21:, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-" "-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["持仓量"] = pd.to_numeric(temp_df["持仓量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净持仓量"] = pd.to_numeric(temp_df["净持仓量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_lhb_em.py#L12-L247
| 25 |
[
0
] | 0.423729 |
[
17,
18,
29,
30,
31,
32,
33,
34,
61,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
112,
126,
127,
128,
129,
130,
131,
132,
133,
134,
135,
136,
163,
177,
178,
179,
180,
181,
182,
183,
184,
185,
186,
187,
214,
228,
229,
230,
231,
232,
233,
234,
235
] | 22.457627 | false | 7.575758 | 236 | 5 | 77.542373 | 10 |
def option_lhb_em(
symbol: str = "510050",
indicator: str = "期权交易情况-认沽交易量",
trade_date: str = "20220121",
) -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/get"
params = {
"type": "RPT_IF_BILLBOARD_TD",
"sty": "ALL",
"filter": f"""(SECURITY_CODE="{symbol}")(TRADE_DATE='{'-'.join([trade_date[:4], trade_date[4:6], trade_date[6:]])}')""",
"p": "1",
"pss": "200",
"source": "IFBILLBOARD",
"client": "WEB",
"ut": "b2884a393a59ad64002292a3e90d46a5",
"_": "1642904215146",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
if indicator == "期权交易情况-认沽交易量":
temp_df = temp_df.iloc[:7, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"交易量",
"增减",
"净认沽量",
"占总交易量比例",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"交易量",
"增减",
"净认沽量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净认沽量"] = pd.to_numeric(temp_df["净认沽量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权持仓情况-认沽持仓量":
temp_df = temp_df.iloc[7:14, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-",
"-",
"-",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["持仓量"] = pd.to_numeric(temp_df["持仓量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净持仓量"] = pd.to_numeric(temp_df["净持仓量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权交易情况-认购交易量":
temp_df = temp_df.iloc[14:21, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"交易量",
"增减",
"净交易量",
"占总交易量比例",
"-",
"-",
"-",
"-",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"交易量",
"增减",
"净交易量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["交易量"] = pd.to_numeric(temp_df["交易量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净交易量"] = pd.to_numeric(temp_df["净交易量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
elif indicator == "期权持仓情况-认购持仓量":
temp_df = temp_df.iloc[21:, :]
temp_df.columns = [
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"-",
"-",
"机构",
"名次",
"-",
"-",
"-" "-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"-",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
temp_df = temp_df[
[
"交易类型",
"交易日期",
"证券代码",
"标的名称",
"名次",
"机构",
"持仓量",
"增减",
"净持仓量",
"占总交易量比例",
]
]
temp_df["交易日期"] = pd.to_datetime(temp_df["交易日期"]).dt.date
temp_df["名次"] = pd.to_numeric(temp_df["名次"])
temp_df["持仓量"] = pd.to_numeric(temp_df["持仓量"])
temp_df["增减"] = pd.to_numeric(temp_df["增减"])
temp_df["净持仓量"] = pd.to_numeric(temp_df["净持仓量"])
temp_df["占总交易量比例"] = pd.to_numeric(temp_df["占总交易量比例"])
temp_df.reset_index(drop=True, inplace=True)
return temp_df
| 17,989 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity_sina.py
|
option_commodity_contract_sina
|
(symbol: str = "玉米期权") -> pd.D
|
return temp_df
|
当前可以查询的期权品种的合约日期
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: e.g., {'黄金期权': ['au2012', 'au2008', 'au2010', 'au2104', 'au2102', 'au2106', 'au2108']}
:rtype: dict
|
当前可以查询的期权品种的合约日期
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: e.g., {'黄金期权': ['au2012', 'au2008', 'au2010', 'au2104', 'au2102', 'au2106', 'au2108']}
:rtype: dict
| 15 | 58 |
def option_commodity_contract_sina(symbol: str = "玉米期权") -> pd.DataFrame:
"""
当前可以查询的期权品种的合约日期
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:return: e.g., {'黄金期权': ['au2012', 'au2008', 'au2010', 'au2104', 'au2102', 'au2106', 'au2108']}
:rtype: dict
"""
url = (
"https://stock.finance.sina.com.cn/futures/view/optionsDP.php/pg_o/dce"
)
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
url_list = [
item.find("a")["href"]
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
commodity_list = [
item.find("a").text
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
comm_list_dict = {
key: value for key, value in zip(commodity_list, url_list)
}
url = "https://stock.finance.sina.com.cn" + comm_list_dict[symbol]
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = (
soup.find(attrs={"id": "option_symbol"})
.find(attrs={"class": "selected"})
.text
)
contract = [
item.text
for item in soup.find(attrs={"id": "option_suffix"}).find_all("li")
]
temp_df = pd.DataFrame({symbol: contract})
temp_df.reset_index(inplace=True)
temp_df["index"] = temp_df.index + 1
temp_df.columns = ["序号", "合约"]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity_sina.py#L15-L58
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 20.454545 |
[
9,
12,
13,
14,
19,
24,
27,
28,
29,
30,
35,
39,
40,
41,
42,
43
] | 36.363636 | false | 11.842105 | 44 | 4 | 63.636364 | 6 |
def option_commodity_contract_sina(symbol: str = "玉米期权") -> pd.DataFrame:
url = (
"https://stock.finance.sina.com.cn/futures/view/optionsDP.php/pg_o/dce"
)
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
url_list = [
item.find("a")["href"]
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
commodity_list = [
item.find("a").text
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
comm_list_dict = {
key: value for key, value in zip(commodity_list, url_list)
}
url = "https://stock.finance.sina.com.cn" + comm_list_dict[symbol]
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
symbol = (
soup.find(attrs={"id": "option_symbol"})
.find(attrs={"class": "selected"})
.text
)
contract = [
item.text
for item in soup.find(attrs={"id": "option_suffix"}).find_all("li")
]
temp_df = pd.DataFrame({symbol: contract})
temp_df.reset_index(inplace=True)
temp_df["index"] = temp_df.index + 1
temp_df.columns = ["序号", "合约"]
return temp_df
| 17,990 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity_sina.py
|
option_commodity_contract_table_sina
|
(
symbol: str = "黄金期权", contract: str = "au2204"
)
|
return temp_df
|
当前所有期权合约, 包括看涨期权合约和看跌期权合约
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:param contract: e.g., 'au2012'
:type contract: str
:return: 合约实时行情
:rtype: pandas.DataFrame
|
当前所有期权合约, 包括看涨期权合约和看跌期权合约
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:param contract: e.g., 'au2012'
:type contract: str
:return: 合约实时行情
:rtype: pandas.DataFrame
| 61 | 138 |
def option_commodity_contract_table_sina(
symbol: str = "黄金期权", contract: str = "au2204"
) -> pd.DataFrame:
"""
当前所有期权合约, 包括看涨期权合约和看跌期权合约
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: choice of {"豆粕期权", "玉米期权", "铁矿石期权", "棉花期权", "白糖期权", "PTA期权", "甲醇期权", "橡胶期权", "沪铜期权", "黄金期权", "菜籽粕期权", "液化石油气期权", "动力煤期权", "菜籽油期权", "花生期权"}
:type symbol: str
:param contract: e.g., 'au2012'
:type contract: str
:return: 合约实时行情
:rtype: pandas.DataFrame
"""
url = (
"https://stock.finance.sina.com.cn/futures/view/optionsDP.php/pg_o/dce"
)
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
url_list = [
item.find("a")["href"]
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
commodity_list = [
item.find("a").text
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
comm_list_dict = {
key: value for key, value in zip(commodity_list, url_list)
}
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": comm_list_dict[symbol].split("/")[-2],
"exchange": comm_list_dict[symbol].split("/")[-1],
"pinzhong": contract,
}
r = requests.get(url, params=params)
data_json = r.json()
up_df = pd.DataFrame(data_json["result"]["data"]["up"])
down_df = pd.DataFrame(data_json["result"]["data"]["down"])
temp_df = pd.concat([up_df, down_df], axis=1)
temp_df.columns = [
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-看涨期权合约",
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-看跌期权合约",
]
temp_df["看涨合约-买量"] = pd.to_numeric(temp_df["看涨合约-买量"], errors="coerce")
temp_df["看涨合约-买价"] = pd.to_numeric(temp_df["看涨合约-买价"], errors="coerce")
temp_df["看涨合约-最新价"] = pd.to_numeric(temp_df["看涨合约-最新价"], errors="coerce")
temp_df["看涨合约-卖价"] = pd.to_numeric(temp_df["看涨合约-卖价"], errors="coerce")
temp_df["看涨合约-卖量"] = pd.to_numeric(temp_df["看涨合约-卖量"], errors="coerce")
temp_df["看涨合约-持仓量"] = pd.to_numeric(temp_df["看涨合约-持仓量"], errors="coerce")
temp_df["看涨合约-涨跌"] = pd.to_numeric(temp_df["看涨合约-涨跌"], errors="coerce")
temp_df["行权价"] = pd.to_numeric(temp_df["行权价"], errors="coerce")
temp_df["看跌合约-买量"] = pd.to_numeric(temp_df["看跌合约-买量"], errors="coerce")
temp_df["看跌合约-买价"] = pd.to_numeric(temp_df["看跌合约-买价"], errors="coerce")
temp_df["看跌合约-最新价"] = pd.to_numeric(temp_df["看跌合约-最新价"], errors="coerce")
temp_df["看跌合约-卖价"] = pd.to_numeric(temp_df["看跌合约-卖价"], errors="coerce")
temp_df["看跌合约-卖量"] = pd.to_numeric(temp_df["看跌合约-卖量"], errors="coerce")
temp_df["看跌合约-持仓量"] = pd.to_numeric(temp_df["看跌合约-持仓量"], errors="coerce")
temp_df["看跌合约-涨跌"] = pd.to_numeric(temp_df["看跌合约-涨跌"], errors="coerce")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity_sina.py#L61-L138
| 25 |
[
0
] | 1.282051 |
[
13,
16,
17,
18,
23,
28,
31,
32,
38,
39,
40,
41,
42,
43,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77
] | 38.461538 | false | 11.842105 | 78 | 3 | 61.538462 | 8 |
def option_commodity_contract_table_sina(
symbol: str = "黄金期权", contract: str = "au2204"
) -> pd.DataFrame:
url = (
"https://stock.finance.sina.com.cn/futures/view/optionsDP.php/pg_o/dce"
)
r = requests.get(url)
soup = BeautifulSoup(r.text, "lxml")
url_list = [
item.find("a")["href"]
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
commodity_list = [
item.find("a").text
for item in soup.find_all("li", attrs={"class": "active"})
if item.find("a") is not None
]
comm_list_dict = {
key: value for key, value in zip(commodity_list, url_list)
}
url = "https://stock.finance.sina.com.cn/futures/api/openapi.php/OptionService.getOptionData"
params = {
"type": "futures",
"product": comm_list_dict[symbol].split("/")[-2],
"exchange": comm_list_dict[symbol].split("/")[-1],
"pinzhong": contract,
}
r = requests.get(url, params=params)
data_json = r.json()
up_df = pd.DataFrame(data_json["result"]["data"]["up"])
down_df = pd.DataFrame(data_json["result"]["data"]["down"])
temp_df = pd.concat([up_df, down_df], axis=1)
temp_df.columns = [
"看涨合约-买量",
"看涨合约-买价",
"看涨合约-最新价",
"看涨合约-卖价",
"看涨合约-卖量",
"看涨合约-持仓量",
"看涨合约-涨跌",
"行权价",
"看涨合约-看涨期权合约",
"看跌合约-买量",
"看跌合约-买价",
"看跌合约-最新价",
"看跌合约-卖价",
"看跌合约-卖量",
"看跌合约-持仓量",
"看跌合约-涨跌",
"看跌合约-看跌期权合约",
]
temp_df["看涨合约-买量"] = pd.to_numeric(temp_df["看涨合约-买量"], errors="coerce")
temp_df["看涨合约-买价"] = pd.to_numeric(temp_df["看涨合约-买价"], errors="coerce")
temp_df["看涨合约-最新价"] = pd.to_numeric(temp_df["看涨合约-最新价"], errors="coerce")
temp_df["看涨合约-卖价"] = pd.to_numeric(temp_df["看涨合约-卖价"], errors="coerce")
temp_df["看涨合约-卖量"] = pd.to_numeric(temp_df["看涨合约-卖量"], errors="coerce")
temp_df["看涨合约-持仓量"] = pd.to_numeric(temp_df["看涨合约-持仓量"], errors="coerce")
temp_df["看涨合约-涨跌"] = pd.to_numeric(temp_df["看涨合约-涨跌"], errors="coerce")
temp_df["行权价"] = pd.to_numeric(temp_df["行权价"], errors="coerce")
temp_df["看跌合约-买量"] = pd.to_numeric(temp_df["看跌合约-买量"], errors="coerce")
temp_df["看跌合约-买价"] = pd.to_numeric(temp_df["看跌合约-买价"], errors="coerce")
temp_df["看跌合约-最新价"] = pd.to_numeric(temp_df["看跌合约-最新价"], errors="coerce")
temp_df["看跌合约-卖价"] = pd.to_numeric(temp_df["看跌合约-卖价"], errors="coerce")
temp_df["看跌合约-卖量"] = pd.to_numeric(temp_df["看跌合约-卖量"], errors="coerce")
temp_df["看跌合约-持仓量"] = pd.to_numeric(temp_df["看跌合约-持仓量"], errors="coerce")
temp_df["看跌合约-涨跌"] = pd.to_numeric(temp_df["看跌合约-涨跌"], errors="coerce")
return temp_df
| 17,991 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/option/option_commodity_sina.py
|
option_commodity_hist_sina
|
(symbol: str = "au2012C392")
|
return temp_df
|
合约历史行情-日频
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: return of option_sina_option_commodity_contract_list(symbol="黄金期权", contract="au2012"), 看涨期权合约 filed
:type symbol: str
:return: 合约历史行情-日频
:rtype: pandas.DataFrame
|
合约历史行情-日频
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: return of option_sina_option_commodity_contract_list(symbol="黄金期权", contract="au2012"), 看涨期权合约 filed
:type symbol: str
:return: 合约历史行情-日频
:rtype: pandas.DataFrame
| 141 | 164 |
def option_commodity_hist_sina(symbol: str = "au2012C392") -> pd.DataFrame:
"""
合约历史行情-日频
https://stock.finance.sina.com.cn/futures/view/optionsDP.php
:param symbol: return of option_sina_option_commodity_contract_list(symbol="黄金期权", contract="au2012"), 看涨期权合约 filed
:type symbol: str
:return: 合约历史行情-日频
:rtype: pandas.DataFrame
"""
url = "https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_m2009C30002020_7_17=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[data_text.find("[") : -2])
temp_df = pd.DataFrame(data_json)
temp_df.columns = ["open", "high", "low", "close", "volume", "date"]
temp_df = temp_df[["date", "open", "high", "low", "close", "volume"]]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
temp_df["open"] = pd.to_numeric(temp_df["open"])
temp_df["high"] = pd.to_numeric(temp_df["high"])
temp_df["low"] = pd.to_numeric(temp_df["low"])
temp_df["close"] = pd.to_numeric(temp_df["close"])
temp_df["volume"] = pd.to_numeric(temp_df["volume"])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/option/option_commodity_sina.py#L141-L164
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 37.5 |
[
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23
] | 62.5 | false | 11.842105 | 24 | 1 | 37.5 | 6 |
def option_commodity_hist_sina(symbol: str = "au2012C392") -> pd.DataFrame:
url = "https://stock.finance.sina.com.cn/futures/api/jsonp.php/var%20_m2009C30002020_7_17=/FutureOptionAllService.getOptionDayline"
params = {"symbol": symbol}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[data_text.find("[") : -2])
temp_df = pd.DataFrame(data_json)
temp_df.columns = ["open", "high", "low", "close", "volume", "date"]
temp_df = temp_df[["date", "open", "high", "low", "close", "volume"]]
temp_df["date"] = pd.to_datetime(temp_df["date"]).dt.date
temp_df["open"] = pd.to_numeric(temp_df["open"])
temp_df["high"] = pd.to_numeric(temp_df["high"])
temp_df["low"] = pd.to_numeric(temp_df["low"])
temp_df["close"] = pd.to_numeric(temp_df["close"])
temp_df["volume"] = pd.to_numeric(temp_df["volume"])
return temp_df
| 17,992 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_bitcoin_cme.py
|
crypto_bitcoin_cme
|
(date: str = "20210609")
|
return temp_df
|
芝加哥商业交易所-比特币成交量报告
https://datacenter.jin10.com/reportType/dc_cme_btc_report
:return: 比特币成交量报告
:rtype: pandas.DataFrame
|
芝加哥商业交易所-比特币成交量报告
https://datacenter.jin10.com/reportType/dc_cme_btc_report
:return: 比特币成交量报告
:rtype: pandas.DataFrame
| 12 | 50 |
def crypto_bitcoin_cme(date: str = "20210609") -> pd.DataFrame:
"""
芝加哥商业交易所-比特币成交量报告
https://datacenter.jin10.com/reportType/dc_cme_btc_report
:return: 比特币成交量报告
:rtype: pandas.DataFrame
"""
url = "https://datacenter-api.jin10.com/reports/list"
params = {
"category": "cme",
"date": "-".join([date[:4], date[4:6], date[6:]]),
"attr_id": "4",
"_": "1624354777843",
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(
[item for item in data_json["data"]["values"]],
columns=[item["name"] for item in data_json["data"]["keys"]],
)
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_bitcoin_cme.py#L12-L50
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 17.948718 |
[
7,
8,
14,
32,
33,
34,
38
] | 17.948718 | false | 35.714286 | 39 | 3 | 82.051282 | 4 |
def crypto_bitcoin_cme(date: str = "20210609") -> pd.DataFrame:
url = "https://datacenter-api.jin10.com/reports/list"
params = {
"category": "cme",
"date": "-".join([date[:4], date[4:6], date[6:]]),
"attr_id": "4",
"_": "1624354777843",
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"sec-ch-ua": '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
"sec-ch-ua-mobile": "?0",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.106 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(
[item for item in data_json["data"]["values"]],
columns=[item["name"] for item in data_json["data"]["keys"]],
)
return temp_df
| 17,993 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_hist_investing.py
|
crypto_name_url_table
|
(symbol: str = "web")
|
加密货币名称、代码和 ID,每次更新较慢
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: choice of {"web", "local"}; web 表示从网页获取最新,local 表示利用本地本文件
:type symbol: str
:return: 加密货币名称、代码和 ID
:rtype: pandas.DataFrame
|
加密货币名称、代码和 ID,每次更新较慢
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: choice of {"web", "local"}; web 表示从网页获取最新,local 表示利用本地本文件
:type symbol: str
:return: 加密货币名称、代码和 ID
:rtype: pandas.DataFrame
| 19 | 128 |
def crypto_name_url_table(symbol: str = "web") -> pd.DataFrame:
"""
加密货币名称、代码和 ID,每次更新较慢
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: choice of {"web", "local"}; web 表示从网页获取最新,local 表示利用本地本文件
:type symbol: str
:return: 加密货币名称、代码和 ID
:rtype: pandas.DataFrame
"""
if symbol == "web":
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "https://cn.investing.com/crypto/Service/LoadCryptoCurrencies"
payload = {
'draw': '14',
'columns[0][data]': 'currencies_order',
'columns[0][name]': 'currencies_order',
'columns[0][searchable]': 'true',
'columns[0][orderable]': 'true',
'columns[0][search][value]': '',
'columns[0][search][regex]': 'false',
'columns[1][data]': 'function',
'columns[1][name]': 'crypto_id',
'columns[1][searchable]': 'true',
'columns[1][orderable]': 'false',
'columns[1][search][value]': '',
'columns[1][search][regex]': 'false',
'columns[2][data]': 'function',
'columns[2][name]': 'name',
'columns[2][searchable]': 'true',
'columns[2][orderable]': 'true',
'columns[2][search][value]': '',
'columns[2][search][regex]': 'false',
'columns[3][data]': 'symbol',
'columns[3][name]': 'symbol',
'columns[3][searchable]': 'true',
'columns[3][orderable]': 'true',
'columns[3][search][value]': '',
'columns[3][search][regex]': 'false',
'columns[4][data]': 'function',
'columns[4][name]': 'price_usd',
'columns[4][searchable]': 'true',
'columns[4][orderable]': 'true',
'columns[4][search][value]': '',
'columns[4][search][regex]': 'false',
'columns[5][data]': 'market_cap_formatted',
'columns[5][name]': 'market_cap_usd',
'columns[5][searchable]': 'true',
'columns[5][orderable]': 'true',
'columns[5][search][value]': '',
'columns[5][search][regex]': 'false',
'columns[6][data]': '24h_volume_formatted',
'columns[6][name]': '24h_volume_usd',
'columns[6][searchable]': 'true',
'columns[6][orderable]': 'true',
'columns[6][search][value]': '',
'columns[6][search][regex]': 'false',
'columns[7][data]': 'total_volume',
'columns[7][name]': 'total_volume',
'columns[7][searchable]': 'true',
'columns[7][orderable]': 'true',
'columns[7][search][value]': '',
'columns[7][search][regex]': 'false',
'columns[8][data]': 'change_percent_formatted',
'columns[8][name]': 'change_percent',
'columns[8][searchable]': 'true',
'columns[8][orderable]': 'true',
'columns[8][search][value]': '',
'columns[8][search][regex]': 'false',
'columns[9][data]': 'percent_change_7d_formatted',
'columns[9][name]': 'percent_change_7d',
'columns[9][searchable]': 'true',
'columns[9][orderable]': 'true',
'columns[9][search][value]': '',
'columns[9][search][regex]': 'false',
'order[0][column]': 'currencies_order',
'order[0][dir]': 'asc',
'start': '0',
'length': '100',
'search[value]': '',
'search[regex]': 'false',
'currencyId': '12',
}
r = requests.post(url, data=payload, headers=headers)
data_json = r.json()
total_page = math.ceil(int(data_json['recordsTotal']) / 100)
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
payload.update({
"start": (page-1)*100,
'length': 100
})
r = requests.post(url, data=payload, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json['data'])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df = big_df[[
'symbol',
'name',
'name_trans',
'sml_id',
'related_pair_ID',
]]
return big_df
else:
get_crypto_info_csv_path = get_crypto_info_csv()
name_url_df = pd.read_csv(get_crypto_info_csv_path)
return name_url_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_hist_investing.py#L19-L128
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 8.181818 |
[
9,
10,
14,
15,
85,
86,
87,
88,
89,
90,
94,
95,
96,
97,
98,
105,
107,
108,
109
] | 17.272727 | false | 12.5 | 110 | 3 | 82.727273 | 6 |
def crypto_name_url_table(symbol: str = "web") -> pd.DataFrame:
if symbol == "web":
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
url = "https://cn.investing.com/crypto/Service/LoadCryptoCurrencies"
payload = {
'draw': '14',
'columns[0][data]': 'currencies_order',
'columns[0][name]': 'currencies_order',
'columns[0][searchable]': 'true',
'columns[0][orderable]': 'true',
'columns[0][search][value]': '',
'columns[0][search][regex]': 'false',
'columns[1][data]': 'function',
'columns[1][name]': 'crypto_id',
'columns[1][searchable]': 'true',
'columns[1][orderable]': 'false',
'columns[1][search][value]': '',
'columns[1][search][regex]': 'false',
'columns[2][data]': 'function',
'columns[2][name]': 'name',
'columns[2][searchable]': 'true',
'columns[2][orderable]': 'true',
'columns[2][search][value]': '',
'columns[2][search][regex]': 'false',
'columns[3][data]': 'symbol',
'columns[3][name]': 'symbol',
'columns[3][searchable]': 'true',
'columns[3][orderable]': 'true',
'columns[3][search][value]': '',
'columns[3][search][regex]': 'false',
'columns[4][data]': 'function',
'columns[4][name]': 'price_usd',
'columns[4][searchable]': 'true',
'columns[4][orderable]': 'true',
'columns[4][search][value]': '',
'columns[4][search][regex]': 'false',
'columns[5][data]': 'market_cap_formatted',
'columns[5][name]': 'market_cap_usd',
'columns[5][searchable]': 'true',
'columns[5][orderable]': 'true',
'columns[5][search][value]': '',
'columns[5][search][regex]': 'false',
'columns[6][data]': '24h_volume_formatted',
'columns[6][name]': '24h_volume_usd',
'columns[6][searchable]': 'true',
'columns[6][orderable]': 'true',
'columns[6][search][value]': '',
'columns[6][search][regex]': 'false',
'columns[7][data]': 'total_volume',
'columns[7][name]': 'total_volume',
'columns[7][searchable]': 'true',
'columns[7][orderable]': 'true',
'columns[7][search][value]': '',
'columns[7][search][regex]': 'false',
'columns[8][data]': 'change_percent_formatted',
'columns[8][name]': 'change_percent',
'columns[8][searchable]': 'true',
'columns[8][orderable]': 'true',
'columns[8][search][value]': '',
'columns[8][search][regex]': 'false',
'columns[9][data]': 'percent_change_7d_formatted',
'columns[9][name]': 'percent_change_7d',
'columns[9][searchable]': 'true',
'columns[9][orderable]': 'true',
'columns[9][search][value]': '',
'columns[9][search][regex]': 'false',
'order[0][column]': 'currencies_order',
'order[0][dir]': 'asc',
'start': '0',
'length': '100',
'search[value]': '',
'search[regex]': 'false',
'currencyId': '12',
}
r = requests.post(url, data=payload, headers=headers)
data_json = r.json()
total_page = math.ceil(int(data_json['recordsTotal']) / 100)
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page+1), leave=False):
payload.update({
"start": (page-1)*100,
'length': 100
})
r = requests.post(url, data=payload, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json['data'])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df = big_df[[
'symbol',
'name',
'name_trans',
'sml_id',
'related_pair_ID',
]]
return big_df
else:
get_crypto_info_csv_path = get_crypto_info_csv()
name_url_df = pd.read_csv(get_crypto_info_csv_path)
return name_url_df
| 17,994 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_hist_investing.py
|
crypto_hist
|
(
symbol: str = "BTC",
period: str = "每日",
start_date: str = "20191020",
end_date: str = "20201020",
)
|
return df_data
|
加密货币历史数据
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: 货币名称
:type symbol: str
:param period: choice of {"每日", "每周", "每月"}
:type period: str
:param start_date: '20151020', 注意格式
:type start_date: str
:param end_date: '20201020', 注意格式
:type end_date: str
:return: 加密货币历史数据获取
:rtype: pandas.DataFrame
|
加密货币历史数据
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: 货币名称
:type symbol: str
:param period: choice of {"每日", "每周", "每月"}
:type period: str
:param start_date: '20151020', 注意格式
:type start_date: str
:param end_date: '20201020', 注意格式
:type end_date: str
:return: 加密货币历史数据获取
:rtype: pandas.DataFrame
| 131 | 239 |
def crypto_hist(
symbol: str = "BTC",
period: str = "每日",
start_date: str = "20191020",
end_date: str = "20201020",
):
"""
加密货币历史数据
https://cn.investing.com/crypto/ethereum/historical-data
:param symbol: 货币名称
:type symbol: str
:param period: choice of {"每日", "每周", "每月"}
:type period: str
:param start_date: '20151020', 注意格式
:type start_date: str
:param end_date: '20201020', 注意格式
:type end_date: str
:return: 加密货币历史数据获取
:rtype: pandas.DataFrame
"""
import warnings
warnings.filterwarnings('ignore')
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
period_map = {"每日": "Daily", "每周": "Weekly", "每月": "Monthly"}
start_date = "/".join([start_date[:4], start_date[4:6], start_date[6:]])
end_date = "/".join([end_date[:4], end_date[4:6], end_date[6:]])
name_url_df = crypto_name_url_table(symbol='local')
curr_id = name_url_df[name_url_df["symbol"] == symbol]["related_pair_ID"].values[0]
sml_id = name_url_df[name_url_df["symbol"] == symbol]["sml_id"].values[0]
url = "https://cn.investing.com/instruments/HistoricalDataAjax"
payload = {
"curr_id": curr_id,
"smlID": sml_id,
"header": "null",
"st_date": start_date,
"end_date": end_date,
"interval_sec": period_map[period],
"sort_col": "date",
"sort_ord": "DESC",
"action": "historical_data",
}
r = requests.post(url, data=payload, headers=headers)
temp_df = pd.read_html(r.text)[0]
df_data = temp_df.copy()
if period == "每月":
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月")
else:
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月%d日")
if any(df_data["交易量"].astype(str).str.contains("-")):
df_data["交易量"][df_data["交易量"].str.contains("-")] = df_data["交易量"][
df_data["交易量"].str.contains("-")
].replace("-", 0)
if any(df_data["交易量"].astype(str).str.contains("B")):
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)]
.str.replace("B", "")
.str.replace(",", "")
.astype(float)
* 1000000000
)
if any(df_data["交易量"].astype(str).str.contains("M")):
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)]
.str.replace("M", "")
.str.replace(",", "")
.astype(float)
* 1000000
)
if any(df_data["交易量"].astype(str).str.contains("K")):
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)]
.str.replace("K", "")
.str.replace(",", "")
.astype(float)
* 1000
)
df_data["交易量"] = df_data["交易量"].astype(float)
df_data["涨跌幅"] = pd.DataFrame(
round(
df_data["涨跌幅"].str.replace(",", "").str.replace("%", "").astype(float)
/ 100,
6,
)
)
del df_data["日期"]
df_data.reset_index(inplace=True)
df_data = df_data[[
"日期",
"收盘",
"开盘",
"高",
"低",
"交易量",
"涨跌幅",
]]
df_data['日期'] = pd.to_datetime(df_data['日期']).dt.date
df_data['收盘'] = pd.to_numeric(df_data['收盘'])
df_data['开盘'] = pd.to_numeric(df_data['开盘'])
df_data['高'] = pd.to_numeric(df_data['高'])
df_data['低'] = pd.to_numeric(df_data['低'])
df_data['交易量'] = pd.to_numeric(df_data['交易量'])
df_data['涨跌幅'] = pd.to_numeric(df_data['涨跌幅'])
df_data.sort_values('日期', inplace=True)
df_data.reset_index(inplace=True, drop=True)
return df_data
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_hist_investing.py#L131-L239
| 25 |
[
0
] | 0.917431 |
[
20,
21,
22,
26,
27,
28,
29,
30,
31,
32,
33,
44,
46,
47,
48,
49,
51,
52,
53,
56,
57,
64,
65,
72,
73,
80,
81,
88,
89,
90,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108
] | 36.697248 | false | 12.5 | 109 | 6 | 63.302752 | 12 |
def crypto_hist(
symbol: str = "BTC",
period: str = "每日",
start_date: str = "20191020",
end_date: str = "20201020",
):
import warnings
warnings.filterwarnings('ignore')
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.111 Safari/537.36",
"X-Requested-With": "XMLHttpRequest",
}
period_map = {"每日": "Daily", "每周": "Weekly", "每月": "Monthly"}
start_date = "/".join([start_date[:4], start_date[4:6], start_date[6:]])
end_date = "/".join([end_date[:4], end_date[4:6], end_date[6:]])
name_url_df = crypto_name_url_table(symbol='local')
curr_id = name_url_df[name_url_df["symbol"] == symbol]["related_pair_ID"].values[0]
sml_id = name_url_df[name_url_df["symbol"] == symbol]["sml_id"].values[0]
url = "https://cn.investing.com/instruments/HistoricalDataAjax"
payload = {
"curr_id": curr_id,
"smlID": sml_id,
"header": "null",
"st_date": start_date,
"end_date": end_date,
"interval_sec": period_map[period],
"sort_col": "date",
"sort_ord": "DESC",
"action": "historical_data",
}
r = requests.post(url, data=payload, headers=headers)
temp_df = pd.read_html(r.text)[0]
df_data = temp_df.copy()
if period == "每月":
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月")
else:
df_data.index = pd.to_datetime(df_data["日期"], format="%Y年%m月%d日")
if any(df_data["交易量"].astype(str).str.contains("-")):
df_data["交易量"][df_data["交易量"].str.contains("-")] = df_data["交易量"][
df_data["交易量"].str.contains("-")
].replace("-", 0)
if any(df_data["交易量"].astype(str).str.contains("B")):
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("B").fillna(False)]
.str.replace("B", "")
.str.replace(",", "")
.astype(float)
* 1000000000
)
if any(df_data["交易量"].astype(str).str.contains("M")):
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("M").fillna(False)]
.str.replace("M", "")
.str.replace(",", "")
.astype(float)
* 1000000
)
if any(df_data["交易量"].astype(str).str.contains("K")):
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)] = (
df_data["交易量"][df_data["交易量"].str.contains("K").fillna(False)]
.str.replace("K", "")
.str.replace(",", "")
.astype(float)
* 1000
)
df_data["交易量"] = df_data["交易量"].astype(float)
df_data["涨跌幅"] = pd.DataFrame(
round(
df_data["涨跌幅"].str.replace(",", "").str.replace("%", "").astype(float)
/ 100,
6,
)
)
del df_data["日期"]
df_data.reset_index(inplace=True)
df_data = df_data[[
"日期",
"收盘",
"开盘",
"高",
"低",
"交易量",
"涨跌幅",
]]
df_data['日期'] = pd.to_datetime(df_data['日期']).dt.date
df_data['收盘'] = pd.to_numeric(df_data['收盘'])
df_data['开盘'] = pd.to_numeric(df_data['开盘'])
df_data['高'] = pd.to_numeric(df_data['高'])
df_data['低'] = pd.to_numeric(df_data['低'])
df_data['交易量'] = pd.to_numeric(df_data['交易量'])
df_data['涨跌幅'] = pd.to_numeric(df_data['涨跌幅'])
df_data.sort_values('日期', inplace=True)
df_data.reset_index(inplace=True, drop=True)
return df_data
| 17,995 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_hold.py
|
crypto_bitcoin_hold_report
|
()
|
return temp_df
|
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
|
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
| 12 | 70 |
def crypto_bitcoin_hold_report():
"""
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
"""
url = "https://datacenter-api.jin10.com/bitcoin_treasuries/list"
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-version": "1.0.0",
}
params = {"_": "1618902583006"}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["values"])
temp_df.columns = [
'代码',
'公司名称-英文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'_',
'分类',
'倍数',
'_',
'公司名称-中文',
]
temp_df = temp_df[[
'代码',
'公司名称-英文',
'公司名称-中文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'分类',
'倍数',
]]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_hold.py#L12-L70
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 11.864407 |
[
7,
8,
20,
21,
22,
23,
24,
42,
58
] | 15.254237 | false | 23.076923 | 59 | 1 | 84.745763 | 4 |
def crypto_bitcoin_hold_report():
url = "https://datacenter-api.jin10.com/bitcoin_treasuries/list"
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-version": "1.0.0",
}
params = {"_": "1618902583006"}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["values"])
temp_df.columns = [
'代码',
'公司名称-英文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'_',
'分类',
'倍数',
'_',
'公司名称-中文',
]
temp_df = temp_df[[
'代码',
'公司名称-英文',
'公司名称-中文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'分类',
'倍数',
]]
return temp_df
| 17,996 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_hold.py
|
crypto_bitcoin_hold_report
|
()
|
return temp_df
|
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
|
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
| 73 | 131 |
def crypto_bitcoin_hold_report():
"""
金十数据-比特币持仓报告
https://datacenter.jin10.com/dc_report?name=bitcoint
:return: 比特币持仓报告
:rtype: pandas.DataFrame
"""
url = "https://datacenter-api.jin10.com/bitcoin_treasuries/list"
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-version": "1.0.0",
}
params = {"_": "1618902583006"}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["values"])
temp_df.columns = [
'代码',
'公司名称-英文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'_',
'分类',
'倍数',
'_',
'公司名称-中文',
]
temp_df = temp_df[[
'代码',
'公司名称-英文',
'公司名称-中文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'分类',
'倍数',
]]
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_hold.py#L73-L131
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 11.864407 |
[
7,
8,
20,
21,
22,
23,
24,
42,
58
] | 15.254237 | false | 23.076923 | 59 | 1 | 84.745763 | 4 |
def crypto_bitcoin_hold_report():
url = "https://datacenter-api.jin10.com/bitcoin_treasuries/list"
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.128 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-version": "1.0.0",
}
params = {"_": "1618902583006"}
r = requests.get(url, params=params, headers=headers)
data_json = r.json()
temp_df = pd.DataFrame(data_json["data"]["values"])
temp_df.columns = [
'代码',
'公司名称-英文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'_',
'分类',
'倍数',
'_',
'公司名称-中文',
]
temp_df = temp_df[[
'代码',
'公司名称-英文',
'公司名称-中文',
'国家/地区',
'市值',
'比特币占市值比重',
'持仓成本',
'持仓占比',
'持仓量',
'当日持仓市值',
'查询日期',
'公告链接',
'分类',
'倍数',
]]
return temp_df
| 17,997 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/crypto/crypto_crix.py
|
crypto_crix
|
(symbol: str = "CRIX")
|
CRIX 和 VCRIX 指数
https://thecrix.de/
:param symbol: choice of {"CRIX", "VCRIX"}
:type symbol: str
:return: CRIX 和 VCRIX 指数
:rtype: pandas.DataFrame
|
CRIX 和 VCRIX 指数
https://thecrix.de/
:param symbol: choice of {"CRIX", "VCRIX"}
:type symbol: str
:return: CRIX 和 VCRIX 指数
:rtype: pandas.DataFrame
| 13 | 60 |
def crypto_crix(symbol: str = "CRIX") -> pd.DataFrame:
"""
CRIX 和 VCRIX 指数
https://thecrix.de/
:param symbol: choice of {"CRIX", "VCRIX"}
:type symbol: str
:return: CRIX 和 VCRIX 指数
:rtype: pandas.DataFrame
"""
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
url: str = "https://thecrix.de/"
r = requests.get(url, verify=False)
soup = BeautifulSoup(r.text, "lxml")
data_text = soup.find_all("script")[12].string
if symbol == "CRIX":
inner_text = data_text[data_text.find("series") : data_text.find("CRIX")]
temp_df = pd.DataFrame(
list(
eval(
inner_text[
inner_text.find("data") + 5 : inner_text.find("name")
].strip()
)
)[0]
)
temp_df.columns = ["date", "value"]
temp_df["date"] = pd.to_datetime(temp_df["date"], unit="ms").dt.date
return temp_df
else:
data_text = data_text[
data_text.find("VCRIX IndeX") : data_text.find("2014-11-28")
]
inner_text = data_text[data_text.find("series") : data_text.find('"VCRIX"')]
temp_df = pd.DataFrame(
list(
eval(
inner_text[
inner_text.find("data") + 5 : inner_text.find("name")
].strip()
)
)[0]
)
temp_df.columns = ["date", "value"]
temp_df["date"] = pd.to_datetime(temp_df["date"], unit="ms").dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/crypto/crypto_crix.py#L13-L60
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 18.75 |
[
9,
10,
12,
13,
14,
15,
16,
17,
18,
27,
28,
29,
32,
35,
36,
45,
46,
47
] | 37.5 | false | 23.076923 | 48 | 2 | 62.5 | 6 |
def crypto_crix(symbol: str = "CRIX") -> pd.DataFrame:
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
url: str = "https://thecrix.de/"
r = requests.get(url, verify=False)
soup = BeautifulSoup(r.text, "lxml")
data_text = soup.find_all("script")[12].string
if symbol == "CRIX":
inner_text = data_text[data_text.find("series") : data_text.find("CRIX")]
temp_df = pd.DataFrame(
list(
eval(
inner_text[
inner_text.find("data") + 5 : inner_text.find("name")
].strip()
)
)[0]
)
temp_df.columns = ["date", "value"]
temp_df["date"] = pd.to_datetime(temp_df["date"], unit="ms").dt.date
return temp_df
else:
data_text = data_text[
data_text.find("VCRIX IndeX") : data_text.find("2014-11-28")
]
inner_text = data_text[data_text.find("series") : data_text.find('"VCRIX"')]
temp_df = pd.DataFrame(
list(
eval(
inner_text[
inner_text.find("data") + 5 : inner_text.find("name")
].strip()
)
)[0]
)
temp_df.columns = ["date", "value"]
temp_df["date"] = pd.to_datetime(temp_df["date"], unit="ms").dt.date
return temp_df
| 17,998 |
|
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/interest_rate/interbank_rate_em.py
|
rate_interbank
|
(
market: str = "上海银行同业拆借市场",
symbol: str = "Shibor人民币",
indicator: str = "隔夜",
)
|
return big_df
|
东方财富-拆借利率一览-具体市场的具体品种的具体指标的拆借利率数据
具体 market 和 symbol 参见: http://data.eastmoney.com/shibor/shibor.aspx?m=sg&t=88&d=99333&cu=sgd&type=009065&p=79
:param market: choice of {"上海银行同业拆借市场", "中国银行同业拆借市场", "伦敦银行同业拆借市场", "欧洲银行同业拆借市场", "香港银行同业拆借市场", "新加坡银行同业拆借市场"}
:type market: str
:param symbol: choice of {"Shibor人民币", "Chibor人民币", "Libor英镑", "***", "Sibor美元"}
:type symbol: str
:param indicator: choice of {"隔夜", "1周", "2周", "***", "1年"}
:type indicator: str
:return: 具体市场的具体品种的具体指标的拆借利率数据
:rtype: pandas.DataFrame
|
东方财富-拆借利率一览-具体市场的具体品种的具体指标的拆借利率数据
具体 market 和 symbol 参见: http://data.eastmoney.com/shibor/shibor.aspx?m=sg&t=88&d=99333&cu=sgd&type=009065&p=79
:param market: choice of {"上海银行同业拆借市场", "中国银行同业拆借市场", "伦敦银行同业拆借市场", "欧洲银行同业拆借市场", "香港银行同业拆借市场", "新加坡银行同业拆借市场"}
:type market: str
:param symbol: choice of {"Shibor人民币", "Chibor人民币", "Libor英镑", "***", "Sibor美元"}
:type symbol: str
:param indicator: choice of {"隔夜", "1周", "2周", "***", "1年"}
:type indicator: str
:return: 具体市场的具体品种的具体指标的拆借利率数据
:rtype: pandas.DataFrame
| 12 | 127 |
def rate_interbank(
market: str = "上海银行同业拆借市场",
symbol: str = "Shibor人民币",
indicator: str = "隔夜",
):
"""
东方财富-拆借利率一览-具体市场的具体品种的具体指标的拆借利率数据
具体 market 和 symbol 参见: http://data.eastmoney.com/shibor/shibor.aspx?m=sg&t=88&d=99333&cu=sgd&type=009065&p=79
:param market: choice of {"上海银行同业拆借市场", "中国银行同业拆借市场", "伦敦银行同业拆借市场", "欧洲银行同业拆借市场", "香港银行同业拆借市场", "新加坡银行同业拆借市场"}
:type market: str
:param symbol: choice of {"Shibor人民币", "Chibor人民币", "Libor英镑", "***", "Sibor美元"}
:type symbol: str
:param indicator: choice of {"隔夜", "1周", "2周", "***", "1年"}
:type indicator: str
:return: 具体市场的具体品种的具体指标的拆借利率数据
:rtype: pandas.DataFrame
"""
market_map = {
"上海银行同业拆借市场": "001",
"中国银行同业拆借市场": "002",
"伦敦银行同业拆借市场": "003",
"欧洲银行同业拆借市场": "004",
"香港银行同业拆借市场": "005",
"新加坡银行同业拆借市场": "006",
}
symbol_map = {
"Shibor人民币": "CNY",
"Chibor人民币": "CNY",
"Libor英镑": "GBP",
"Libor欧元": "EUR",
"Libor美元": "USD",
"Libor日元": "JPY",
"Euribor欧元": "EUR",
"Hibor美元": "USD",
"Hibor人民币": "CNH",
"Hibor港币": "HKD",
"Sibor星元": "SGD",
"Sibor美元": "USD",
}
indicator_map = {
"隔夜": "001",
"1周": "101",
"2周": "102",
"3周": "103",
"1月": "201",
"2月": "202",
"3月": "203",
"4月": "204",
"5月": "205",
"6月": "206",
"7月": "207",
"8月": "208",
"9月": "209",
"10月": "210",
"11月": "211",
"1年": "301",
}
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_IMP_INTRESTRATEN",
"columns": "REPORT_DATE,REPORT_PERIOD,IR_RATE,CHANGE_RATE,INDICATOR_ID,LATEST_RECORD,MARKET,MARKET_CODE,CURRENCY,CURRENCY_CODE",
"quoteColumns": "",
"filter": f"""(MARKET_CODE="{market_map[market]}")(CURRENCY_CODE="{symbol_map[symbol]}")(INDICATOR_ID="{indicator_map[indicator]}")""",
"pageNumber": "1",
"pageSize": "500",
"sortTypes": "-1",
"sortColumns": "REPORT_DATE",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1653376974939",
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["result"]["pages"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
"p": page,
"pageNo": page,
"pageNum": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"报告日",
"-",
"利率",
"涨跌",
"-",
"-",
"-",
"-",
"-",
"-",
]
big_df = big_df[
[
"报告日",
"利率",
"涨跌",
]
]
big_df["报告日"] = pd.to_datetime(big_df["报告日"]).dt.date
big_df["利率"] = pd.to_numeric(big_df["利率"])
big_df["涨跌"] = pd.to_numeric(big_df["涨跌"])
big_df.sort_values(["报告日"], inplace=True)
big_df.reset_index(inplace=True, drop=True)
return big_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/interest_rate/interbank_rate_em.py#L12-L127
| 25 |
[
0
] | 0.862069 |
[
17,
25,
39,
57,
58,
74,
75,
76,
77,
78,
79,
87,
88,
89,
90,
91,
103,
110,
111,
112,
113,
114,
115
] | 19.827586 | false | 19.354839 | 116 | 2 | 80.172414 | 10 |
def rate_interbank(
market: str = "上海银行同业拆借市场",
symbol: str = "Shibor人民币",
indicator: str = "隔夜",
):
market_map = {
"上海银行同业拆借市场": "001",
"中国银行同业拆借市场": "002",
"伦敦银行同业拆借市场": "003",
"欧洲银行同业拆借市场": "004",
"香港银行同业拆借市场": "005",
"新加坡银行同业拆借市场": "006",
}
symbol_map = {
"Shibor人民币": "CNY",
"Chibor人民币": "CNY",
"Libor英镑": "GBP",
"Libor欧元": "EUR",
"Libor美元": "USD",
"Libor日元": "JPY",
"Euribor欧元": "EUR",
"Hibor美元": "USD",
"Hibor人民币": "CNH",
"Hibor港币": "HKD",
"Sibor星元": "SGD",
"Sibor美元": "USD",
}
indicator_map = {
"隔夜": "001",
"1周": "101",
"2周": "102",
"3周": "103",
"1月": "201",
"2月": "202",
"3月": "203",
"4月": "204",
"5月": "205",
"6月": "206",
"7月": "207",
"8月": "208",
"9月": "209",
"10月": "210",
"11月": "211",
"1年": "301",
}
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_IMP_INTRESTRATEN",
"columns": "REPORT_DATE,REPORT_PERIOD,IR_RATE,CHANGE_RATE,INDICATOR_ID,LATEST_RECORD,MARKET,MARKET_CODE,CURRENCY,CURRENCY_CODE",
"quoteColumns": "",
"filter": f"""(MARKET_CODE="{market_map[market]}")(CURRENCY_CODE="{symbol_map[symbol]}")(INDICATOR_ID="{indicator_map[indicator]}")""",
"pageNumber": "1",
"pageSize": "500",
"sortTypes": "-1",
"sortColumns": "REPORT_DATE",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1653376974939",
}
r = requests.get(url, params=params)
data_json = r.json()
total_page = data_json["result"]["pages"]
big_df = pd.DataFrame()
for page in tqdm(range(1, total_page + 1), leave=False):
params.update(
{
"pageNumber": page,
"p": page,
"pageNo": page,
"pageNum": page,
}
)
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
big_df = pd.concat([big_df, temp_df], ignore_index=True)
big_df.columns = [
"报告日",
"-",
"利率",
"涨跌",
"-",
"-",
"-",
"-",
"-",
"-",
]
big_df = big_df[
[
"报告日",
"利率",
"涨跌",
]
]
big_df["报告日"] = pd.to_datetime(big_df["报告日"]).dt.date
big_df["利率"] = pd.to_numeric(big_df["利率"])
big_df["涨跌"] = pd.to_numeric(big_df["涨跌"])
big_df.sort_values(["报告日"], inplace=True)
big_df.reset_index(inplace=True, drop=True)
return big_df
| 17,999 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/hf/hf_sp500.py
|
hf_sp_500
|
(year: str = "2017")
|
return temp_df
|
S&P 500 minute data from 2012-2018
:param year: from 2012-2018
:type year: str
:return: specific year dataframe
:rtype: pandas.DataFrame
|
S&P 500 minute data from 2012-2018
:param year: from 2012-2018
:type year: str
:return: specific year dataframe
:rtype: pandas.DataFrame
| 13 | 30 |
def hf_sp_500(year: str = "2017") -> pd.DataFrame:
"""
S&P 500 minute data from 2012-2018
:param year: from 2012-2018
:type year: str
:return: specific year dataframe
:rtype: pandas.DataFrame
"""
url = f"https://github.com/FutureSharks/financial-data/raw/master/pyfinancialdata/data/stocks/histdata/SPXUSD/DAT_ASCII_SPXUSD_M1_{year}.csv"
temp_df = pd.read_table(url, header=None, sep=";")
temp_df.columns = ["date", "open", "high", "low", "close", "price"]
temp_df['date'] = pd.to_datetime(temp_df['date']).dt.date
temp_df['open'] = pd.to_numeric(temp_df['open'])
temp_df['high'] = pd.to_numeric(temp_df['high'])
temp_df['low'] = pd.to_numeric(temp_df['low'])
temp_df['close'] = pd.to_numeric(temp_df['close'])
temp_df['price'] = pd.to_numeric(temp_df['price'])
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/hf/hf_sp500.py#L13-L30
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 44.444444 |
[
8,
9,
10,
11,
12,
13,
14,
15,
16,
17
] | 55.555556 | false | 25 | 18 | 1 | 44.444444 | 5 |
def hf_sp_500(year: str = "2017") -> pd.DataFrame:
url = f"https://github.com/FutureSharks/financial-data/raw/master/pyfinancialdata/data/stocks/histdata/SPXUSD/DAT_ASCII_SPXUSD_M1_{year}.csv"
temp_df = pd.read_table(url, header=None, sep=";")
temp_df.columns = ["date", "open", "high", "low", "close", "price"]
temp_df['date'] = pd.to_datetime(temp_df['date']).dt.date
temp_df['open'] = pd.to_numeric(temp_df['open'])
temp_df['high'] = pd.to_numeric(temp_df['high'])
temp_df['low'] = pd.to_numeric(temp_df['low'])
temp_df['close'] = pd.to_numeric(temp_df['close'])
temp_df['price'] = pd.to_numeric(temp_df['price'])
return temp_df
| 18,000 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_retail_rate_monthly
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-零售销售月率
https://data.eastmoney.com/cjsj/foreign_5_0.html
:return: 零售销售月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-零售销售月率
https://data.eastmoney.com/cjsj/foreign_5_0.html
:return: 零售销售月率
:rtype: pandas.DataFrame
| 15 | 62 |
def macro_australia_retail_rate_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-零售销售月率
https://data.eastmoney.com/cjsj/foreign_5_0.html
:return: 零售销售月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152903")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L15-L62
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.583333 |
[
7,
8,
23,
24,
25,
26,
38,
44,
45,
46,
47
] | 22.916667 | false | 11.650485 | 48 | 1 | 77.083333 | 4 |
def macro_australia_retail_rate_monthly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152903")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,001 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_trade
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-贸易帐
https://data.eastmoney.com/cjsj/foreign_5_1.html
:return: 贸易帐
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-贸易帐
https://data.eastmoney.com/cjsj/foreign_5_1.html
:return: 贸易帐
:rtype: pandas.DataFrame
| 66 | 112 |
def macro_australia_trade() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-贸易帐
https://data.eastmoney.com/cjsj/foreign_5_1.html
:return: 贸易帐
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152793")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L66-L112
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_trade() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152793")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,002 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_unemployment_rate
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-失业率
https://data.eastmoney.com/cjsj/foreign_5_2.html
:return: 失业率
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-失业率
https://data.eastmoney.com/cjsj/foreign_5_2.html
:return: 失业率
:rtype: pandas.DataFrame
| 116 | 162 |
def macro_australia_unemployment_rate() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-失业率
https://data.eastmoney.com/cjsj/foreign_5_2.html
:return: 失业率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101141")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L116-L162
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_unemployment_rate() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101141")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,003 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_ppi_quarterly
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-生产者物价指数季率
https://data.eastmoney.com/cjsj/foreign_5_3.html
:return: 生产者物价指数季率
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-生产者物价指数季率
https://data.eastmoney.com/cjsj/foreign_5_3.html
:return: 生产者物价指数季率
:rtype: pandas.DataFrame
| 166 | 212 |
def macro_australia_ppi_quarterly() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-生产者物价指数季率
https://data.eastmoney.com/cjsj/foreign_5_3.html
:return: 生产者物价指数季率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152722")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L166-L212
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_ppi_quarterly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00152722")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,004 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_cpi_quarterly
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-消费者物价指数季率
http://data.eastmoney.com/cjsj/foreign_5_4.html
:return: 消费者物价指数季率
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-消费者物价指数季率
http://data.eastmoney.com/cjsj/foreign_5_4.html
:return: 消费者物价指数季率
:rtype: pandas.DataFrame
| 216 | 262 |
def macro_australia_cpi_quarterly() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-消费者物价指数季率
http://data.eastmoney.com/cjsj/foreign_5_4.html
:return: 消费者物价指数季率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101104")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L216-L262
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_cpi_quarterly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101104")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,005 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_cpi_yearly
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_5_5.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_5_5.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
| 266 | 312 |
def macro_australia_cpi_yearly() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_5_5.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101093")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L266-L312
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_cpi_yearly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00101093")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,006 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_australia.py
|
macro_australia_bank_rate
|
()
|
return temp_df
|
东方财富-经济数据-澳大利亚-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_5_6.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
|
东方财富-经济数据-澳大利亚-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_5_6.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
| 316 | 362 |
def macro_australia_bank_rate() -> pd.DataFrame:
"""
东方财富-经济数据-澳大利亚-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_5_6.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342255")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_australia.py#L316-L362
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 11.650485 | 47 | 1 | 76.595745 | 4 |
def macro_australia_bank_rate() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_AUSTRALIA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342255")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,007 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_cpi
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-消费者物价指数
https://data.eastmoney.com/cjsj/foreign_8_0.html
:return: 消费者物价指数
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-消费者物价指数
https://data.eastmoney.com/cjsj/foreign_8_0.html
:return: 消费者物价指数
:rtype: pandas.DataFrame
| 14 | 48 |
def macro_china_hk_cpi() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-消费者物价指数
https://data.eastmoney.com/cjsj/foreign_8_0.html
:return: 消费者物价指数
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "0",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L14-L48
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_cpi() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "0",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,008 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_cpi_ratio
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_8_1.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_8_1.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
| 51 | 85 |
def macro_china_hk_cpi_ratio() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_8_1.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L51-L85
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_cpi_ratio() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,009 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_rate_of_unemployment
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-失业率
https://data.eastmoney.com/cjsj/foreign_8_2.html
:return: 失业率
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-失业率
https://data.eastmoney.com/cjsj/foreign_8_2.html
:return: 失业率
:rtype: pandas.DataFrame
| 88 | 122 |
def macro_china_hk_rate_of_unemployment() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-失业率
https://data.eastmoney.com/cjsj/foreign_8_2.html
:return: 失业率
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "2",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L88-L122
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_rate_of_unemployment() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "2",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,010 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_gbp
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港 GDP
https://data.eastmoney.com/cjsj/foreign_8_3.html
:return: 香港 GDP
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港 GDP
https://data.eastmoney.com/cjsj/foreign_8_3.html
:return: 香港 GDP
:rtype: pandas.DataFrame
| 125 | 159 |
def macro_china_hk_gbp() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港 GDP
https://data.eastmoney.com/cjsj/foreign_8_3.html
:return: 香港 GDP
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "3",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值']) / 100
temp_df['现值'] = pd.to_numeric(temp_df['现值']) / 100
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L125-L159
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_gbp() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "3",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值']) / 100
temp_df['现值'] = pd.to_numeric(temp_df['现值']) / 100
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,011 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_gbp_ratio
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港 GDP 同比
https://data.eastmoney.com/cjsj/foreign_8_4.html
:return: 香港 GDP 同比
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港 GDP 同比
https://data.eastmoney.com/cjsj/foreign_8_4.html
:return: 香港 GDP 同比
:rtype: pandas.DataFrame
| 162 | 196 |
def macro_china_hk_gbp_ratio() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港 GDP 同比
https://data.eastmoney.com/cjsj/foreign_8_4.html
:return: 香港 GDP 同比
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "4",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L162-L196
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_gbp_ratio() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "4",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,012 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_building_volume
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港楼宇买卖合约数量
https://data.eastmoney.com/cjsj/foreign_8_5.html
:return: 香港楼宇买卖合约数量
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港楼宇买卖合约数量
https://data.eastmoney.com/cjsj/foreign_8_5.html
:return: 香港楼宇买卖合约数量
:rtype: pandas.DataFrame
| 199 | 233 |
def macro_china_hk_building_volume() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港楼宇买卖合约数量
https://data.eastmoney.com/cjsj/foreign_8_5.html
:return: 香港楼宇买卖合约数量
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "5",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L199-L233
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_building_volume() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "5",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,013 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_building_amount
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港楼宇买卖合约成交金额
https://data.eastmoney.com/cjsj/foreign_8_6.html
:return: 香港楼宇买卖合约成交金额
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港楼宇买卖合约成交金额
https://data.eastmoney.com/cjsj/foreign_8_6.html
:return: 香港楼宇买卖合约成交金额
:rtype: pandas.DataFrame
| 236 | 270 |
def macro_china_hk_building_amount() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港楼宇买卖合约成交金额
https://data.eastmoney.com/cjsj/foreign_8_6.html
:return: 香港楼宇买卖合约成交金额
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "6",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值']) / 100
temp_df['现值'] = pd.to_numeric(temp_df['现值']) / 100
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L236-L270
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_building_amount() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "6",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值']) / 100
temp_df['现值'] = pd.to_numeric(temp_df['现值']) / 100
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,014 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_trade_diff_ratio
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港商品贸易差额年率
https://data.eastmoney.com/cjsj/foreign_8_7.html
:return: 香港商品贸易差额年率
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港商品贸易差额年率
https://data.eastmoney.com/cjsj/foreign_8_7.html
:return: 香港商品贸易差额年率
:rtype: pandas.DataFrame
| 273 | 307 |
def macro_china_hk_trade_diff_ratio() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港商品贸易差额年率
https://data.eastmoney.com/cjsj/foreign_8_7.html
:return: 香港商品贸易差额年率
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "7",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L273-L307
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_trade_diff_ratio() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "7",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,015 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_china_hk.py
|
macro_china_hk_ppi
|
()
|
return temp_df
|
东方财富-经济数据一览-中国香港-香港制造业 PPI 年率
https://data.eastmoney.com/cjsj/foreign_8_8.html
:return: 香港制造业 PPI 年率
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-中国香港-香港制造业 PPI 年率
https://data.eastmoney.com/cjsj/foreign_8_8.html
:return: 香港制造业 PPI 年率
:rtype: pandas.DataFrame
| 310 | 344 |
def macro_china_hk_ppi() -> pd.DataFrame:
"""
东方财富-经济数据一览-中国香港-香港制造业 PPI 年率
https://data.eastmoney.com/cjsj/foreign_8_8.html
:return: 香港制造业 PPI 年率
:rtype: pandas.DataFrame
"""
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "8",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_china_hk.py#L310-L344
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 20 |
[
7,
8,
20,
21,
22,
23,
24,
30,
31,
32,
33,
34
] | 34.285714 | false | 10 | 35 | 2 | 65.714286 | 4 |
def macro_china_hk_ppi() -> pd.DataFrame:
url = "https://datainterface.eastmoney.com/EM_DataCenter/JS.aspx"
params = {
"type": "GJZB",
"sty": "HKZB",
"js": "({data:[(x)],pages:(pc)})",
"p": "1",
"ps": "2000",
"mkt": "8",
"stat": "8",
"pageNo": "1",
"pageNum": "1",
"_": "1621332091873",
}
r = requests.get(url, params=params)
data_text = r.text
data_json = demjson.decode(data_text[1:-1])
temp_df = pd.DataFrame([item.split(",") for item in data_json["data"]])
temp_df.columns = [
"时间",
"前值",
"现值",
"发布日期",
]
temp_df['前值'] = pd.to_numeric(temp_df['前值'])
temp_df['现值'] = pd.to_numeric(temp_df['现值'])
temp_df['时间'] = pd.to_datetime(temp_df['时间']).dt.date
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,016 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_usa.py
|
macro_usa_phs
|
()
|
return temp_df
|
东方财富-经济数据一览-美国-未决房屋销售月率
https://data.eastmoney.com/cjsj/foreign_0_5.html
:return: 未决房屋销售月率
:rtype: pandas.DataFrame
|
东方财富-经济数据一览-美国-未决房屋销售月率
https://data.eastmoney.com/cjsj/foreign_0_5.html
:return: 未决房屋销售月率
:rtype: pandas.DataFrame
| 28 | 75 |
def macro_usa_phs() -> pd.DataFrame:
"""
东方财富-经济数据一览-美国-未决房屋销售月率
https://data.eastmoney.com/cjsj/foreign_0_5.html
:return: 未决房屋销售月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_USA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342249")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[
[
"时间",
"前值",
"现值",
"发布日期",
]
]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"]).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_usa.py#L28-L75
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.583333 |
[
7,
8,
23,
24,
25,
26,
36,
44,
45,
46,
47
] | 22.916667 | false | 4.118993 | 48 | 1 | 77.083333 | 4 |
def macro_usa_phs() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_USA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342249")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[
[
"时间",
"前值",
"现值",
"发布日期",
]
]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"]).dt.date
return temp_df
| 18,017 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_usa.py
|
macro_usa_gdp_monthly
|
()
|
return temp_df
|
金十数据-美国国内生产总值(GDP)报告, 数据区间从 20080228-至今
https://datacenter.jin10.com/reportType/dc_usa_gdp
:return: pandas.Series
|
金十数据-美国国内生产总值(GDP)报告, 数据区间从 20080228-至今
https://datacenter.jin10.com/reportType/dc_usa_gdp
:return: pandas.Series
| 79 | 135 |
def macro_usa_gdp_monthly() -> pd.DataFrame:
"""
金十数据-美国国内生产总值(GDP)报告, 数据区间从 20080228-至今
https://datacenter.jin10.com/reportType/dc_usa_gdp
:return: pandas.Series
"""
t = time.time()
res = requests.get(
JS_USA_GDP_MONTHLY_URL.format(
str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
)
)
json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
date_list = [item["date"] for item in json_data["list"]]
value_list = [item["datas"]["美国国内生产总值(GDP)"] for item in json_data["list"]]
value_df = pd.DataFrame(value_list)
value_df.columns = json_data["kinds"]
value_df.index = pd.to_datetime(date_list)
temp_df = value_df["今值(%)"]
url = "https://datacenter-api.jin10.com/reports/list_v2"
params = {
"max_date": "",
"category": "ec",
"attr_id": "53",
"_": str(int(round(t * 1000))),
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
temp_se = temp_se.iloc[:, 1]
temp_df = temp_df.append(temp_se)
temp_df.dropna(inplace=True)
temp_df.sort_index(inplace=True)
temp_df = temp_df.reset_index()
temp_df.drop_duplicates(subset="index", inplace=True)
temp_df.set_index("index", inplace=True)
temp_df = temp_df.squeeze()
temp_df.index.name = None
temp_df.name = "gdp"
temp_df = temp_df.astype("float")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_usa.py#L79-L135
| 25 |
[
0,
1,
2,
3,
4,
5
] | 10.526316 |
[
6,
7,
12,
13,
14,
15,
16,
17,
18,
19,
20,
26,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56
] | 47.368421 | false | 4.118993 | 57 | 3 | 52.631579 | 3 |
def macro_usa_gdp_monthly() -> pd.DataFrame:
t = time.time()
res = requests.get(
JS_USA_GDP_MONTHLY_URL.format(
str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
)
)
json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
date_list = [item["date"] for item in json_data["list"]]
value_list = [item["datas"]["美国国内生产总值(GDP)"] for item in json_data["list"]]
value_df = pd.DataFrame(value_list)
value_df.columns = json_data["kinds"]
value_df.index = pd.to_datetime(date_list)
temp_df = value_df["今值(%)"]
url = "https://datacenter-api.jin10.com/reports/list_v2"
params = {
"max_date": "",
"category": "ec",
"attr_id": "53",
"_": str(int(round(t * 1000))),
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
temp_se = temp_se.iloc[:, 1]
temp_df = temp_df.append(temp_se)
temp_df.dropna(inplace=True)
temp_df.sort_index(inplace=True)
temp_df = temp_df.reset_index()
temp_df.drop_duplicates(subset="index", inplace=True)
temp_df.set_index("index", inplace=True)
temp_df = temp_df.squeeze()
temp_df.index.name = None
temp_df.name = "gdp"
temp_df = temp_df.astype("float")
return temp_df
| 18,018 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_usa.py
|
macro_usa_cpi_monthly
|
()
|
return temp_df
|
美国CPI月率报告, 数据区间从19700101-至今
https://datacenter.jin10.com/reportType/dc_usa_cpi
https://cdn.jin10.com/dc/reports/dc_usa_cpi_all.js?v=1578741110
:return: 美国CPI月率报告-今值(%)
:rtype: pandas.Series
|
美国CPI月率报告, 数据区间从19700101-至今
https://datacenter.jin10.com/reportType/dc_usa_cpi
https://cdn.jin10.com/dc/reports/dc_usa_cpi_all.js?v=1578741110
:return: 美国CPI月率报告-今值(%)
:rtype: pandas.Series
| 139 | 197 |
def macro_usa_cpi_monthly() -> pd.DataFrame:
"""
美国CPI月率报告, 数据区间从19700101-至今
https://datacenter.jin10.com/reportType/dc_usa_cpi
https://cdn.jin10.com/dc/reports/dc_usa_cpi_all.js?v=1578741110
:return: 美国CPI月率报告-今值(%)
:rtype: pandas.Series
"""
t = time.time()
res = requests.get(
JS_USA_CPI_MONTHLY_URL.format(
str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
)
)
json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
date_list = [item["date"] for item in json_data["list"]]
value_list = [item["datas"]["美国居民消费价格指数(CPI)(月环比)"] for item in json_data["list"]]
value_df = pd.DataFrame(value_list)
value_df.columns = json_data["kinds"]
value_df.index = pd.to_datetime(date_list)
temp_df = value_df["今值(%)"]
url = "https://datacenter-api.jin10.com/reports/list_v2"
params = {
"max_date": "",
"category": "ec",
"attr_id": "9",
"_": str(int(round(t * 1000))),
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
temp_se = temp_se.iloc[:, 1]
temp_df = temp_df.append(temp_se)
temp_df.dropna(inplace=True)
temp_df.sort_index(inplace=True)
temp_df = temp_df.reset_index()
temp_df.drop_duplicates(subset="index", inplace=True)
temp_df.set_index("index", inplace=True)
temp_df = temp_df.squeeze()
temp_df.index.name = None
temp_df.name = "cpi_monthly"
temp_df = temp_df.astype("float")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_usa.py#L139-L197
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7
] | 13.559322 |
[
8,
9,
14,
15,
16,
17,
18,
19,
20,
21,
22,
28,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58
] | 45.762712 | false | 4.118993 | 59 | 3 | 54.237288 | 5 |
def macro_usa_cpi_monthly() -> pd.DataFrame:
t = time.time()
res = requests.get(
JS_USA_CPI_MONTHLY_URL.format(
str(int(round(t * 1000))), str(int(round(t * 1000)) + 90)
)
)
json_data = json.loads(res.text[res.text.find("{") : res.text.rfind("}") + 1])
date_list = [item["date"] for item in json_data["list"]]
value_list = [item["datas"]["美国居民消费价格指数(CPI)(月环比)"] for item in json_data["list"]]
value_df = pd.DataFrame(value_list)
value_df.columns = json_data["kinds"]
value_df.index = pd.to_datetime(date_list)
temp_df = value_df["今值(%)"]
url = "https://datacenter-api.jin10.com/reports/list_v2"
params = {
"max_date": "",
"category": "ec",
"attr_id": "9",
"_": str(int(round(t * 1000))),
}
headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate, br",
"accept-language": "zh-CN,zh;q=0.9,en;q=0.8",
"cache-control": "no-cache",
"origin": "https://datacenter.jin10.com",
"pragma": "no-cache",
"referer": "https://datacenter.jin10.com/reportType/dc_usa_michigan_consumer_sentiment",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-site",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.149 Safari/537.36",
"x-app-id": "rU6QIu7JHe2gOUeR",
"x-csrf-token": "",
"x-version": "1.0.0",
}
r = requests.get(url, params=params, headers=headers)
temp_se = pd.DataFrame(r.json()["data"]["values"]).iloc[:, :2]
temp_se.index = pd.to_datetime(temp_se.iloc[:, 0])
temp_se = temp_se.iloc[:, 1]
temp_df = temp_df.append(temp_se)
temp_df.dropna(inplace=True)
temp_df.sort_index(inplace=True)
temp_df = temp_df.reset_index()
temp_df.drop_duplicates(subset="index", inplace=True)
temp_df.set_index("index", inplace=True)
temp_df = temp_df.squeeze()
temp_df.index.name = None
temp_df.name = "cpi_monthly"
temp_df = temp_df.astype("float")
return temp_df
| 18,019 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_new_house_rate
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-新屋开工
https://data.eastmoney.com/cjsj/foreign_7_0.html
:return: 新屋开工
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-新屋开工
https://data.eastmoney.com/cjsj/foreign_7_0.html
:return: 新屋开工
:rtype: pandas.DataFrame
| 13 | 59 |
def macro_canada_new_house_rate() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-新屋开工
https://data.eastmoney.com/cjsj/foreign_7_0.html
:return: 新屋开工
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342247")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L13-L59
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_new_house_rate() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342247")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,020 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_unemployment_rate
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-失业率
https://data.eastmoney.com/cjsj/foreign_7_1.html
:return: 失业率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-失业率
https://data.eastmoney.com/cjsj/foreign_7_1.html
:return: 失业率
:rtype: pandas.DataFrame
| 63 | 109 |
def macro_canada_unemployment_rate() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-失业率
https://data.eastmoney.com/cjsj/foreign_7_1.html
:return: 失业率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00157746")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L63-L109
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_unemployment_rate() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00157746")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,021 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_trade
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-贸易帐
https://data.eastmoney.com/cjsj/foreign_7_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-贸易帐
https://data.eastmoney.com/cjsj/foreign_7_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
| 113 | 159 |
def macro_canada_trade() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-贸易帐
https://data.eastmoney.com/cjsj/foreign_7_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102022")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L113-L159
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_trade() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102022")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,022 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_retail_rate_monthly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-零售销售月率
https://data.eastmoney.com/cjsj/foreign_7_3.html
:return: 零售销售月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-零售销售月率
https://data.eastmoney.com/cjsj/foreign_7_3.html
:return: 零售销售月率
:rtype: pandas.DataFrame
| 163 | 209 |
def macro_canada_retail_rate_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-零售销售月率
https://data.eastmoney.com/cjsj/foreign_7_3.html
:return: 零售销售月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG01337094")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L163-L209
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_retail_rate_monthly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG01337094")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,023 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_bank_rate
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_7_4.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_7_4.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
| 213 | 259 |
def macro_canada_bank_rate() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-央行公布利率决议
https://data.eastmoney.com/cjsj/foreign_7_4.html
:return: 央行公布利率决议
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342248")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L213-L259
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_bank_rate() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00342248")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,024 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_core_cpi_yearly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-核心消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_5.html
:return: 核心消费者物价指数年率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-核心消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_5.html
:return: 核心消费者物价指数年率
:rtype: pandas.DataFrame
| 263 | 309 |
def macro_canada_core_cpi_yearly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-核心消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_5.html
:return: 核心消费者物价指数年率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102030")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L263-L309
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_core_cpi_yearly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102030")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,025 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_core_cpi_monthly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-核心消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_6.html
:return: 核心消费者物价指数月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-核心消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_6.html
:return: 核心消费者物价指数月率
:rtype: pandas.DataFrame
| 313 | 359 |
def macro_canada_core_cpi_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-核心消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_6.html
:return: 核心消费者物价指数月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102044")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L313-L359
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_core_cpi_monthly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102044")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,026 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_cpi_yearly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_7.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_7.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
| 363 | 409 |
def macro_canada_cpi_yearly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-消费者物价指数年率
https://data.eastmoney.com/cjsj/foreign_7_7.html
:return: 消费者物价指数年率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102029")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L363-L409
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_cpi_yearly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00102029")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,027 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_cpi_monthly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_8.html
:return: 消费者物价指数月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_8.html
:return: 消费者物价指数月率
:rtype: pandas.DataFrame
| 413 | 459 |
def macro_canada_cpi_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-消费者物价指数月率
https://data.eastmoney.com/cjsj/foreign_7_8.html
:return: 消费者物价指数月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00158719")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L413-L459
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_cpi_monthly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00158719")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,028 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_canada.py
|
macro_canada_gdp_monthly
|
()
|
return temp_df
|
东方财富-经济数据-加拿大-GDP 月率
https://data.eastmoney.com/cjsj/foreign_7_9.html
:return: GDP 月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-加拿大-GDP 月率
https://data.eastmoney.com/cjsj/foreign_7_9.html
:return: GDP 月率
:rtype: pandas.DataFrame
| 463 | 509 |
def macro_canada_gdp_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-加拿大-GDP 月率
https://data.eastmoney.com/cjsj/foreign_7_9.html
:return: GDP 月率
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00159259")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_canada.py#L463-L509
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 14.893617 |
[
7,
8,
23,
24,
25,
26,
37,
43,
44,
45,
46
] | 23.404255 | false | 9.722222 | 47 | 1 | 76.595745 | 4 |
def macro_canada_gdp_monthly() -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_CA",
"columns": "ALL",
"filter": '(INDICATOR_ID="EMG00159259")',
"pageNumber": "1",
"pageSize": "2000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1669047266881",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.columns = [
"-",
"-",
"-",
"-",
"时间",
"-",
"发布日期",
"现值",
"前值",
]
temp_df = temp_df[[
"时间",
"前值",
"现值",
"发布日期",
]]
temp_df["前值"] = pd.to_numeric(temp_df["前值"], errors="coerce")
temp_df["现值"] = pd.to_numeric(temp_df["现值"], errors="coerce")
temp_df['发布日期'] = pd.to_datetime(temp_df['发布日期']).dt.date
return temp_df
| 18,029 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_uk.py
|
macro_uk_core
|
(symbol: str = "EMG00010348")
|
return temp_df
|
东方财富-数据中心-经济数据一览-宏观经济-英国-核心代码
https://data.eastmoney.com/cjsj/foreign_4_0.html
:param symbol: 代码
:type symbol: str
:return: 指定 symbol 的数据
:rtype: pandas.DataFrame
|
东方财富-数据中心-经济数据一览-宏观经济-英国-核心代码
https://data.eastmoney.com/cjsj/foreign_4_0.html
:param symbol: 代码
:type symbol: str
:return: 指定 symbol 的数据
:rtype: pandas.DataFrame
| 12 | 66 |
def macro_uk_core(symbol: str = "EMG00010348") -> pd.DataFrame:
"""
东方财富-数据中心-经济数据一览-宏观经济-英国-核心代码
https://data.eastmoney.com/cjsj/foreign_4_0.html
:param symbol: 代码
:type symbol: str
:return: 指定 symbol 的数据
:rtype: pandas.DataFrame
"""
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_BRITAIN",
"columns": "ALL",
"filter": f'(INDICATOR_ID="{symbol}")',
"pageNumber": "1",
"pageSize": "5000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1667639896816",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.rename(
columns={
"COUNTRY": "-",
"INDICATOR_ID": "-",
"INDICATOR_NAME": "-",
"REPORT_DATE_CH": "时间",
"REPORT_DATE": "-",
"PUBLISH_DATE": "发布日期",
"VALUE": "现值",
"PRE_VALUE": "前值",
"INDICATOR_IDOLD": "-",
},
inplace=True,
)
temp_df = temp_df[
[
"时间",
"前值",
"现值",
"发布日期",
]
]
temp_df["前值"] = pd.to_numeric(temp_df["前值"])
temp_df["现值"] = pd.to_numeric(temp_df["现值"])
temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"]).dt.date
temp_df.sort_values(["发布日期"], inplace=True, ignore_index=True)
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_uk.py#L12-L66
| 25 |
[
0,
1,
2,
3,
4,
5,
6,
7,
8
] | 16.363636 |
[
9,
10,
25,
26,
27,
28,
42,
50,
51,
52,
53,
54
] | 21.818182 | false | 21.73913 | 55 | 1 | 78.181818 | 6 |
def macro_uk_core(symbol: str = "EMG00010348") -> pd.DataFrame:
url = "https://datacenter-web.eastmoney.com/api/data/v1/get"
params = {
"reportName": "RPT_ECONOMICVALUE_BRITAIN",
"columns": "ALL",
"filter": f'(INDICATOR_ID="{symbol}")',
"pageNumber": "1",
"pageSize": "5000",
"sortColumns": "REPORT_DATE",
"sortTypes": "-1",
"source": "WEB",
"client": "WEB",
"p": "1",
"pageNo": "1",
"pageNum": "1",
"_": "1667639896816",
}
r = requests.get(url, params=params)
data_json = r.json()
temp_df = pd.DataFrame(data_json["result"]["data"])
temp_df.rename(
columns={
"COUNTRY": "-",
"INDICATOR_ID": "-",
"INDICATOR_NAME": "-",
"REPORT_DATE_CH": "时间",
"REPORT_DATE": "-",
"PUBLISH_DATE": "发布日期",
"VALUE": "现值",
"PRE_VALUE": "前值",
"INDICATOR_IDOLD": "-",
},
inplace=True,
)
temp_df = temp_df[
[
"时间",
"前值",
"现值",
"发布日期",
]
]
temp_df["前值"] = pd.to_numeric(temp_df["前值"])
temp_df["现值"] = pd.to_numeric(temp_df["现值"])
temp_df["发布日期"] = pd.to_datetime(temp_df["发布日期"]).dt.date
temp_df.sort_values(["发布日期"], inplace=True, ignore_index=True)
return temp_df
| 18,030 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_uk.py
|
macro_uk_halifax_monthly
|
()
|
return temp_df
|
东方财富-经济数据-英国-Halifax 房价指数月率
https://data.eastmoney.com/cjsj/foreign_4_0.html
:return: Halifax 房价指数月率
:rtype: pandas.DataFrame
|
东方财富-经济数据-英国-Halifax 房价指数月率
https://data.eastmoney.com/cjsj/foreign_4_0.html
:return: Halifax 房价指数月率
:rtype: pandas.DataFrame
| 70 | 78 |
def macro_uk_halifax_monthly() -> pd.DataFrame:
"""
东方财富-经济数据-英国-Halifax 房价指数月率
https://data.eastmoney.com/cjsj/foreign_4_0.html
:return: Halifax 房价指数月率
:rtype: pandas.DataFrame
"""
temp_df = macro_uk_core(symbol="EMG00342256")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_uk.py#L70-L78
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 77.777778 |
[
7,
8
] | 22.222222 | false | 21.73913 | 9 | 1 | 77.777778 | 4 |
def macro_uk_halifax_monthly() -> pd.DataFrame:
temp_df = macro_uk_core(symbol="EMG00342256")
return temp_df
| 18,031 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_uk.py
|
macro_uk_halifax_yearly
|
()
|
return temp_df
|
东方财富-经济数据-英国-Halifax 房价指数年率
https://data.eastmoney.com/cjsj/foreign_4_1.html
:return: Halifax房价指数年率
:rtype: pandas.DataFrame
|
东方财富-经济数据-英国-Halifax 房价指数年率
https://data.eastmoney.com/cjsj/foreign_4_1.html
:return: Halifax房价指数年率
:rtype: pandas.DataFrame
| 82 | 90 |
def macro_uk_halifax_yearly() -> pd.DataFrame:
"""
东方财富-经济数据-英国-Halifax 房价指数年率
https://data.eastmoney.com/cjsj/foreign_4_1.html
:return: Halifax房价指数年率
:rtype: pandas.DataFrame
"""
temp_df = macro_uk_core(symbol="EMG00010370")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_uk.py#L82-L90
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 77.777778 |
[
7,
8
] | 22.222222 | false | 21.73913 | 9 | 1 | 77.777778 | 4 |
def macro_uk_halifax_yearly() -> pd.DataFrame:
temp_df = macro_uk_core(symbol="EMG00010370")
return temp_df
| 18,032 |
akfamily/akshare
|
087025d8d6f799b30ca114013e82c1ad22dc9294
|
akshare/economic/macro_uk.py
|
macro_uk_trade
|
()
|
return temp_df
|
东方财富-经济数据-英国-贸易帐
https://data.eastmoney.com/cjsj/foreign_4_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
|
东方财富-经济数据-英国-贸易帐
https://data.eastmoney.com/cjsj/foreign_4_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
| 94 | 102 |
def macro_uk_trade() -> pd.DataFrame:
"""
东方财富-经济数据-英国-贸易帐
https://data.eastmoney.com/cjsj/foreign_4_2.html
:return: 贸易帐
:rtype: pandas.DataFrame
"""
temp_df = macro_uk_core(symbol="EMG00158309")
return temp_df
|
https://github.com/akfamily/akshare/blob/087025d8d6f799b30ca114013e82c1ad22dc9294/project25/akshare/economic/macro_uk.py#L94-L102
| 25 |
[
0,
1,
2,
3,
4,
5,
6
] | 77.777778 |
[
7,
8
] | 22.222222 | false | 21.73913 | 9 | 1 | 77.777778 | 4 |
def macro_uk_trade() -> pd.DataFrame:
temp_df = macro_uk_core(symbol="EMG00158309")
return temp_df
| 18,033 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.