siat 3.2.30__py3-none-any.whl → 3.2.31__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/__init__ -20240701.py +65 -0
- siat/__init__.py +18 -32
- siat/luchy_draw.py +132 -15
- {siat-3.2.30.dist-info → siat-3.2.31.dist-info}/METADATA +1 -1
- {siat-3.2.30.dist-info → siat-3.2.31.dist-info}/RECORD +7 -6
- {siat-3.2.30.dist-info → siat-3.2.31.dist-info}/WHEEL +0 -0
- {siat-3.2.30.dist-info → siat-3.2.31.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,65 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
"""
|
3
|
+
功能:一次性引入SIAT的所有模块
|
4
|
+
作者:王德宏,北京外国语大学国际商学院
|
5
|
+
版权:2021-2024(C) 仅限教学使用,商业使用需要授权
|
6
|
+
联络:wdehong2000@163.com
|
7
|
+
"""
|
8
|
+
|
9
|
+
#==============================================================================
|
10
|
+
#屏蔽所有警告性信息
|
11
|
+
import warnings; warnings.filterwarnings('ignore')
|
12
|
+
#==============================================================================
|
13
|
+
from siat.allin import *
|
14
|
+
#==============================================================================
|
15
|
+
#同一命令行多个输出,主要用于Jupyter Notebook
|
16
|
+
from IPython.core.interactiveshell import InteractiveShell
|
17
|
+
InteractiveShell.ast_node_interactivity='all'
|
18
|
+
#==============================================================================
|
19
|
+
# 检查是否存在新版本
|
20
|
+
try:
|
21
|
+
import pkg_resources
|
22
|
+
current_version=pkg_resources.get_distribution("siat").version
|
23
|
+
current_list=current_version.split('.')
|
24
|
+
print("Successfully imported siat version",current_version)
|
25
|
+
|
26
|
+
import luddite
|
27
|
+
latest_version=luddite.get_version_pypi("siat")
|
28
|
+
latest_list=latest_version.split('.')
|
29
|
+
|
30
|
+
newest=True
|
31
|
+
for i in range(3):
|
32
|
+
#print(i)
|
33
|
+
if int(current_list[i]) < int(latest_list[i]):
|
34
|
+
newest=False
|
35
|
+
|
36
|
+
"""
|
37
|
+
if not newest:
|
38
|
+
print("The latest version of siat is",latest_version,'\n')
|
39
|
+
print("*** If you expect to upgrade siat in Anaconda Prompt, use the instruction below:")
|
40
|
+
print(" pip install siat --upgrade")
|
41
|
+
print("*** If you expect to upgrade in Jupyter, add a \'!\' right before the instruction above",'\n')
|
42
|
+
|
43
|
+
print("*** If you encounter incompatible plug-in, try to uninstall siat first and reinstall it:")
|
44
|
+
print(" pip uninstall siat")
|
45
|
+
print(" pip install siat",'\n')
|
46
|
+
|
47
|
+
print("*** If you have a slow internet connection, use an option trailing the instruction above:")
|
48
|
+
print(" -i https://mirrors.aliyun.com/pypi/simple/",'\n')
|
49
|
+
|
50
|
+
print("If you have done any of the above, restart the Python (eg. restarting the kernel)")
|
51
|
+
print("Provided you still need additional help, please contact wdehong2000@163.com")
|
52
|
+
"""
|
53
|
+
if not newest:
|
54
|
+
#print("The latest version of siat is",latest_version,'\n')
|
55
|
+
print("Now there is a newer version of siat",latest_version,'\n')
|
56
|
+
print("*** How to upgrade siat?")
|
57
|
+
print("Upgrade directly from official source? use command: upgrade_siat()")
|
58
|
+
print("Upgrade from Tsinghua? use command: upgrade_siat(alternative='tsinghua')")
|
59
|
+
print("Upgrade from Alibaba? use command: upgrade_siat(alternative='alibaba')")
|
60
|
+
|
61
|
+
except:
|
62
|
+
pass
|
63
|
+
|
64
|
+
|
65
|
+
#==============================================================================
|
siat/__init__.py
CHANGED
@@ -17,46 +17,32 @@ from IPython.core.interactiveshell import InteractiveShell
|
|
17
17
|
InteractiveShell.ast_node_interactivity='all'
|
18
18
|
#==============================================================================
|
19
19
|
# 检查是否存在新版本
|
20
|
+
check_newer_version=False
|
21
|
+
|
20
22
|
try:
|
21
23
|
import pkg_resources
|
22
24
|
current_version=pkg_resources.get_distribution("siat").version
|
23
25
|
current_list=current_version.split('.')
|
24
26
|
print("Successfully imported siat version",current_version)
|
25
27
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
newest=True
|
31
|
-
for i in range(3):
|
32
|
-
#print(i)
|
33
|
-
if int(current_list[i]) < int(latest_list[i]):
|
34
|
-
newest=False
|
35
|
-
|
36
|
-
"""
|
37
|
-
if not newest:
|
38
|
-
print("The latest version of siat is",latest_version,'\n')
|
39
|
-
print("*** If you expect to upgrade siat in Anaconda Prompt, use the instruction below:")
|
40
|
-
print(" pip install siat --upgrade")
|
41
|
-
print("*** If you expect to upgrade in Jupyter, add a \'!\' right before the instruction above",'\n')
|
28
|
+
if check_newer_version:
|
29
|
+
import luddite
|
30
|
+
latest_version=luddite.get_version_pypi("siat")
|
31
|
+
latest_list=latest_version.split('.')
|
42
32
|
|
43
|
-
|
44
|
-
|
45
|
-
|
33
|
+
newest=True
|
34
|
+
for i in range(3):
|
35
|
+
#print(i)
|
36
|
+
if int(current_list[i]) < int(latest_list[i]):
|
37
|
+
newest=False
|
46
38
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
#print("The latest version of siat is",latest_version,'\n')
|
55
|
-
print("Now there is a newer version of siat",latest_version,'\n')
|
56
|
-
print("*** How to upgrade siat?")
|
57
|
-
print("Upgrade directly from official source? use command: upgrade_siat()")
|
58
|
-
print("Upgrade from Tsinghua? use command: upgrade_siat(alternative='tsinghua')")
|
59
|
-
print("Upgrade from Alibaba? use command: upgrade_siat(alternative='alibaba')")
|
39
|
+
if not newest:
|
40
|
+
#print("The latest version of siat is",latest_version,'\n')
|
41
|
+
print("Now there is a newer version of siat",latest_version,'\n')
|
42
|
+
print("*** How to upgrade siat?")
|
43
|
+
print("Upgrade directly from official source? use command: upgrade_siat()")
|
44
|
+
print("Upgrade from Tsinghua? use command: upgrade_siat(alternative='tsinghua')")
|
45
|
+
print("Upgrade from Alibaba? use command: upgrade_siat(alternative='alibaba')")
|
60
46
|
|
61
47
|
except:
|
62
48
|
pass
|
siat/luchy_draw.py
CHANGED
@@ -20,7 +20,45 @@ import pickle
|
|
20
20
|
import random
|
21
21
|
import datetime
|
22
22
|
import time
|
23
|
+
import os
|
24
|
+
from IPython.display import display_html, HTML
|
23
25
|
|
26
|
+
#==============================================================================
|
27
|
+
|
28
|
+
def current_dir(printout=True):
|
29
|
+
"""
|
30
|
+
功能:找出当前路径
|
31
|
+
"""
|
32
|
+
|
33
|
+
current_path = os.getcwd()
|
34
|
+
|
35
|
+
if printout:
|
36
|
+
print(f"[当前工作路径] {current_path}")
|
37
|
+
|
38
|
+
return current_path
|
39
|
+
|
40
|
+
#==============================================================================
|
41
|
+
if __name__=='__main__':
|
42
|
+
file_path="S:\北外工作-24春\小学期-人大\学生名单\student_list.xlsx"
|
43
|
+
pickle_path="student_list.pkl"
|
44
|
+
|
45
|
+
existing(file_path)
|
46
|
+
existing(pickle_path)
|
47
|
+
|
48
|
+
|
49
|
+
def existing(file_path):
|
50
|
+
"""
|
51
|
+
功能:检查文件file_path是否存在,不带路径时检查当前目录
|
52
|
+
"""
|
53
|
+
# 检查文件是否存在
|
54
|
+
if os.path.exists(file_path):
|
55
|
+
if os.path.isfile(file_path):
|
56
|
+
return True
|
57
|
+
else:
|
58
|
+
return False
|
59
|
+
else:
|
60
|
+
return False
|
61
|
+
|
24
62
|
#==============================================================================
|
25
63
|
if __name__=='__main__':
|
26
64
|
text="A B C"
|
@@ -28,11 +66,13 @@ if __name__=='__main__':
|
|
28
66
|
text_size=12
|
29
67
|
delay=1
|
30
68
|
|
31
|
-
typewriter(text,text_color='red',text_size=12,delay=1)
|
69
|
+
typewriter(text,text_color='red',text_size=12,delay=1)
|
32
70
|
|
33
|
-
def typewriter(text,text_color='blue',text_size=12,delay=
|
71
|
+
def typewriter(text,text_color='blue',text_size=12,delay=3):
|
34
72
|
from IPython.display import display_html
|
35
73
|
|
74
|
+
time.sleep(delay)
|
75
|
+
|
36
76
|
text_html="<center><font size="+str(text_size)+" color="+text_color+">"+text
|
37
77
|
display_html(text_html, raw=True)
|
38
78
|
|
@@ -41,17 +81,103 @@ def typewriter(text,text_color='blue',text_size=12,delay=1):
|
|
41
81
|
#==============================================================================
|
42
82
|
|
43
83
|
def pickle_write(df,pickle_path):
|
44
|
-
|
45
|
-
|
46
|
-
|
84
|
+
|
85
|
+
ok2go=True
|
86
|
+
|
87
|
+
prompt="File "+pickle_path+" already exists, overwrite it? [yes/no]"
|
88
|
+
file_exist=existing(pickle_path)
|
89
|
+
if file_exist:
|
90
|
+
yes=read_yes_no(prompt, default=None)
|
91
|
+
if not yes:
|
92
|
+
ok2go=False
|
93
|
+
|
94
|
+
if ok2go:
|
95
|
+
with open(pickle_path, 'wb') as pickle_file:
|
96
|
+
# 使用pickle模块的dump函数写入对象
|
97
|
+
pickle.dump(df,pickle_file)
|
98
|
+
|
99
|
+
return
|
47
100
|
|
48
101
|
if __name__=='__main__':
|
102
|
+
course="SICS RUC24"
|
49
103
|
file_path="S:\北外工作-24春\小学期-人大\学生名单\student_list.xlsx"
|
50
104
|
pickle_path="student_list.pkl"
|
51
105
|
skiprows=1
|
52
106
|
column='Name'
|
53
107
|
|
54
|
-
|
108
|
+
draw_limit=2
|
109
|
+
absent_limit=2
|
110
|
+
pass_limit=2
|
111
|
+
|
112
|
+
lucky_draw_header_create(course,file_path, \
|
113
|
+
skiprows=1,column='Name',draw_limit=2, \
|
114
|
+
absent_limit=2,pass_limit=2)
|
115
|
+
pickle_read(pickle_path=course+' header.pkl')
|
116
|
+
|
117
|
+
|
118
|
+
def lucky_draw_header_create(course,file_path, \
|
119
|
+
skiprows=1,column='Name',draw_limit=2, \
|
120
|
+
absent_limit=2,pass_limit=2):
|
121
|
+
|
122
|
+
pickle_path=course+" header.pkl"
|
123
|
+
|
124
|
+
header_dict={'course':course,'file_path':file_path,'pickle_path':pickle_path, \
|
125
|
+
'skiprows':skiprows,'column':column,'draw_limit':draw_limit, \
|
126
|
+
'absent_limit':absent_limit,'pass_limit':pass_limit}
|
127
|
+
|
128
|
+
pickle_write(header_dict,pickle_path)
|
129
|
+
|
130
|
+
return
|
131
|
+
|
132
|
+
def lucky_draw_header_modify(course,file_path="current", \
|
133
|
+
skiprows=="current",column=="current",draw_limit=="current", \
|
134
|
+
absent_limit=="current",pass_limit=="current"):
|
135
|
+
|
136
|
+
pickle_path=course+" header.pkl"
|
137
|
+
header_dict=pickle_read(pickle_path)
|
138
|
+
|
139
|
+
if file_path !='current':
|
140
|
+
header_dict['file_path']=file_path
|
141
|
+
else:
|
142
|
+
file_path=header_dict['file_path']
|
143
|
+
|
144
|
+
if skiprows !='current':
|
145
|
+
header_dict['skiprows']=skiprows
|
146
|
+
else:
|
147
|
+
skiprows=header_dict['skiprows']
|
148
|
+
|
149
|
+
if column !='current':
|
150
|
+
header_dict['column']=column
|
151
|
+
else:
|
152
|
+
column=header_dict['column']
|
153
|
+
|
154
|
+
if draw_limit !='current':
|
155
|
+
header_dict['draw_limit']=draw_limit
|
156
|
+
else:
|
157
|
+
draw_limit=header_dict['draw_limit']
|
158
|
+
|
159
|
+
if absent_limit !='current':
|
160
|
+
header_dict['absent_limit']=absent_limit
|
161
|
+
else:
|
162
|
+
absent_limit=header_dict['absent_limit']
|
163
|
+
|
164
|
+
if pass_limit !='current':
|
165
|
+
header_dict['pass_limit']=pass_limit
|
166
|
+
else:
|
167
|
+
pass_limit=header_dict['pass_limit']
|
168
|
+
|
169
|
+
header_dict={'course':course,'file_path':file_path,'pickle_path':pickle_path, \
|
170
|
+
'skiprows':skiprows,'column':column,'draw_limit':draw_limit, \
|
171
|
+
'absent_limit':absent_limit,'pass_limit':pass_limit}
|
172
|
+
|
173
|
+
pickle_write(header_dict,pickle_path)
|
174
|
+
|
175
|
+
return
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
lucky_draw_initialize(file_path,skiprows=1,column='Name',pickle_path="student_list.pkl")
|
55
181
|
|
56
182
|
def lucky_draw_initialize(file_path,skiprows=1,column='Name',pickle_path="student_list.pkl"):
|
57
183
|
"""
|
@@ -93,15 +219,6 @@ def pickle_read(pickle_path="student_list.pkl"):
|
|
93
219
|
|
94
220
|
|
95
221
|
|
96
|
-
def pickle_append(df,column='Name',pickle_path="student_list.pkl"):
|
97
|
-
df_tmp=pickle_read(pickle_path)
|
98
|
-
df_new=pd.concat([df_tmp,df])
|
99
|
-
|
100
|
-
df_new.sort_values(by=[column,'Date'],inplace=True)
|
101
|
-
|
102
|
-
pickle_write(df_new,pickle_path)
|
103
|
-
|
104
|
-
return
|
105
222
|
|
106
223
|
#==============================================================================
|
107
224
|
if __name__=='__main__':
|
@@ -1,4 +1,5 @@
|
|
1
|
-
siat/__init__.py,sha256=gP5uajXnJesnH5SL0ZPwq_Qhv59AG1bs4qwZv26Fo2Y,2894
|
1
|
+
siat/__init__ -20240701.py,sha256=gP5uajXnJesnH5SL0ZPwq_Qhv59AG1bs4qwZv26Fo2Y,2894
|
2
|
+
siat/__init__.py,sha256=NJn2HSa0cdet21YFoJs5nafHgrM3H3J3wdtFYi1KzfM,2065
|
2
3
|
siat/allin.py,sha256=f8mlMSQJUgx4mRVOJNlHH2SZP0jUyWaeDPT2V6AGfY8,2757
|
3
4
|
siat/alpha_vantage_test.py,sha256=tKr-vmuFH3CZAqwmISz6jzjPHzV1JJl3sPfZdz8aTfM,747
|
4
5
|
siat/assets_liquidity.py,sha256=o_UZdLs693uNWPEQB2OzxDH0mdWimOmq4qe_vx1pue0,28987
|
@@ -64,7 +65,7 @@ siat/grafix_test.py,sha256=kXvcpLgQNO7wd30g_bWljLj5UH7bIVI0_dUtXbfiKR0,3150
|
|
64
65
|
siat/holding_risk.py,sha256=G3wpaewAKF9CwEqRpr4khyuDu9SU2EGyQUHdk7cmHOA,30693
|
65
66
|
siat/holding_risk_test.py,sha256=FRlw_9wFG98BYcg_cSj95HX5WZ1TvkGaOUdXD7-V86s,474
|
66
67
|
siat/local_debug_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
67
|
-
siat/luchy_draw.py,sha256=
|
68
|
+
siat/luchy_draw.py,sha256=d4Ga2KqbF0nBv4P6GQBSRe2vq3S55G2B0HtKuEJJzyo,11699
|
68
69
|
siat/market_china.py,sha256=hKoTLUyHuzsuG2L3_IuLx_utTKqS-__mZ63wrElh65U,45943
|
69
70
|
siat/markowitz.py,sha256=glHikhabFAF6Hb6df1pYfhkxid2IZXBYAVQng5wd9Wk,97526
|
70
71
|
siat/markowitz2-20240620.py,sha256=irZAPnjaatFsKQmFRMENP-cO6bEUl2narYtkU5NKTWI,108019
|
@@ -137,7 +138,7 @@ siat/valuation.py,sha256=NKfeZMdDJOW42oLVHob6eSVBXUqlN1OCnnzwyGAst8c,48855
|
|
137
138
|
siat/valuation_china.py,sha256=EkZQaVkoBjM0c4MCNbaX-bMnlG0e3FXeaWczZDnkptU,67784
|
138
139
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
139
140
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
140
|
-
siat-3.2.
|
141
|
-
siat-3.2.
|
142
|
-
siat-3.2.
|
143
|
-
siat-3.2.
|
141
|
+
siat-3.2.31.dist-info/METADATA,sha256=acxPalewEFV2nyg0ZetnYmjlFyvjL5X9S4UCVjjcJss,7234
|
142
|
+
siat-3.2.31.dist-info/WHEEL,sha256=2wepM1nk4DS4eFpYrW1TTqPcoGNfHhhO_i5m4cOimbo,92
|
143
|
+
siat-3.2.31.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
144
|
+
siat-3.2.31.dist-info/RECORD,,
|
File without changes
|
File without changes
|