siat 3.10.125__py3-none-any.whl → 3.10.126__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- siat/common.py +106 -2
- siat/exchange_bond_china.pickle +0 -0
- siat/fund_china.pickle +0 -0
- siat/stock.py +10 -2
- siat/stock_info.pickle +0 -0
- {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/METADATA +234 -226
- siat-3.10.126.dist-info/RECORD +76 -0
- {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/WHEEL +1 -1
- {siat-3.10.125.dist-info → siat-3.10.126.dist-info/licenses}/LICENSE +0 -0
- {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/top_level.txt +0 -0
- siat/__init__ -20240701.py +0 -65
- siat/__init__.py.backup_20250214.py +0 -73
- siat/alpha_vantage_test.py +0 -24
- siat/assets_liquidity_test.py +0 -44
- siat/barrons_scraping_test.py +0 -276
- siat/beta_adjustment_test.py +0 -77
- siat/bond_test.py +0 -142
- siat/capm_beta_test.py +0 -49
- siat/cmat_commons.py +0 -961
- siat/compare_cross_test.py +0 -117
- siat/concepts_iwencai.py +0 -86
- siat/concepts_kpl.py +0 -93
- siat/cryptocurrency_test.py +0 -71
- siat/derivative.py +0 -1111
- siat/economy-20230125.py +0 -1206
- siat/economy_test.py +0 -360
- siat/esg_test.py +0 -63
- siat/fama_french_test.py +0 -115
- siat/financial_statements_test.py +0 -31
- siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
- siat/financials_china2_test.py +0 -67
- siat/financials_china2_test2.py +0 -88
- siat/financials_china2_test3.py +0 -87
- siat/financials_china_test.py +0 -475
- siat/financials_china_test2.py +0 -197
- siat/financials_china_test2_fin_indicator.py +0 -197
- siat/financials_test.py +0 -713
- siat/fred_test.py +0 -40
- siat/fund_china_test.py +0 -175
- siat/fund_test.py +0 -40
- siat/future_china_test.py +0 -37
- siat/global_index_test.py +0 -66
- siat/grafix_test.py +0 -112
- siat/holding_risk_test.py +0 -13
- siat/local_debug_test.py +0 -100
- siat/markowitz2-20240620.py +0 -2614
- siat/markowitz_ccb_test.py +0 -37
- siat/markowitz_ef_test.py +0 -136
- siat/markowitz_old.py +0 -871
- siat/markowitz_simple-20230709.py +0 -370
- siat/markowitz_test.py +0 -164
- siat/markowitz_test2.py +0 -69
- siat/ml_cases_example1.py +0 -60
- siat/option_china_test.py +0 -447
- siat/option_pricing_test.py +0 -81
- siat/option_sina_api_test.py +0 -112
- siat/proxy_test.py +0 -84
- siat/quandl_test.py +0 -39
- siat/risk_adjusted_return_test.py +0 -81
- siat/risk_evaluation_test.py +0 -96
- siat/risk_free_rate_test.py +0 -127
- siat/sector_china_test.py +0 -203
- siat/security_price.py +0 -831
- siat/security_prices_test.py +0 -310
- siat/security_trend2-20240620.py +0 -493
- siat/setup.py +0 -41
- siat/shenwan index history test.py +0 -41
- siat/stock_china_test.py +0 -38
- siat/stock_info_test.py +0 -189
- siat/stock_list_china_test.py +0 -33
- siat/stock_technical-20240620.py +0 -2736
- siat/stock_test.py +0 -487
- siat/temp.py +0 -36
- siat/test2_graphviz.py +0 -484
- siat/test_graphviz.py +0 -411
- siat/test_markowitz_simple.py +0 -198
- siat/test_markowitz_simple_revised.py +0 -215
- siat/test_markowitz_simple_revised2.py +0 -218
- siat/transaction_test.py +0 -436
- siat/translate-20230125.py +0 -2107
- siat/translate-20230206.py +0 -2109
- siat/translate-20230215.py +0 -2158
- siat/translate_20240606.py +0 -4206
- siat/translate_241003_keep.py +0 -4300
- siat/universal_test.py +0 -100
- siat/valuation_market_china_test.py +0 -36
- siat-3.10.125.dist-info/RECORD +0 -152
siat/fred_test.py
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import pandas as pd
|
4
|
-
#if you get an error after executing the code, try adding below:
|
5
|
-
pd.core.common.is_list_like = pd.api.types.is_list_like
|
6
|
-
|
7
|
-
import pandas_datareader.data as web
|
8
|
-
import datetime
|
9
|
-
|
10
|
-
start = datetime.datetime(2021, 1, 1)
|
11
|
-
end = datetime.datetime(2021, 11, 30)
|
12
|
-
|
13
|
-
sp500 = web.DataReader(['sp500'], 'fred', start, end)
|
14
|
-
djia = web.DataReader(['djia'], 'fred', start, end)
|
15
|
-
|
16
|
-
hk50 = web.DataReader(['hk50'], 'fred', start, end) #失败
|
17
|
-
|
18
|
-
def get_index_fred(ticker,start,end):
|
19
|
-
"""
|
20
|
-
功能:替代雅虎不能用的临时解决方案,获取标普500、道琼斯等指数
|
21
|
-
"""
|
22
|
-
yahoolist=['^GSPC','^DJI','^VIX','^IXIC','^N225','^NDX']
|
23
|
-
fredlist=['sp500','djia','vixcls','nasdaqcom','nikkei225','nasdaq100']
|
24
|
-
|
25
|
-
if not (ticker in tidailist):
|
26
|
-
return None
|
27
|
-
|
28
|
-
import pandas as pd
|
29
|
-
import pandas_datareader.data as web
|
30
|
-
if ticker in yahoolist:
|
31
|
-
pos=yahoolist.index(ticker)
|
32
|
-
id=fredlist[pos]
|
33
|
-
|
34
|
-
df = web.DataReader([id], 'fred', start, end)
|
35
|
-
df.rename(columns={id:'Close'},inplace=True)
|
36
|
-
|
37
|
-
#删除空值记录
|
38
|
-
df.dropna(inplace=True)
|
39
|
-
|
40
|
-
return df
|
siat/fund_china_test.py
DELETED
@@ -1,175 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
# 绝对引用指定目录中的模块
|
4
|
-
|
5
|
-
import os; os.chdir("S:/siat")
|
6
|
-
from siat import *
|
7
|
-
#==============================================================================
|
8
|
-
df=etf_trend_china('510580','2022-1-1','2022-4-30',loc1='center left')
|
9
|
-
|
10
|
-
|
11
|
-
df=oef_trend_china('000592','2021-1-1','2021-3-31',trend_type='收益率',power=5)
|
12
|
-
df = mmf_rank_china()
|
13
|
-
|
14
|
-
df=mmf_trend_china('320019','2020-7-1','2020-9-30', power=1)
|
15
|
-
df=mmf_trend_china('001234','2021-1-1','2022-1-31', power=1)
|
16
|
-
df2=mmf_trend_china('004972','2021-1-1','2022-1-31', power=1)
|
17
|
-
df3=mmf_trend_china('004137','2021-1-1','2022-1-31', power=1)
|
18
|
-
df4=mmf_trend_china('002890','2021-1-1','2022-1-31', power=1)
|
19
|
-
df5=mmf_trend_china('004417','2021-1-1','2022-1-31', power=1)
|
20
|
-
df6=mmf_trend_china('005151','2021-1-1','2022-1-31', power=1)
|
21
|
-
df7=mmf_trend_china('001909','2021-1-1','2022-1-31', power=1)
|
22
|
-
df8=mmf_trend_china('001821','2021-1-1','2022-1-31', power=1)
|
23
|
-
df9=mmf_trend_china('000836','2021-1-1','2022-1-31', power=1)
|
24
|
-
df10=mmf_trend_china('000700','2021-1-1','2022-1-31', power=1)
|
25
|
-
#==============================================================================
|
26
|
-
df10 = ak.fund_em_exchange_rank()
|
27
|
-
df10s=df10[['基金代码','基金简称','单位净值','近1年']]
|
28
|
-
df10s2=df10s[df10s['近1年']!='']
|
29
|
-
|
30
|
-
df10s2['近1年']=df10s2['近1年'].astype('float')
|
31
|
-
df10s.sort_values(by=['近1年'],ascending=False, inplace=True)
|
32
|
-
df10s.reset_index(drop=True,inplace=True)
|
33
|
-
df10s.head(10)
|
34
|
-
|
35
|
-
#==============================================================================
|
36
|
-
df90_lof=ak.fund_etf_category_sina(symbol="LOF基金") #可选参数为: 封闭式基金, ETF基金, LOF基金
|
37
|
-
df90_lof_s=df90_etf_s[df90_etf_s["LOF"]==True]
|
38
|
-
|
39
|
-
df90_cef=ak.fund_etf_category_sina(symbol="封闭式基金")
|
40
|
-
|
41
|
-
df90_etf=ak.fund_etf_category_sina(symbol="ETF基金")
|
42
|
-
df90_etf_s=df90_etf[['代码','名称']]
|
43
|
-
df90_etf_s["沪深300"]= df90_etf_s["名称"].str.contains('沪深300')
|
44
|
-
df90_etf_s1=df90_etf_s[df90_etf_s["沪深300"]==True]
|
45
|
-
|
46
|
-
df90_etf_s["上证50"]= df90_etf_s["名称"].str.contains('上证50')
|
47
|
-
df90_etf_s2=df90_etf_s[df90_etf_s["上证50"]==True]
|
48
|
-
|
49
|
-
df90_etf_s["中证500"]= df90_etf_s["名称"].str.contains('中证500')
|
50
|
-
df90_etf_s3=df90_etf_s[df90_etf_s["中证500"]==True]
|
51
|
-
|
52
|
-
df90_etf_s["上证综指"]= df90_etf_s["名称"].str.contains('上证综指')
|
53
|
-
df90_etf_s5=df90_etf_s[df90_etf_s["上证综指"]==True]
|
54
|
-
|
55
|
-
df90_etf_s["标普500"]= df90_etf_s["名称"].str.contains('标普500')
|
56
|
-
df90_etf_s6=df90_etf_s[df90_etf_s["标普500"]==True]
|
57
|
-
|
58
|
-
df90_etf_s["纳斯达克"]= df90_etf_s["名称"].str.contains('纳')
|
59
|
-
df90_etf_s7=df90_etf_s[df90_etf_s["纳斯达克"]==True]
|
60
|
-
|
61
|
-
df90_etf_s["恒生"]= df90_etf_s["名称"].str.contains('恒生')
|
62
|
-
df90_etf_s8=df90_etf_s[df90_etf_s["恒生"]==True]
|
63
|
-
|
64
|
-
df90_etf_s["日经"]= df90_etf_s["名称"].str.contains('日经')
|
65
|
-
df90_etf_s9=df90_etf_s[df90_etf_s["日经"]==True]
|
66
|
-
|
67
|
-
df90_etf_s["深证成指"]= df90_etf_s["名称"].str.contains('深证成指')
|
68
|
-
df90_etf_s10=df90_etf_s[df90_etf_s["深证成指"]==True]
|
69
|
-
|
70
|
-
df90_etf_s["CAC"]= df90_etf_s["名称"].str.contains('CAC')
|
71
|
-
df90_etf_s11=df90_etf_s[df90_etf_s["CAC"]==True]
|
72
|
-
|
73
|
-
df90_etf_s["富时"]= df90_etf_s["名称"].str.contains('富时')
|
74
|
-
df90_etf_s12=df90_etf_s[df90_etf_s["富时"]==True]
|
75
|
-
|
76
|
-
df90_etf_s["债指"]= df90_etf_s["名称"].str.contains('债')
|
77
|
-
df90_etf_s13=df90_etf_s[df90_etf_s["债指"]==True]
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
df90 = ak.fund_etf_hist_sina(symbol="sz169103")
|
82
|
-
|
83
|
-
#==============================================================================
|
84
|
-
df=security_price("169103.SZ",'2021-7-1','2021-10-15')
|
85
|
-
df=security_price("180801.SZ",'2021-7-1','2021-10-15')
|
86
|
-
|
87
|
-
df1=fund_stock_holding_compare_china('005827.SS','2021Q1','2021Q2')
|
88
|
-
df2=fund_stock_holding_rank_china('005827')
|
89
|
-
|
90
|
-
|
91
|
-
df=reits_profile_china()
|
92
|
-
df=reits_profile_china(top = 3)
|
93
|
-
df=reits_profile_china(top = -3)
|
94
|
-
df=reits_profile_china('508056')
|
95
|
-
#==============================================================================
|
96
|
-
from siat.translate import *
|
97
|
-
|
98
|
-
#==============================================================================
|
99
|
-
from siat import *
|
100
|
-
df=oef_rank_china('单位净值','全部类型')
|
101
|
-
set(list(df['基金类型'])) #基金类别列表
|
102
|
-
set(list(df['基金代码'])) #基金个数
|
103
|
-
df=oef_trend_china('180801','2020-1-1','2021-9-30',"收益率")
|
104
|
-
|
105
|
-
import akshare as ak
|
106
|
-
df = ak.fund_em_open_fund_info(fund="710001", indicator="累计收益率走势")
|
107
|
-
df=oef_trend_china('710001','2020-1-1','2021-9-30',"收益率")
|
108
|
-
#==============================================================================
|
109
|
-
df=oef_trend_china('000592','2021-1-1','2021-3-31',trend_type='收益率',power=5)
|
110
|
-
|
111
|
-
df=mmf_trend_china('320019','2020-7-1','2020-9-30',power=1)
|
112
|
-
|
113
|
-
df=oef_trend_china('000595','2019-1-1','2020-12-31',trend_type='净值')
|
114
|
-
df=oef_trend_china('000592','2021-1-1','2021-3-31',trend_type='收益率',power=5)
|
115
|
-
df=oef_trend_china('050111','2020-9-1','2020-9-30',trend_type='排名')
|
116
|
-
df=mmf_trend_china('320019','2020-7-1','2020-9-30',power=3)
|
117
|
-
df=etf_trend_china('510580','2019-1-1','2020-9-30')
|
118
|
-
|
119
|
-
#==============================================================================
|
120
|
-
|
121
|
-
df=oef_rank_china('单位净值','全部类型')
|
122
|
-
|
123
|
-
|
124
|
-
df=pof_list_china()
|
125
|
-
|
126
|
-
|
127
|
-
df=oef_rank_china('单位净值','全部类型')
|
128
|
-
df=oef_rank_china('累计净值','全部类型')
|
129
|
-
df=oef_rank_china('手续费','全部类型')
|
130
|
-
|
131
|
-
|
132
|
-
df=oef_rank_china('单位净值','股票型')
|
133
|
-
df=oef_rank_china('累计净值','股票型')
|
134
|
-
|
135
|
-
|
136
|
-
df=oef_rank_china('单位净值','债券型')
|
137
|
-
df=oef_rank_china('累计净值','债券型')
|
138
|
-
|
139
|
-
df=oef_trend_china('519035','2019-1-1','2020-10-16',trend_type='净值')
|
140
|
-
|
141
|
-
df=oef_trend_china('519035','2020-5-1','2020-10-16',trend_type='收益率',power=5)
|
142
|
-
|
143
|
-
df=oef_trend_china('519035','2020-9-1','2020-9-30',trend_type='排名')
|
144
|
-
|
145
|
-
|
146
|
-
df=oef_trend_china('000595','2019-1-1','2020-10-16',trend_type='净值')
|
147
|
-
df=oef_trend_china('000592','2020-7-1','2020-9-30',trend_type='收益率',power=5)
|
148
|
-
df=oef_trend_china('050111','2020-9-1','2020-9-30',trend_type='排名')
|
149
|
-
|
150
|
-
df = ak.fund_em_money_fund_daily()
|
151
|
-
df = mmf_rank_china()
|
152
|
-
|
153
|
-
df=mmf_trend_china('320019','2020-7-1','2020-9-30',power=1)
|
154
|
-
|
155
|
-
amac_member_list=list(set(list(amac_member_info_df['机构类型'])))
|
156
|
-
|
157
|
-
df=etf_rank_china(info_type='单位净值',fund_type='全部类型')
|
158
|
-
df=etf_rank_china(info_type='累计净值')
|
159
|
-
df=etf_trend_china('510580','2019-1-1','2020-9-30')
|
160
|
-
|
161
|
-
|
162
|
-
from siat.fund_china import *
|
163
|
-
df=fund_summary_china()
|
164
|
-
|
165
|
-
df=pef_manager_china()
|
166
|
-
df=pef_manager_china("广东省")
|
167
|
-
df=pef_manager_china("上海市")
|
168
|
-
df=pef_manager_china("北京市")
|
169
|
-
df=pef_product_china()
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
siat/fund_test.py
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
"""
|
3
|
-
Created on Sun Oct 18 20:02:52 2020
|
4
|
-
|
5
|
-
@author: Peter
|
6
|
-
"""
|
7
|
-
|
8
|
-
import os; os.chdir("S:/siat")
|
9
|
-
from siat.fund import *
|
10
|
-
|
11
|
-
df=pof_list_china()
|
12
|
-
|
13
|
-
|
14
|
-
df=oef_rank_china('单位净值','全部类型')
|
15
|
-
df=oef_rank_china('累计净值','全部类型')
|
16
|
-
df=oef_rank_china('手续费','全部类型')
|
17
|
-
|
18
|
-
|
19
|
-
df=oef_rank_china('单位净值','股票型')
|
20
|
-
df=oef_rank_china('累计净值','股票型')
|
21
|
-
|
22
|
-
|
23
|
-
df=oef_rank_china('单位净值','债券型')
|
24
|
-
df=oef_rank_china('累计净值','债券型')
|
25
|
-
|
26
|
-
df=oef_trend_china('519035','2019-1-1','2020-10-16',trend_type='净值')
|
27
|
-
|
28
|
-
df=oef_trend_china('519035','2020-5-1','2020-10-16',trend_type='收益率',power=5)
|
29
|
-
|
30
|
-
df=oef_trend_china('519035','2020-9-1','2020-9-30',trend_type='排名')
|
31
|
-
|
32
|
-
|
33
|
-
df=oef_trend_china('000595','2019-1-1','2020-10-16',trend_type='净值')
|
34
|
-
df=oef_trend_china('000592','2020-7-1','2020-9-30',trend_type='收益率',power=5)
|
35
|
-
df=oef_trend_china('050111','2020-9-1','2020-9-30',trend_type='排名')
|
36
|
-
|
37
|
-
df = ak.fund_em_money_fund_daily()
|
38
|
-
df = mmf_rank_china()
|
39
|
-
|
40
|
-
df=mmf_trend_china('320019','2020-7-1','2020-9-30',power=1)
|
siat/future_china_test.py
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
# 绝对引用指定目录中的模块
|
3
|
-
import sys
|
4
|
-
sys.path.insert(0,r'S:\siat\siat')
|
5
|
-
|
6
|
-
from future_china import *
|
7
|
-
|
8
|
-
clist=[0.021,0.024,0.027,0.03,0.04,0.05,0.06]
|
9
|
-
df=cf_day_coupon_trend(clist,30,10,2,0.03)
|
10
|
-
|
11
|
-
#=====内盘期货=====
|
12
|
-
#列示全部品种与代码
|
13
|
-
df=future_type_china()
|
14
|
-
|
15
|
-
#列示某个期货品种的基本信息
|
16
|
-
df=future_type_china("SC")
|
17
|
-
|
18
|
-
#列示某个品种在某个时间段的所有合约
|
19
|
-
df=future_price_china("SC","2021-8-1","2022-1-31")
|
20
|
-
|
21
|
-
#列示某个合约在某个时间段的交易状况
|
22
|
-
df=future_price_china("SC2406","2021-8-1","2021-8-31")
|
23
|
-
|
24
|
-
#=====外盘期货(品种与合约合一)=====
|
25
|
-
#列示全部品种与代码
|
26
|
-
df=future_type_foreign()
|
27
|
-
|
28
|
-
#列示某个期货品种的基本信息
|
29
|
-
df=future_type_foreign("AHD")
|
30
|
-
|
31
|
-
#列示某个合约在某个时间段的交易状况
|
32
|
-
df=future_price_foreign("AHD","2021-8-1","2021-8-31")
|
33
|
-
|
34
|
-
#==========================================================================================
|
35
|
-
import akshare as ak
|
36
|
-
futures_rule_df = ak.futures_rule(date="20200713")
|
37
|
-
#==========================================================================================
|
siat/global_index_test.py
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir("S:/siat")
|
4
|
-
from siat import *
|
5
|
-
|
6
|
-
#==============================================================================
|
7
|
-
if __name__=='__main__':
|
8
|
-
yahoo_index='^VIX'
|
9
|
-
start='19910101'
|
10
|
-
end='20101231'
|
11
|
-
freq='daily'
|
12
|
-
|
13
|
-
def get_index_investing(yahoo_index,start,end,freq='daily'):
|
14
|
-
"""
|
15
|
-
功能:获得全球指数历史行情
|
16
|
-
数据源:https://cn.investing.com/indices/
|
17
|
-
输入:雅虎财经指数代码
|
18
|
-
输出:历史行情df
|
19
|
-
注意:
|
20
|
-
"""
|
21
|
-
import pandas as pd
|
22
|
-
freq_cvt=pd.DataFrame([
|
23
|
-
['daily','每日'],['weekly','每周'],['monthly','每月'],
|
24
|
-
], columns=['freq','freq_investing'])
|
25
|
-
try:
|
26
|
-
freq_investing=freq_cvt[freq_cvt['freq']==freq]['freq_investing'].values[0]
|
27
|
-
except:
|
28
|
-
#未查到
|
29
|
-
freq_investing='每日'
|
30
|
-
|
31
|
-
index_cvt=pd.DataFrame([
|
32
|
-
['^RUT','美国','罗素2000小盘股'],['^VIX','美国','VIX恐慌指数'],
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
], columns=['yahoo_index','country','investing_index'])
|
39
|
-
|
40
|
-
try:
|
41
|
-
country=index_cvt[index_cvt['yahoo_index']==yahoo_index]['country'].values[0]
|
42
|
-
investing_index=index_cvt[index_cvt['yahoo_index']==yahoo_index]['investing_index'].values[0]
|
43
|
-
except:
|
44
|
-
#未查到
|
45
|
-
return None
|
46
|
-
|
47
|
-
|
48
|
-
import akshare as ak
|
49
|
-
df = ak.index_investing_global(country=country, index_name=investing_index, \
|
50
|
-
period=freq_investing, start_date=start, end_date=end)
|
51
|
-
print(index_investing_global_df)
|
52
|
-
|
53
|
-
|
54
|
-
df = ak.index_investing_global(country="美国", index_name="VIX恐慌指数", period="每月", start_date="2005-01-01", end_date="2020-06-05")
|
55
|
-
ak.index_investing_global_country_name_url("美国")
|
56
|
-
|
57
|
-
|
58
|
-
ak.index_investing_global(country="美国", index_name="VIX恐慌指数", period="每月", start_date="2005-01-01", end_date="2020-06-05")
|
59
|
-
|
60
|
-
|
61
|
-
index_investing_global_df = ak.index_investing_global(country="中国", index_name="富时中国A50指数", period="每日", start_date="20000101", end_date="20210909")
|
62
|
-
print(index_investing_global_df)
|
63
|
-
|
64
|
-
|
65
|
-
index_investing_global_df = ak.index_investing_global_from_url(url="https://www.investing.com/indices/ftse-epra-nareit-hong-kong", period="每日", start_date="19900101", end_date="20210909")
|
66
|
-
print(index_investing_global_df)
|
siat/grafix_test.py
DELETED
@@ -1,112 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir('S:/siat')
|
4
|
-
from siat import *
|
5
|
-
|
6
|
-
|
7
|
-
df=security_price('000300.SS','2004-1-1','2022-4-30',power=1)
|
8
|
-
#==============================================================================
|
9
|
-
hhstocks=['600221.SS','600115.SS','600029.SS']
|
10
|
-
cfps=compare_snapshot(hhstocks,'Cashflow per Share')
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
#==============================================================================
|
15
|
-
|
16
|
-
df=get_prices('INTC','2021-1-1','2021-3-31')
|
17
|
-
df.Close.plot()
|
18
|
-
|
19
|
-
dfm=df_smooth(df,method='pchip',sampling='H',order=3)
|
20
|
-
dfm.Close.plot()
|
21
|
-
|
22
|
-
dfa=df_smooth(df,method='akima')
|
23
|
-
dfa.Close.plot()
|
24
|
-
|
25
|
-
#==============================================================================
|
26
|
-
|
27
|
-
df.plot(y=['High','Close','Low'])
|
28
|
-
|
29
|
-
#================
|
30
|
-
#按照小时为单位重新采样日期时间
|
31
|
-
dfh=df.resample('H')
|
32
|
-
methodlist=['quadratic','cubic','slinear','linear','zero','nearest','time','index','barycentric', \
|
33
|
-
'krogh','piecewise_polynomial','pchip','akima','from_derivatives']
|
34
|
-
for m in methodlist:
|
35
|
-
dfm=dfh.interpolate(method=m)
|
36
|
-
dfm.plot(y=['High','Close','Low'],xlabel='Method = '+m)
|
37
|
-
#结果:pchip效果最真实,akima也不错
|
38
|
-
|
39
|
-
methodlist_o=['spline','polynomial']
|
40
|
-
orderlist=[1,2,3,4,5,6]
|
41
|
-
for mo in methodlist_o:
|
42
|
-
for od in orderlist:
|
43
|
-
try:
|
44
|
-
dfm=dfh.interpolate(method=mo,order=od)
|
45
|
-
dfm.plot(y=['High','Close','Low'],xlabel='Method = '+mo+', order = '+str(od))
|
46
|
-
except: continue
|
47
|
-
#结果:效果都不佳
|
48
|
-
#===================
|
49
|
-
|
50
|
-
dfh=df.resample('H')
|
51
|
-
dfhp=dfh.interpolate(method='pchip')
|
52
|
-
|
53
|
-
import matplotlib.pyplot as plt
|
54
|
-
# 解决中文显示问题:SimHei黑体 FangSong仿宋
|
55
|
-
plt.rcParams['font.sans-serif'] = ['SimHei']
|
56
|
-
plt.rcParams['axes.unicode_minus'] = False
|
57
|
-
|
58
|
-
titletxt='绘图'
|
59
|
-
stylelist=[]
|
60
|
-
footnote='日期'
|
61
|
-
ylabeltxtleft='收盘价'
|
62
|
-
ylabeltxtright='最高价'
|
63
|
-
dfh.Close.plot(title=titletxt,legend=True,xlabel=footnote,ylabel=ylabeltxt,fontsize=8)
|
64
|
-
|
65
|
-
dfhp[['High','Close']].plot(secondary_y=['High'])
|
66
|
-
ax=dfhp.plot(y=['High','Close'],secondary_y=['High'])
|
67
|
-
ax.set_ylabel(ylabeltxtleft)
|
68
|
-
ax.right_ax.set_ylabel(ylabeltxtright)
|
69
|
-
|
70
|
-
dfhc.plot(y=['Close'])
|
71
|
-
dfhc.plot(y=['High'],secondary_y=True)
|
72
|
-
plt.show()
|
73
|
-
|
74
|
-
|
75
|
-
import matplotlib.pyplot as plt
|
76
|
-
# 解决中文显示问题:SimHei黑体 FangSong仿宋
|
77
|
-
plt.rcParams['font.sans-serif'] = ['SimHei']
|
78
|
-
plt.rcParams['axes.unicode_minus'] = False
|
79
|
-
|
80
|
-
x=dfhc.index; y=dfhc.Close
|
81
|
-
|
82
|
-
plt.plot(x, y, linewidth=1)
|
83
|
-
plt.title("绘图", fontsize=14)#标题及字号
|
84
|
-
plt.xlabel("X", fontsize=12)#X轴标题及字号
|
85
|
-
plt.ylabel("Y", fontsize=12)#Y轴标题及字号
|
86
|
-
plt.tick_params(axis='both', labelsize=8)#刻度大小
|
87
|
-
plt.show()
|
88
|
-
|
89
|
-
|
90
|
-
#==============================================================================
|
91
|
-
from siat import *
|
92
|
-
plot_norm(0,1,'pdf')
|
93
|
-
plot_norm(0,1,'pdf',200)
|
94
|
-
|
95
|
-
plot_norm(0,1,'cdf')
|
96
|
-
plot_norm(0,1,'cdf',200)
|
97
|
-
|
98
|
-
plot_norm(0,1,'ppf')
|
99
|
-
plot_norm(0,1,'ppf',200)
|
100
|
-
|
101
|
-
import scipy.stats as st
|
102
|
-
st.norm.cdf(0)
|
103
|
-
st.norm.cdf(1)
|
104
|
-
st.norm.cdf(2)
|
105
|
-
st.norm.cdf(2.43)
|
106
|
-
st.norm.cdf(3)
|
107
|
-
|
108
|
-
st.norm.ppf(0.5)
|
109
|
-
st.norm.ppf(0.8)
|
110
|
-
st.norm.ppf(0.9)
|
111
|
-
st.norm.ppf(0.95)
|
112
|
-
st.norm.ppf(0.99)
|
siat/holding_risk_test.py
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
import os; os.chdir('S:/siat')
|
4
|
-
|
5
|
-
from siat import *
|
6
|
-
|
7
|
-
portfolio={'Market':("China","000001.SS"),'300782.SZ':1}
|
8
|
-
portfolio_rets_curve(portfolio,'2022-1-1','2022-4-18')
|
9
|
-
e,r=get_ES_portfolio(portfolio,'2022-4-18',5,0.99,model='historical')
|
10
|
-
|
11
|
-
portfolio2={'Market':("China","000001.SS"),'300782.SZ':0.3,'300563.SZ':0.7}
|
12
|
-
portfolio_rets_curve(portfolio2,'2022-1-1','2022-4-18')
|
13
|
-
e,r=get_ES_portfolio(portfolio2,'2022-4-18',5,0.99,model='historical')
|
siat/local_debug_test.py
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
"""
|
4
|
-
本地测试的简单方法:
|
5
|
-
1、卸载siat插件: pip uninstall siat
|
6
|
-
2、import os; os.chdir("S:/siat")
|
7
|
-
3、from siat import *
|
8
|
-
"""
|
9
|
-
|
10
|
-
import os; os.chdir("S:/siat")
|
11
|
-
from siat import *
|
12
|
-
#=====================================================================
|
13
|
-
df=oef_trend_china('050111','2021-7-1','2021-8-31',trend_type='排名',twinx=True)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
#=====================================================================
|
18
|
-
compare_stock("MSFT", ["Open", "Close"], "2020-3-16", "2020-3-31")
|
19
|
-
prices = compare_stock(["DAI.DE","BMW.DE"], "Close", "2020-1-1", "2020-3-31")
|
20
|
-
compare_stock("7203.T", ["High", "Low"], "2020-3-1", "2020-3-31")
|
21
|
-
info=candlestick("00700.HK","2020-2-1","2020-3-31", mav=2, volume=True, style='blueskies')
|
22
|
-
compare_stock("IBM", ["Annual Ret%", "Daily Ret%"], "2019-1-1", "2019-12-31")
|
23
|
-
compare_stock(["JD", "AMZN"], "Exp Ret%", "2019-1-1", "2020-12-31")
|
24
|
-
compare_security(["FRI","^RUT"],"Exp Ret%","2010-1-1","2020-6-30")
|
25
|
-
|
26
|
-
compare_security(["GCZ25.CMX","GCZ24.CMX"],"Close","2020-1-1","2020-6-30")
|
27
|
-
|
28
|
-
compare_security(['^HSI','000001.SS'],"Close","1991-1-1","2021-2-28", twinx=True)
|
29
|
-
compare_security(['^TWII','000001.SS'],"Close","1997-1-1","2021-2-28", twinx=True)
|
30
|
-
compare_security(['^KS11','000001.SS'],"Close","1997-1-1","2021-2-28", twinx=True)
|
31
|
-
compare_security(['^BSESN','000001.SS'],"Close","1997-1-1","2021-2-28", twinx=True)
|
32
|
-
compare_security(['^FTSE','000001.SS'],"Close","1991-1-1","2021-2-28", twinx=True)
|
33
|
-
|
34
|
-
tickers=['AMZN','EBAY','SHOP','MELI','BABA','JD','VIPS','PDD']
|
35
|
-
roa=compare_snapshot(tickers,'ROA')
|
36
|
-
|
37
|
-
tat=compare_history(['AMZN','JD'],'Total Asset Turnover')
|
38
|
-
|
39
|
-
tickers=['600519.SS','000858.SZ','600779.SS','000596.SZ','603589.SS']
|
40
|
-
df=compare_dupont(tickers,fsdate='2020-12-31',scale1 = 10,scale2 = 10)
|
41
|
-
|
42
|
-
Market={'Market':('US','^GSPC')}
|
43
|
-
Stocks={'AAPL':.1,'MSFT':.13,'XOM':.09,'JNJ':.09,'JPM':.09,'AMZN':.15,'GE':.08,'FB':.13,'T':.14}
|
44
|
-
portfolio=dict(Market,**Stocks)
|
45
|
-
pf_info=portfolio_cumret(portfolio,'2019-12-31')
|
46
|
-
|
47
|
-
beta=capm_beta('600000.SS','000001.SS','2011-1-1','2020-12-31')
|
48
|
-
|
49
|
-
members=['IBM','AAPL','MSFT']
|
50
|
-
shares=[1, 1, 3]
|
51
|
-
yearlist=gen_yearlist('2010','2020')
|
52
|
-
df=capm_beta_portfolio_yearly(members, shares,'^GSPC',yearlist)
|
53
|
-
|
54
|
-
yearlist=gen_yearlist('2011','2020')
|
55
|
-
betas_sw=get_beta_SW('4452.T','^N225', yearlist)
|
56
|
-
|
57
|
-
yearlist=gen_yearlist('2011','2019')
|
58
|
-
betas_sw= get_beta_SW('HMI.F','^FCHI', yearlist)
|
59
|
-
betas_sw=get_beta_SW('DIO.F','^FCHI', yearlist)
|
60
|
-
|
61
|
-
ff3_betas=reg_ff3_betas('BILI','2018-1-1','2019-4-30','US')
|
62
|
-
|
63
|
-
ff3_betas=reg_ff3_betas('AEM','2018-3-1','2019-8-31','US')
|
64
|
-
|
65
|
-
vix=security_price("^VIX", "2021-1-1", "2021-3-31",power=10)
|
66
|
-
|
67
|
-
var,ratio=stock_VaR_normal_standard('BABA',1000,'2019-8-8',1,0.99)
|
68
|
-
|
69
|
-
plot_rets_curve('01166.HK','2015-1-1','2015-3-31')
|
70
|
-
|
71
|
-
var, ratio=stock_VaR_normal_standard('ZM',1000,'2020-5-1',1,0.99)
|
72
|
-
|
73
|
-
var, r=stock_VaR_historical_grouping('00992.HK',1000,'2020-5-1',1,0.99, pastyears=3)
|
74
|
-
|
75
|
-
var, ratio=get_VaR_allmodels('01810.HK',1000,'2020-7-20',5,0.99)
|
76
|
-
|
77
|
-
pf_sohu={'Market':('US','^GSPC'),'SOHU':1.0}
|
78
|
-
rs15=roll_spread_portfolio(pf_sohu,'2015-1-1','2015-12-31')
|
79
|
-
|
80
|
-
portfolio={'Market':('US','^GSPC'),'DPW':0.4,'RIOT':0.3,'MARA':0.2,'NCTY':0.1}
|
81
|
-
sr,rp=rar_ratio_portfolio(portfolio,'2018-1-1','2020-12-31',ratio_name='sortino')
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
#=====================================================================
|
91
|
-
#=====================================================================
|
92
|
-
#=====================================================================
|
93
|
-
#=====================================================================
|
94
|
-
|
95
|
-
df_all=oef_rank_china(info_type='单位净值',fund_type='全部类型',rank=15)
|
96
|
-
|
97
|
-
df_z=oef_rank_china(info_type='单位净值',fund_type='债券型')
|
98
|
-
df_g=oef_rank_china('单位净值','股票型',rank=5)
|
99
|
-
df_e=etf_rank_china(info_type='单位净值',fund_type='全部类型',rank=10)
|
100
|
-
#=====================================================================
|