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.
Files changed (87) hide show
  1. siat/common.py +106 -2
  2. siat/exchange_bond_china.pickle +0 -0
  3. siat/fund_china.pickle +0 -0
  4. siat/stock.py +10 -2
  5. siat/stock_info.pickle +0 -0
  6. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/METADATA +234 -226
  7. siat-3.10.126.dist-info/RECORD +76 -0
  8. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/WHEEL +1 -1
  9. {siat-3.10.125.dist-info → siat-3.10.126.dist-info/licenses}/LICENSE +0 -0
  10. {siat-3.10.125.dist-info → siat-3.10.126.dist-info}/top_level.txt +0 -0
  11. siat/__init__ -20240701.py +0 -65
  12. siat/__init__.py.backup_20250214.py +0 -73
  13. siat/alpha_vantage_test.py +0 -24
  14. siat/assets_liquidity_test.py +0 -44
  15. siat/barrons_scraping_test.py +0 -276
  16. siat/beta_adjustment_test.py +0 -77
  17. siat/bond_test.py +0 -142
  18. siat/capm_beta_test.py +0 -49
  19. siat/cmat_commons.py +0 -961
  20. siat/compare_cross_test.py +0 -117
  21. siat/concepts_iwencai.py +0 -86
  22. siat/concepts_kpl.py +0 -93
  23. siat/cryptocurrency_test.py +0 -71
  24. siat/derivative.py +0 -1111
  25. siat/economy-20230125.py +0 -1206
  26. siat/economy_test.py +0 -360
  27. siat/esg_test.py +0 -63
  28. siat/fama_french_test.py +0 -115
  29. siat/financial_statements_test.py +0 -31
  30. siat/financials2 - /321/205/320/231/320/277/321/206/320/254/320/274.py" +0 -341
  31. siat/financials_china2_test.py +0 -67
  32. siat/financials_china2_test2.py +0 -88
  33. siat/financials_china2_test3.py +0 -87
  34. siat/financials_china_test.py +0 -475
  35. siat/financials_china_test2.py +0 -197
  36. siat/financials_china_test2_fin_indicator.py +0 -197
  37. siat/financials_test.py +0 -713
  38. siat/fred_test.py +0 -40
  39. siat/fund_china_test.py +0 -175
  40. siat/fund_test.py +0 -40
  41. siat/future_china_test.py +0 -37
  42. siat/global_index_test.py +0 -66
  43. siat/grafix_test.py +0 -112
  44. siat/holding_risk_test.py +0 -13
  45. siat/local_debug_test.py +0 -100
  46. siat/markowitz2-20240620.py +0 -2614
  47. siat/markowitz_ccb_test.py +0 -37
  48. siat/markowitz_ef_test.py +0 -136
  49. siat/markowitz_old.py +0 -871
  50. siat/markowitz_simple-20230709.py +0 -370
  51. siat/markowitz_test.py +0 -164
  52. siat/markowitz_test2.py +0 -69
  53. siat/ml_cases_example1.py +0 -60
  54. siat/option_china_test.py +0 -447
  55. siat/option_pricing_test.py +0 -81
  56. siat/option_sina_api_test.py +0 -112
  57. siat/proxy_test.py +0 -84
  58. siat/quandl_test.py +0 -39
  59. siat/risk_adjusted_return_test.py +0 -81
  60. siat/risk_evaluation_test.py +0 -96
  61. siat/risk_free_rate_test.py +0 -127
  62. siat/sector_china_test.py +0 -203
  63. siat/security_price.py +0 -831
  64. siat/security_prices_test.py +0 -310
  65. siat/security_trend2-20240620.py +0 -493
  66. siat/setup.py +0 -41
  67. siat/shenwan index history test.py +0 -41
  68. siat/stock_china_test.py +0 -38
  69. siat/stock_info_test.py +0 -189
  70. siat/stock_list_china_test.py +0 -33
  71. siat/stock_technical-20240620.py +0 -2736
  72. siat/stock_test.py +0 -487
  73. siat/temp.py +0 -36
  74. siat/test2_graphviz.py +0 -484
  75. siat/test_graphviz.py +0 -411
  76. siat/test_markowitz_simple.py +0 -198
  77. siat/test_markowitz_simple_revised.py +0 -215
  78. siat/test_markowitz_simple_revised2.py +0 -218
  79. siat/transaction_test.py +0 -436
  80. siat/translate-20230125.py +0 -2107
  81. siat/translate-20230206.py +0 -2109
  82. siat/translate-20230215.py +0 -2158
  83. siat/translate_20240606.py +0 -4206
  84. siat/translate_241003_keep.py +0 -4300
  85. siat/universal_test.py +0 -100
  86. siat/valuation_market_china_test.py +0 -36
  87. siat-3.10.125.dist-info/RECORD +0 -152
@@ -1,117 +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
- ticker='600519.SS'
9
- start='2023-1-1'
10
- end='2023-4-4'
11
- info_types=['Close','Volume']
12
-
13
- #获取股票价格
14
- df1=fetch_price_stock(ticker,start,end)
15
-
16
- #获取指数价格
17
- mktidx='000300.SS'
18
- df1i=fetch_price_stock(mktidx,start,end)
19
-
20
- #获取ETF价格
21
- etf='512690.SS'
22
- df1e=fetch_price_stock(etf,start,end)
23
-
24
- #获取REiTs基金价格
25
- reits='180801.SZ'
26
- df1r=fetch_price_stock(reits,start,end)
27
-
28
-
29
- if __name__=='__main__':
30
- Market={'Market':('China','000300.SS','白酒组合1号')}
31
- Stocks ={'600519.SS':.5,
32
- '000858.SZ':.3,
33
- '000596.SZ':.1,
34
- '000568.SZ':.1}
35
- portfolio=dict(Market,**Stocks)
36
-
37
- start='2023-1-1'
38
- end='2023-4-4'
39
-
40
- #获取投资组合价格
41
- df2=fetch_price_stock_portfolio(portfolio,start,end)
42
-
43
- if __name__=='__main__':
44
- ticker='850831'
45
-
46
- start='2023-1-1'
47
- end='2023-4-4'
48
- info_types=['Close','Volume']
49
-
50
- #获取申万指数价格
51
- df3=fetch_price_swindex(ticker,start,end)
52
-
53
- #多种证券价格组合
54
- dflist=[df1,df1i,df1e,df1r,df2,df3]
55
-
56
- #比较收益与风险指标
57
- cmc1=compare_msecurity_cross(dflist,
58
- measure='Exp Ret%',
59
- start=start,end=end)
60
-
61
- cmc2=compare_msecurity_cross(dflist,
62
- measure='Annual Ret%',
63
- start=start,end=end)
64
-
65
- #比较夏普指标
66
- rar3=rar_ratio_rolling_df(df3,ratio_name='sharpe',window=240)
67
-
68
- cmc3=compare_mrar_cross(dflist,rar_name='sharpe',start=start,end=end,window=240)
69
-
70
- cmc4=compare_mrar_cross(dflist,rar_name='sortino',start=start,end=end,window=240)
71
-
72
- cmc4=compare_mrar_cross(dflist,rar_name='alpha',start=start,end=end,window=240)
73
- #==============================================================================
74
-
75
- # 定义投资组合:成份股与初始持股比例
76
- # 初始持股比例跟着感觉走,后面将进行优化
77
- Market={'Market':('China','000300.SS','地产组合1号初版')}
78
- Stocks ={'000002.SZ':.40,#万科A
79
- '600048.SS':.08,#保利发展
80
- '001979.SZ':.08,#招商蛇口
81
- '600325.SS':.08,#华发股份
82
- '000069.SZ':.08,#华侨城A
83
- '600383.SS':.08,#金地集团
84
- '600895.SS':.05,#张江高科
85
- '601155.SS':.05,#新城控股
86
- '600606.SS':.05,#绿地控股
87
- '600208.SS':.05,#新湖中宝
88
- }
89
- portfolio_v0=dict(Market,**Stocks)
90
-
91
-
92
- tjend='2022-12-31'
93
- pastyears=3
94
-
95
-
96
- # 收集投资组合成份股的基础数据
97
- pf_info0=portfolio_hpr(portfolio_v0, #投资组合初版
98
- thedate=tjend, #截止日期
99
- pastyears=pastyears, #近三年
100
- printout=False,#不打印结果
101
- graph=False, #不绘图
102
- )
103
-
104
- simulation=100000
105
-
106
-
107
- # 第一次优化地产组合1号:优化持股比例,基于夏普比率
108
- portfolio_optimize_strategy(
109
- pf_info0, #成分股的基础数据
110
- ratio='sharpe', #夏普比率
111
- simulation=simulation,#模拟次数
112
- )
113
-
114
-
115
-
116
-
117
- #==============================================================================
siat/concepts_iwencai.py DELETED
@@ -1,86 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Created on Wed Oct 28 21:41:28 2020
4
-
5
- @author: Peter
6
- """
7
-
8
- import urllib.request
9
- import re
10
- import requests
11
-
12
- # def main():
13
- # # url = "http://www.iwencai.com/school/dictionary?qs=study_dictonary_stock"
14
- # # url='http://www.iwencai.com/yike/article-class-list?tagId=37'
15
- # url="http://www.iwencai.com/yike/detail/auid/716981f756614a79"
16
- # try:
17
- # data = urllib.request.urlopen(url).read()
18
- # content = data.decode('UTF-8')
19
- #
20
- # # pattern = re.compile('<div class="term_top clearfix">.*?<a.*?point_info="title">(.*?)</a></div>.*?'
21
- # # '<div class="term_summary clearfix">(.*?)</div>',
22
- # # re.S)
23
- # pattern = re.compile('<div class="term_summ_acl term_summ_acl_img">*?<div>(.*?)</div></div>',
24
- # re.S)
25
- # items = re.findall(pattern, content)
26
- # print(items[0])
27
- # # for item in items:
28
- # # print(item[0],item[1])
29
- #
30
- # except e:
31
- # print(e.code)
32
- # print(e.re)
33
-
34
- def main():
35
- for i in range(1,300):
36
- con_list=getPage(i)
37
- for item in con_list:
38
-
39
- subUrl=item['URL']
40
- concrete=getConcrete(subUrl)
41
- if concrete!=None :
42
- if len(concrete)!=0:
43
- print(item['title'])
44
- concrete=concrete.replace('<div>','')
45
- # concrete.replace('&nbsp;', '')
46
- print(concrete.replace('&nbsp;', ''))
47
- print("================================")
48
-
49
-
50
- def getConcrete(subUrl):
51
- concrete_url = "http://www.iwencai.com/" + subUrl
52
- # print(concrete_url)
53
- try:
54
- data = urllib.request.urlopen(concrete_url).read()
55
- content = data.decode('UTF-8') #
56
- pattern = re.compile('<div class="term_summ_acl term_summ_acl_img">(.*?)</div>',re.S)
57
- items = re.findall(pattern, content)
58
- if len(items)==0:
59
- pattern = re.compile('<div class="term_summ_acl ">(.*?)</div>',re.S)
60
- items = re.findall(pattern, content)
61
- return items[0]
62
- except:
63
- print("异常--------------")
64
- return []
65
-
66
- #获取索引页面的内容
67
- def getPage(pageIndex):
68
- siteURL="http://www.iwencai.com/yike/index-page-ajax/"
69
- url = siteURL + "?p=" + str(pageIndex)+"&filterTag=37"
70
- # request = urllib2.Request(url)
71
- # response = urllib2.urlopen(request)
72
- # return response.read().decode('gbk')
73
- # data = urllib.request.urlopen(url).read()
74
- # content = data.decode('gbk')
75
- # return content
76
- headers = {
77
- 'Referer': 'http://www.sse.com.cn/disclosure/credibility/supervision/inquiries/',
78
- 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36'
79
- }
80
- r = requests.get(url, headers=headers)
81
- return r.json()['list']
82
- # print(r.json()['list'][1]['summ'])
83
-
84
-
85
- if __name__ == '__main__':
86
- main()
siat/concepts_kpl.py DELETED
@@ -1,93 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
- """
3
- Spyder Editor
4
-
5
- This is a temporary script file.
6
- """
7
-
8
- def kpl_stock_concept():
9
- """
10
- 功能:抓取开盘啦网站的概念股明细
11
- """
12
- import pandas as pd
13
- import json
14
- import requests
15
- import random
16
-
17
- url = 'https://pchq.kaipanla.com/w1/api/index.php'
18
- concept_label = []
19
- label_df = pd.DataFrame()
20
-
21
- # 获取概念ID
22
- #USER_AGENTS列表,随即使用,以便避过反爬虫机制
23
- ua_list = [
24
- "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; AcooBrowser; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
25
- "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.0.04506)",
26
- "Mozilla/4.0 (compatible; MSIE 7.0; AOL 9.5; AOLBuild 4337.35; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)",
27
- "Mozilla/5.0 (Windows; U; MSIE 9.0; Windows NT 9.0; en-US)",
28
- "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 2.0.50727; Media Center PC 6.0)",
29
- "Mozilla/5.0 (compatible; MSIE 8.0; Windows NT 6.0; Trident/4.0; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; .NET CLR 1.0.3705; .NET CLR 1.1.4322)",
30
- "Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.2; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.04506.30)",
31
- "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN) AppleWebKit/523.15 (KHTML, like Gecko, Safari/419.3) Arora/0.3 (Change: 287 c9dfb30)",
32
- "Mozilla/5.0 (X11; U; Linux; en-US) AppleWebKit/527+ (KHTML, like Gecko, Safari/419.3) Arora/0.6",
33
- "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2pre) Gecko/20070215 K-Ninja/2.1.1",
34
- "Mozilla/5.0 (Windows; U; Windows NT 5.1; zh-CN; rv:1.9) Gecko/20080705 Firefox/3.0 Kapiko/3.0",
35
- "Mozilla/5.0 (X11; Linux i686; U;) Gecko/20070322 Kazehakase/0.4.5",
36
- "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.8) Gecko Fedora/1.9.0.8-1.fc10 Kazehakase/0.5.6",
37
- "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11",
38
- "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.20 (KHTML, like Gecko) Chrome/19.0.1036.7 Safari/535.20",
39
- "Opera/9.80 (Macintosh; Intel Mac OS X 10.6.8; U; fr) Presto/2.9.168 Version/11.52",
40
- ]
41
- session=requests.Session()
42
- for i in range(0,500,5):
43
- param1 = {'c': 'PCArrangeData', 'a': 'GetZSIndexPlate', 'SelType': 2, 'ZSType': 5, 'PType': 2, 'POrder': 1,
44
- 'PStart': '', 'PEnd': '', 'PIndex': i, 'Pst': 15, 'UserID': '399083','Token': '2292739880d01bd81e169e90a1898ebe'}
45
-
46
- html1 = json.loads(session.post(url=url, headers={'User-Agent': random.choice(ua_list)}, data=param1).text)
47
- if len(html1['plates']['list']) != 0:
48
- label_df = label_df.append(html1['plates']['list'],ignore_index=True)
49
- else:
50
- break
51
- label_df = label_df.iloc[:,0:2]
52
- label_df.columns = ['label','concept']
53
-
54
- # 获取概念股明细
55
- stock_df = pd.DataFrame()
56
- label_list=label_df['label'].tolist()
57
- concept_list=label_df['label'].tolist()
58
- for label in label_df['label'].tolist():
59
- pos=label_list.index(label)
60
- print("Processing",concept_list[pos],"\b,",pos+1,"of",len(label_list))
61
- for j in range(0,500,5):
62
- param2 = {'c': 'PCArrangeData', 'a': 'GetZSIndexPlate', 'SelType': 3, 'LType': 6, 'LOrder': 1,
63
- 'LStart': '', 'LEnd': '', 'LIndex': j, 'Lst': 15, 'PlateID': label, 'UserID': '399083',
64
- 'Token': '2292739880d01bd81e169e90a1898ebe'}
65
-
66
- html2 = json.loads(session.post(url=url, headers={'User-Agent': random.choice(ua_list)}, data=param2).text)
67
- #print(html2)
68
- if len(html2['stocks']['list']) != 0:
69
- data = pd.DataFrame(html2['stocks']['list'])
70
- #print(data)
71
- data['label'] = label
72
- stock_df = stock_df.append(data, ignore_index=True)
73
- else:
74
- break
75
-
76
- stock_df = stock_df.iloc[:, [0, 1, 13]]
77
- stock_df.columns = ['scode', 'sname','label']
78
-
79
- stock_concept_detail_df = pd.merge(stock_df, label_df)
80
-
81
- stock_concept_detail_df.rename({'symbol': 'scode', 'name': 'sname', '板块': 'concept'}, axis='columns', inplace=True)
82
-
83
- stock_concept_detail_df = stock_concept_detail_df[['scode', 'sname', 'concept']]
84
- stock_concept_detail_df['scode'] = stock_concept_detail_df['scode'].apply(lambda x: (x + ".SH") if x.startswith('6') == True else (x + ".SZ"))
85
- stock_concept_detail_df.drop_duplicates(inplace=True)
86
-
87
- stock_concept_detail_df.sort_values(by=['scode'],inplace=True)
88
- #print(stock_concept_detail_df.head(5))
89
- print('Completed.')
90
- return stock_concept_detail_df
91
-
92
-
93
-
@@ -1,71 +0,0 @@
1
- # -*- coding: utf-8 -*-
2
-
3
- import os; os.chdir("S:/siat")
4
- from siat.cryptocurrency import *
5
-
6
- #==============================================================================
7
- price=Crypto_Price_Trend('ETH','USD','Coinbase','2020-7-1','2021-4-21')
8
-
9
- price=Crypto_Price_Trend('BTC','USD','Coinbase','2020-7-1','2021-4-21')
10
-
11
- price=Crypto_Price_Trend('BTC','USD','Coinbase','2021-2-8','2021-4-21')
12
-
13
- price=Crypto_Price_Trend('Libra','USD','Coinbase','2021-2-8','2021-4-21')
14
- #==============================================================================
15
- markets=fetchCrypto_Exchange("ETH","USD")
16
- #==============================================================================
17
- product="ETH"
18
- currency="USD"
19
- market1="Coinbase"
20
- market2="Bitstamp"
21
- prices1=fetchCrypto_Price_byExchange(product,currency,market1)
22
- prices2=fetchCrypto_Price_byExchange(product,currency,market2)
23
- product1=[prices1,product,currency,market1]
24
- product2=[prices2,product,currency,market2]
25
- compCrypto_Price(product1,product2,days=360)
26
-
27
-
28
-
29
-
30
- #==============================================================================
31
-
32
- fsym = "ETH"; tsym = "USD"
33
- begdate="2020-1-1"; enddate="2020-12-31"
34
- markets=fetchCrypto_Exchange(fsym,tsym)
35
- cp=fetchCrypto_Price_byExchList(fsym,tsym,markets,begdate,enddate)
36
-
37
- dist1,dist2=calcSpread_in2Markets(cp)
38
- printSpread_in2Markets(dist1,dist2)
39
-
40
-
41
- investment = 10000
42
- account1, account2 = investment/2, investment/2
43
- position = 0.5*(investment/2)
44
-
45
- #价差最高的市场:primexbt Coinbase
46
- market1 = "primexbt"
47
- market2 = "Coinbase"
48
-
49
- df1 = fetchCrypto_Price_byExchange(fsym, tsym, market1)
50
- df2 = fetchCrypto_Price_byExchange(fsym, tsym, market2)
51
-
52
- df1,df2=evalSpread_in2Markets(fsym,tsym,market1,market2,begdate,enddate)
53
- ac1,ac2,money,roi0=backtestMSA_Strategy(investment,account1,account2,position,df1,df2)
54
- eval_Position(market1,market2,investment,ac1,ac2,money)
55
- eval_Roi(fsym,tsym,market1,market2,roi0)
56
-
57
- #价差性价比最高的市场:Bitstamp primexbt
58
- market1 = "Bitstamp"
59
- market2 = "primexbt"
60
- df1,df2=evalSpread_in2Markets(fsym,tsym,market1,market2,begdate,enddate)
61
- ac1,ac2,money,roi0=backtestMSA_Strategy(investment,account1,account2,position,df1,df2)
62
- eval_Position(market1,market2,investment,ac1,ac2,money)
63
- eval_Roi(fsym,tsym,market1,market2,roi0)
64
-
65
- #价差性风险最低的市场:Bitstamp Kraken
66
- market1 = "Bitstamp"
67
- market2 = "Kraken"
68
- df1,df2=evalSpread_in2Markets(fsym,tsym,market1,market2,begdate,enddate)
69
- ac1,ac2,money,roi0=backtestMSA_Strategy(investment,account1,account2,position,df1,df2)
70
- eval_Position(market1,market2,investment,ac1,ac2,money)
71
- eval_Roi(fsym,tsym,market1,market2,roi0)