siat 3.7.22__py3-none-any.whl → 3.7.23__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/security_price2.py +7 -0
- siat/security_prices.py +5 -1
- siat/stock.py +13 -0
- siat/translate.py +7 -1
- siat/yf_name.py +104 -8
- {siat-3.7.22.dist-info → siat-3.7.23.dist-info}/METADATA +1 -1
- {siat-3.7.22.dist-info → siat-3.7.23.dist-info}/RECORD +10 -10
- {siat-3.7.22.dist-info → siat-3.7.23.dist-info}/LICENSE +0 -0
- {siat-3.7.22.dist-info → siat-3.7.23.dist-info}/WHEEL +0 -0
- {siat-3.7.22.dist-info → siat-3.7.23.dist-info}/top_level.txt +0 -0
siat/security_price2.py
CHANGED
@@ -65,6 +65,13 @@ if __name__=='__main__':
|
|
65
65
|
fill=False
|
66
66
|
fill=True
|
67
67
|
|
68
|
+
# 新测试组
|
69
|
+
ticker="XAUUSD"
|
70
|
+
fromdate='2024-5-1'; todate='2024-5-20'
|
71
|
+
ticker_type='auto';source='auto'
|
72
|
+
adjust='';fill=False
|
73
|
+
|
74
|
+
|
68
75
|
price,found=get_price_1ticker(ticker=ticker,fromdate=fromdate,todate=todate, \
|
69
76
|
ticker_type=ticker_type)
|
70
77
|
|
siat/security_prices.py
CHANGED
@@ -553,7 +553,9 @@ if __name__=='__main__':
|
|
553
553
|
ticker='TRBNCN.M'
|
554
554
|
ticker='RSAYCN.M'
|
555
555
|
|
556
|
-
ticker='GC.F'
|
556
|
+
ticker='GC.F' #无法下载
|
557
|
+
ticker='XAUCNY' #一盎司黄金的现货人民币价格
|
558
|
+
ticker='XAUUSD' #一盎司黄金的现货美元价格
|
557
559
|
|
558
560
|
ticker=['AAPL','MSFT']
|
559
561
|
|
@@ -1366,6 +1368,8 @@ if __name__=='__main__':
|
|
1366
1368
|
ticker='AAPL'
|
1367
1369
|
ticker='GC=F'
|
1368
1370
|
|
1371
|
+
ticker='XAUUSD'
|
1372
|
+
|
1369
1373
|
ticker=['AAPL','MSFT']
|
1370
1374
|
ticker=['0700.HK','600519.SS']
|
1371
1375
|
ticker=['AAPL','MSFT','0700.HK','600519.SS']
|
siat/stock.py
CHANGED
@@ -625,6 +625,19 @@ if __name__ =="__main__":
|
|
625
625
|
ticker_type='auto'
|
626
626
|
facecolor='whitesmoke'
|
627
627
|
|
628
|
+
# 测试组6
|
629
|
+
ticker='XAUUSD'
|
630
|
+
indicator='Close'
|
631
|
+
fromdate='2024-5-1'; todate='2024-5-20'
|
632
|
+
zeroline=False
|
633
|
+
attention_value='';attention_value_area=''
|
634
|
+
attention_point='';attention_point_area=''
|
635
|
+
average_value=False
|
636
|
+
datatag=False;power=0;graph=True;source='auto'
|
637
|
+
mark_top=True;mark_bottom=True;mark_end=True
|
638
|
+
ticker_type='auto';facecolor='whitesmoke';loc='best'
|
639
|
+
|
640
|
+
|
628
641
|
df=security_indicator(ticker,indicator,fromdate,todate,ticker_type=ticker_type)
|
629
642
|
|
630
643
|
def security_indicator(ticker,indicator, \
|
siat/translate.py
CHANGED
@@ -1224,6 +1224,7 @@ def codetranslate0(code):
|
|
1224
1224
|
|
1225
1225
|
["SPY",'SPDR标普500ETF'],['SPYD','SPDR标普500股利优先ETF'],
|
1226
1226
|
["SPYG",'SPDR标普500成长优先ETF'],['SPYV','SPDR标普500价值优先ETF'],
|
1227
|
+
["GLD",'SPDR黄金ETF'],
|
1227
1228
|
["VOO",'Vanguard标普500ETF'],['VOOG','Vanguard标普500成长优先ETF'],
|
1228
1229
|
["VOOV",'Vanguard标普500价值优先ETF'],['IVV','iShares标普500ETF'],
|
1229
1230
|
["DGT",'SPDR Global Dow ETF'],['ICF','iShares C&S REIT ETF'],
|
@@ -1702,6 +1703,8 @@ def codetranslate0(code):
|
|
1702
1703
|
['^NYICDX','ICE美元指数'],['DX-Y.NYB','ICE美元指数'],
|
1703
1704
|
['EUR_I','STOOQ欧元指数'],
|
1704
1705
|
|
1706
|
+
['XAUUSD','1盎司黄金现货兑美元'],['XAUCNY','1盎司黄金现货兑人民币'],
|
1707
|
+
|
1705
1708
|
#经济体基准利率
|
1706
1709
|
['INRTAU.M','澳大利亚基准利率'],
|
1707
1710
|
['INRTBR.M','巴西基准利率'],
|
@@ -2051,7 +2054,7 @@ def codetranslate1(code):
|
|
2051
2054
|
|
2052
2055
|
["SPY",'SPDR SP500 ETF'],['SPYD','SPDR SP500 Div ETF'],
|
2053
2056
|
["SPYG",'SPDR SP500 Growth ETF'],['SPYV','SPDR SP500 Value ETF'],
|
2054
|
-
["GLD",'SPDR
|
2057
|
+
["GLD",'SPDR Gold Shares ETF'],
|
2055
2058
|
["VOO",'Vanguard SP500 ETF'],['VOOG','Vanguard SP500 Growth ETF'],
|
2056
2059
|
["VOOV",'Vanguard SP500 Value ETF'],['IVV','iShares SP500 ETF'],
|
2057
2060
|
["DGT",'SPDR Global Dow ETF'],['ICF','iShares C&S REIT ETF'],
|
@@ -2186,6 +2189,8 @@ def codetranslate1(code):
|
|
2186
2189
|
['U11.SI','UOB(SI)'],['C6L.SI','Singapore Airlines(SI)'],['CC3.SI','Starhub(SI)'],
|
2187
2190
|
['S08.SI','Singpost(SI)'],['F34.SI','WILMAR(SI)'],['C31.SI','CapitaLand(SI)'],
|
2188
2191
|
|
2192
|
+
['XAUUSD','Gold(ozt)->USD'],['XAUCNY','Gold(ozt)->RMB'],
|
2193
|
+
|
2189
2194
|
|
2190
2195
|
], columns=['code','codename'])
|
2191
2196
|
|
@@ -3398,6 +3403,7 @@ def ticker1_name(ticker,ticker_type='auto'):
|
|
3398
3403
|
#==============================================================================
|
3399
3404
|
if __name__=='__main__':
|
3400
3405
|
ticker='600519.SS' #股票
|
3406
|
+
ticker='XAUUSD' #一盎司黄金的美元价格
|
3401
3407
|
ticker={'Market':('US','^SPX','中概教培组合'),'EDU':0.5,'TAL':0.3,'TEDU':0.2}
|
3402
3408
|
pf={'Market':('US','^SPX','中概教培组合'),'EDU':0.5,'TAL':0.3,'TEDU':0.2}
|
3403
3409
|
ticker=['600519.SS','sh018003',pf]
|
siat/yf_name.py
CHANGED
@@ -372,13 +372,17 @@ def ticker_info1(ticker,info="all",test_access=True,print_title=True):
|
|
372
372
|
|
373
373
|
if __name__=='__main__':
|
374
374
|
ticker="SGC=F"
|
375
|
-
|
375
|
+
ticker="XAUUSD"
|
376
|
+
short_name=False;add_suffix=True;maxlen=80
|
377
|
+
|
378
|
+
yahoo_name1y(ticker)
|
376
379
|
|
377
|
-
def
|
380
|
+
def yahoo_name1y(ticker,short_name=False,add_suffix=True,maxlen=80):
|
378
381
|
"""
|
379
382
|
功能:从雅虎财经取得全球证券名称,仅限英文。需要去掉常用词,如Corporation
|
380
383
|
优点:对未定义的证券代码也可给出英文名称,即使在中文语言环境中
|
381
|
-
|
384
|
+
现存问题:需要访问雅虎,且耗时稍长;当ticker不存在时会提示一大堆错误信息
|
385
|
+
仅作备用
|
382
386
|
"""
|
383
387
|
|
384
388
|
#测试雅虎
|
@@ -391,9 +395,20 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
|
|
391
395
|
|
392
396
|
import yfinance as yf
|
393
397
|
ticker_info = yf.Ticker(ticker1)
|
394
|
-
|
398
|
+
|
399
|
+
import os, sys
|
400
|
+
class HiddenPrints:
|
401
|
+
def __enter__(self):
|
402
|
+
self._original_stdout = sys.stdout
|
403
|
+
sys.stdout = open(os.devnull, 'w')
|
404
|
+
|
405
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
406
|
+
sys.stdout.close()
|
407
|
+
sys.stdout = self._original_stdout
|
408
|
+
|
395
409
|
try:
|
396
|
-
|
410
|
+
with HiddenPrints():
|
411
|
+
t_info=ticker_info.info
|
397
412
|
except:
|
398
413
|
pass
|
399
414
|
return ticker
|
@@ -408,7 +423,12 @@ def yahoo_name1(ticker,short_name=False,add_suffix=True,maxlen=80):
|
|
408
423
|
try:
|
409
424
|
t_name0=t_info['longName']
|
410
425
|
except:
|
411
|
-
|
426
|
+
try:
|
427
|
+
t_name0=t_info['shortName']
|
428
|
+
except:
|
429
|
+
pass
|
430
|
+
return ticker
|
431
|
+
|
412
432
|
|
413
433
|
if len(t_name0) > maxlen:
|
414
434
|
t_name0=t_info['shortName']
|
@@ -503,7 +523,7 @@ def filter_stock_name(original_name):
|
|
503
523
|
remove_list=[' CORPORATION',' BERHAD',' BHD',' PLC',' INC',' AG ST',' NA O N', \
|
504
524
|
' AKTIENGESELLSCHAFT','(PUBL)',' LLC', \
|
505
525
|
' CO LTD',' CO LIMITED',' LTD',' LIMITED',' COMPANY',' INCORPORATED', \
|
506
|
-
' CORP LTD',' CORP',' AB', \
|
526
|
+
' CORP LTD',' CORP',' AB',' CO', \
|
507
527
|
' GROUP CO','(GROUP)',' GROUP', \
|
508
528
|
' PL S A',' PL SA',' AG', \
|
509
529
|
' SCIENCE & TECHNOLOGY',' HIGH-TECH',' HIGH TECHNOLOGY', \
|
@@ -548,6 +568,7 @@ if __name__ == '__main__':
|
|
548
568
|
stock_code='MSFT'
|
549
569
|
|
550
570
|
stock_code='GC.F'
|
571
|
+
stock_code='XAUUSD'
|
551
572
|
|
552
573
|
stooq_name1(stock_code)
|
553
574
|
|
@@ -605,7 +626,23 @@ def stooq_name1(stock_code,add_suffix=True):
|
|
605
626
|
|
606
627
|
#未找到证券代码
|
607
628
|
if t_name == 'Stooq':
|
608
|
-
|
629
|
+
|
630
|
+
#尝试不加后缀'.us'
|
631
|
+
url = f"https://stooq.com/q/?s={stock_code}"
|
632
|
+
response = requests.get(url,headers=headers)
|
633
|
+
if response.status_code == 200:
|
634
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
635
|
+
soup_title=soup.title
|
636
|
+
soup_text=soup_title.text
|
637
|
+
soup_text_list=soup_text.split(' - ')
|
638
|
+
|
639
|
+
t_name = soup_text_list[1].strip()
|
640
|
+
else:
|
641
|
+
pass
|
642
|
+
return stock_code
|
643
|
+
|
644
|
+
if t_name == 'Stooq':
|
645
|
+
return stock_code
|
609
646
|
|
610
647
|
#过滤名称中多余的尾部词汇
|
611
648
|
t_name=filter_stock_name(t_name)
|
@@ -623,6 +660,62 @@ def stooq_name1(stock_code,add_suffix=True):
|
|
623
660
|
return t_name
|
624
661
|
|
625
662
|
#==============================================================================
|
663
|
+
#==============================================================================
|
664
|
+
if __name__ == '__main__':
|
665
|
+
stock_code='AAPL'
|
666
|
+
stock_code='600519.SS'
|
667
|
+
stock_code='6758.T'
|
668
|
+
stock_code='6758.JP'
|
669
|
+
stock_code='ULVR.L'
|
670
|
+
stock_code='1155.KL'
|
671
|
+
stock_code='MSFT'
|
672
|
+
|
673
|
+
stock_code='GC=F'
|
674
|
+
stock_code='XAUUSD'
|
675
|
+
|
676
|
+
yahoo_name1(stock_code)
|
677
|
+
|
678
|
+
|
679
|
+
def yahoo_name1(stock_code):
|
680
|
+
|
681
|
+
import requests
|
682
|
+
from bs4 import BeautifulSoup
|
683
|
+
|
684
|
+
stock_code1=stock_code.lower()
|
685
|
+
|
686
|
+
#抓取证券名称
|
687
|
+
headers = {
|
688
|
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
689
|
+
}
|
690
|
+
url = f"https://finance.yahoo.com/quote/{stock_code1}"
|
691
|
+
response = requests.get(url,headers=headers)
|
692
|
+
if response.status_code == 200:
|
693
|
+
soup = BeautifulSoup(response.text, 'html.parser')
|
694
|
+
soup_title=soup.title
|
695
|
+
soup_text=soup_title.text
|
696
|
+
|
697
|
+
stock_code2=stock_code1.upper()
|
698
|
+
try:
|
699
|
+
pos=soup_text.index(stock_code2)
|
700
|
+
except:
|
701
|
+
pass
|
702
|
+
return stock_code
|
703
|
+
t_name = soup_text[:pos-1].strip()
|
704
|
+
else:
|
705
|
+
pass
|
706
|
+
return stock_code
|
707
|
+
|
708
|
+
#过滤名称中多余的尾部词汇
|
709
|
+
t_name=filter_stock_name(t_name).strip()
|
710
|
+
t_name=filter_stock_name(t_name).strip()
|
711
|
+
|
712
|
+
return t_name
|
713
|
+
|
714
|
+
#==============================================================================
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
626
719
|
if __name__=='__main__':
|
627
720
|
ticker='1155.KL'
|
628
721
|
ticker='MSFT'
|
@@ -646,6 +739,9 @@ if __name__=='__main__':
|
|
646
739
|
|
647
740
|
ticker='IBM'
|
648
741
|
|
742
|
+
ticker='XAUUSD'
|
743
|
+
short_name=False;add_suffix=True;maxlen=80
|
744
|
+
|
649
745
|
get_stock_name1_en(ticker)
|
650
746
|
|
651
747
|
def get_stock_name1_en(ticker,short_name=False,add_suffix=True,maxlen=80):
|
@@ -100,15 +100,15 @@ siat/risk_free_rate_test.py,sha256=CpmhUf8aEAEZeNu4gvWP2Mz2dLoIgBX5bI41vfUBEr8,4
|
|
100
100
|
siat/sector_china.py,sha256=QShFSaJMOydLKL-eCbUy_cWFnXnbdZW90lCUAp6B5lU,151007
|
101
101
|
siat/sector_china_test.py,sha256=1wq7ef8Bb_L8F0h0W6FvyBrIcBTEbrTV7hljtpj49U4,5843
|
102
102
|
siat/security_price.py,sha256=2oHskgiw41KMGfqtnA0i2YjNNV6cYgtlUK0j3YeuXWs,29185
|
103
|
-
siat/security_price2.py,sha256=
|
104
|
-
siat/security_prices.py,sha256=
|
103
|
+
siat/security_price2.py,sha256=dYwvz9H-uWp-Gyc1g_MId9k8cITS6ZHmjW-Fc2ypp-0,26587
|
104
|
+
siat/security_prices.py,sha256=HoCZ7YPrQYZHgKC-LyXFeeBCTfRc3EMMEiEg52SVv2w,109073
|
105
105
|
siat/security_prices_test.py,sha256=OEphoJ87NPKoNow1QA8EU_5MUYrJF-qKoWKNapVfZNI,10779
|
106
106
|
siat/security_trend.py,sha256=o0vpWdrJkmODCP94X-Bvn-w7efHhj9HpUYBHtLl55D0,17240
|
107
107
|
siat/security_trend2-20240620.py,sha256=QVnEcb7AyVbO77jVqfFsJffGXrX8pgJ9xCfoAKmWBPk,24854
|
108
108
|
siat/security_trend2.py,sha256=mamJtFAbXC1orGgMEmp0taPk-yUqWm-jdGf64bjhn2Q,29756
|
109
109
|
siat/setup.py,sha256=up65rQGLmTBkhtaMLowjoQXYmIsnycnm4g1SYmeQS6o,1335
|
110
110
|
siat/shenwan index history test.py,sha256=JCVAzOSEldHalhSFa3pqD8JI_8_djPMQOxpkuYU-Esg,1418
|
111
|
-
siat/stock.py,sha256=
|
111
|
+
siat/stock.py,sha256=JT_sq-9B8A25fzTh7rSj5-NnO2IlGbI_7O47ZZu9Dk0,159068
|
112
112
|
siat/stock_advice_linear.py,sha256=-twT7IGP-NEplkL1WPSACcNJjggRB2j4mlAQCkzOAuo,31655
|
113
113
|
siat/stock_base.py,sha256=uISvbRyOGy8p9QREA96CVydgflBkn5L3OXOGKl8oanc,1312
|
114
114
|
siat/stock_china.py,sha256=85Ggb21E2mrCYMdSSTTrkoyyLGXMK2V-BtlweHomSRg,93460
|
@@ -134,7 +134,7 @@ siat/transaction_test.py,sha256=Z8g1LJCN4-mnUByXMUMoFmN0t105cbmsz2QmvSuIkbU,1858
|
|
134
134
|
siat/translate-20230125.py,sha256=NPPSXhT38s5t9fzMvl_fvi4ckSB73ThLmZetVI-xGdU,117953
|
135
135
|
siat/translate-20230206.py,sha256=-vtI125WyaJhmPotOpDAmclt_XnYVaWU9ByLWZ6FyYE,118133
|
136
136
|
siat/translate-20230215.py,sha256=TJgtPE3n8IjljmZ4Pefy8dmHoNdFF-1zpML6BhA9FKE,121657
|
137
|
-
siat/translate.py,sha256=
|
137
|
+
siat/translate.py,sha256=hZljXo8Wlee9DQPHnn6Pwt2shl1Ky-yuAIpmNDTdsHA,251884
|
138
138
|
siat/translate_20240606.py,sha256=63IyHWEU3Uz9mjwyuAX3fqY4nUMdwh0ICQAgmgPXP7Y,215121
|
139
139
|
siat/translate_241003_keep.py,sha256=un7Fqe1v35MXsja5exZgjmLzrZtt66NARZIGlyFuGGU,218747
|
140
140
|
siat/universal_test.py,sha256=CDAOffW1Rvs-TcNN5giWVvHMlch1w4dp-w5SIV9jXL0,3936
|
@@ -142,9 +142,9 @@ siat/valuation.py,sha256=tSW5jyda3lChqBkdsbBGfdUeh9bCfjo6P93CjLif9eM,50825
|
|
142
142
|
siat/valuation_china.py,sha256=CVp1IwIsF3Om0J29RGkyxZLt4n9Ug-ua_RKhLwL9fUQ,69624
|
143
143
|
siat/valuation_market_china_test.py,sha256=gbJ0ioauuo4koTPH6WKUkqcXiQPafnbhU5eKJ6lpdLA,1571
|
144
144
|
siat/var_model_validation.py,sha256=R0caWnuZarrRg9939hxh3vJIIpIyPfvelYmzFNZtPbo,14910
|
145
|
-
siat/yf_name.py,sha256=
|
146
|
-
siat-3.7.
|
147
|
-
siat-3.7.
|
148
|
-
siat-3.7.
|
149
|
-
siat-3.7.
|
150
|
-
siat-3.7.
|
145
|
+
siat/yf_name.py,sha256=_WhJmon5KbTw3yR54bfTkiAhkP6GenuCcQ2Vmx5El2I,24025
|
146
|
+
siat-3.7.23.dist-info/LICENSE,sha256=NTEMMROY9_4U1szoKC3N2BLHcDd_o5uTgqdVH8tbApw,1071
|
147
|
+
siat-3.7.23.dist-info/METADATA,sha256=wdVz2LprfX0smE-JCetYAgGRH0pV0XnavkRyUK02uz4,8117
|
148
|
+
siat-3.7.23.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
149
|
+
siat-3.7.23.dist-info/top_level.txt,sha256=r1cVyL7AIKqeAmEJjNR8FMT20OmEzufDstC2gv3NvEY,5
|
150
|
+
siat-3.7.23.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|