• Python 读取股市行情信息


    在股票市场的金融数据方面,可以利用以下组件获得数据来源

    1.国内需要利用akshare组件包来处理,官方网址

    https://www.akshare.xyz

    简单实例如下

    import akshare as ak
    stock_us_daily_df = ak.stock_us_daily(symbol="AAPL", adjust="")
    print(stock_us_daily_df)

    2.利用pandas组件包

    官方网址

    https://pandas.pydata.org/

    这个组件在境外比较好用,国内读取股市信息可能需要VPN

    import investpy
    import matplotlib as mp
    import pandas as pd
    
    
    a=pd.Series(['1a','2a','3a','4a','5a'],index=[1,2,3,4,5])
    ###
    '''
    df = investpy.get_stock_historical_data(stock='AAPL',
                                            country='United States',
                                            from_date='01/01/2010',
                                            to_date='01/01/2020')
    print(df.head())
    ###
    '''
    
    print(a)

    3.

    官方网址

    https://www.tushare.pro/

    实例如下:

    import tushare as ts
    
    ts.set_token('28d80dc9f7e55b29af68e245c8f68ce1a7a163ca05691b12c04d00aa')
    pro = ts.pro_api('28d80dc9f7e55b29af68e245c8f68ce1a7a163ca05691b12c04d00aa')
    df = pro.query('trade_cal', exchange='', start_date='20180901', end_date='20181001', fields='exchange,cal_date,is_open,pretrade_date', is_open='0')
    df = pro.trade_cal(exchange='', start_date='20180901', end_date='20181001', fields='exchange,cal_date,is_open,pretrade_date', is_open='0')
    
    df = pro.stock_basic(**{
        "ts_code": '000100.SZ',
        "name": "TCL",
        "exchange": "SZSE",
        "market": "",
        "is_hs": "",
        "list_status": "",
        "limit": "",
        "offset": ""
    }, fields=[
        "ts_code",
        "symbol",
        "name",
        "area",
        "industry",
        "market",
        "list_date",
        "fullname",
        "enname",
        "cnspell",
        "exchange",
        "curr_type",
        "list_status",
        "delist_date",
        "is_hs"
    ])
    print(df)
  • 相关阅读:
    ElasticSearch学习记录
    用java代码手动控制kafkaconsumer偏移量
    kafka0.9.0及0.10.0配置属性
    kafka常用命令
    kafka消费者客户端(0.9.0.1API)
    kafka入门教程链接
    编程内功
    bzoj3145:[Feyat cup 1.5]Str
    3 SpringBoot与微服务
    2 微服务存在的问题和解决方案
  • 原文地址:https://www.cnblogs.com/yinxuejunfeng/p/16322102.html
Copyright © 2020-2023  润新知