<jupyter_start><jupyter_text>1 全局获取股票对象==========1.1 获取股票对象-----------------通过全局管理对象 sm，或使用函数 get_stock。股票标识格式“市场标识+股票代码”，市场标识：沪市sh，深市sz。<jupyter_code>#s = getStock('sh000001')
s = sm['sh000001']
print(s)<jupyter_output>Stock(SH, 000001, 上证指数, 指数, 1, 1990-12-19 00:00:00, +infinity)<jupyter_text>1.2 遍历所有股票-----------------<jupyter_code>i = 0
#遍历所有股票
for s in sm:
    i += 1
    #print(s)
print("全部数量:", i)

len(sm)<jupyter_output>全部数量: 5848<jupyter_text>2 通过板块（Block）遍历股票对象================2.1 通过 sm.get_stock("板块分类", "板块名称") 获取相应板块------------------------------------------------------------<jupyter_code>blk = sm.get_block("指数板块", "上证380")
for s in blk:
    if not s.valid:
        print(s)<jupyter_output>Stock(SH, 600270, 外运发展, A股, 0, 2000-12-28 00:00:00, +infinity)
Stock(SH, 603959, 百利科技, A股, 0, 2016-05-17 00:00:00, +infinity)
Stock(SH, 603899, 晨光文具, A股, 0, 2015-01-27 00:00:00, +infinity)
Stock(SH, 603898, 好莱客, A股, 0, 2015-02-17 00:00:00, +infinity)
Stock(SH, 603895, 天永智能, A股, 0, 2018-01-22 00:00:00, +infinity)
Stock(SH, 600614, *ST鹏起, A股, 0, 1992-08-28 00:00:00, +infinity)
Stock(SH, 603888, 新华网, A股, 0, 2016-10-28 00:00:00, +infinity)
Stock(SH, 603989, 艾华集团, A股, 0, 2015-05-15 00:00:00, +infinity)
Stock(SH, 600240, *ST华业, A股, 0, 2000-06-28 00:00:00, +infinity)
Stock(SH, 603929, 亚翔集成, A股, 0, 2016-12-30 00:00:00, +infinity)
Stock(SH, 603939, 益丰药房, A股, 0, 2015-02-17 00:00:00, +infinity)
Stock(SH, 603997, 继峰股份, A股, 0, 2015-03-02 00:00:00, +infinity)<jupyter_text>2.1 获取自定义板块------------------自定义板块的板块分类固定为 “self”<jupyter_code>blk = sm.get_block("self", "1")
for s in blk:
    print(s)<jupyter_output>Stock(SH, 601018, 宁波港, A股, 1, 2010-09-28 00:00:00, +infinity)
Stock(SH, 600601, 方正科技, A股, 1, 1990-12-19 00:00:00, +infinity)
Stock(SH, 601098, 中南传媒, A股, 1, 2010-10-28 00:00:00, +infinity)
Stock(SH, 600050, 中国联通, A股, 1, 2002-10-09 00:00:00, +infinity)
Stock(SZ, 000001, 平安银行, A股, 1, 1991-01-02 00:00:00, +infinity)
Stock(SZ, 000958, 东方能源, A股, 1, 1999-12-23 00:00:00, +infinity)
Stock(SZ, 002339, 积成电子, A股, 1, 2010-01-22 00:00:00, +infinity)
Stock(SZ, 002685, 华东重机, A股, 1, 2012-06-12 00:00:00, +infinity)
Stock(SZ, 000728, 国元证券, A股, 1, 1997-05-22 00:00:00, +infinity)<jupyter_text>2.2 板块信息的配置-------------------板块信息在数据存放路径中 “block” 子目录下，目前采用的是钱龙的格式，你也可从钱龙相应的目录下拷贝最新的板块配置信息。![板块配置](images/002_01_block_config.png) 3 查看权息信息=======<jupyter_code>ws = sm['sz000001'].get_weight()
for w in ws:
    print(w)<jupyter_output>Weight(1991-04-03 00:00:00, 0, 0, 0, 0, 0, 150, 68)
Weight(1993-05-24 00:00:00, 3.5, 1, 16, 3, 5, 26941, 17912)
Weight(1994-07-11 00:00:00, 3, 1, 5, 5, 2, 43106, 28659)
Weight(1994-09-02 00:00:00, 0, 0, 0, 0, 0, 43106, 29707)
Weight(1995-09-25 00:00:00, 2, 0, 0, 3, 0, 51728, 35721)
Weight(1996-05-27 00:00:00, 5, 0, 0, 0, 5, 103456, 71393)
Weight(1997-08-25 00:00:00, 5, 0, 0, 2, 0, 155184, 107163)
Weight(1999-10-18 00:00:00, 0, 0, 0, 6, 0, 155184, 107163)
Weight(2000-11-06 00:00:00, 0, 3, 8, 0, 0, 194582, 139312)
Weight(2002-07-23 00:00:00, 0, 0, 0, 1.5, 0, 194582, 140936)
Weight(2003-09-29 00:00:00, 0, 0, 0, 1.5, 0, 194582, 140936)
Weight(2007-06-20 00:00:00, 1, 0, 0, 0, 0, 208676, 155019)
Weight(2008-01-21 00:00:00, 0, 0, 0, 0, 0, 229341, 175682)
Weight(2008-06-26 00:00:00, 0, 0, 0, 0, 0, 229341, 204652)
Weight(2008-06-27 00:00:00, 0, 0, 0, 0, 0, 238880, 214200)
Weight(2008-10-31 00:00:00, 3, 0, 0, 0.335, 0, 310543, 278461)
Weight(2009-06-22 00:00:00, 0, 0, 0, 0, 0, 310543, 292367)
We[...]
{'fraction_non_alphanumeric': 0.23856685115059714, 'fraction_numerical': 0.2988639673754733, 'mean_word_length': 4.299382716049383, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '134787', 'license': 'MIT', 'n_tokens_mistral': 2618, 'n_tokens_neox': 1950, 'n_words': 384, 'path': 'hikyuu/examples/notebook/002-HowToGetStock.ipynb', 'repo_name': 'scanfyu/hikyuu', 'size': '3433'}