模仿akshare方法,利用python获取期权期货数据

本文模仿akshare中的方法,利用python的request提取东方财富网站的期权、期货数据,可用于量化研究,

代码如下:

import json

import requests

import pandas as pd

#输出显示设置

import warnings

pd.set_option('display.max_rows',None)

pd.set_option('display.max_columns',None)

pd.set_option('expand_frame_repr',False)

pd.set_option('display.unicode.ambiguous_as_wide',True)

pd.set_option('display.unicode.east_asian_width',True)

warnings.filterwarnings("ignore")

def option_current_em() -> pd.DataFrame:

    """

    东方财富网-行情中心-期权市场

    https://quote.eastmoney.com/center/qqsc.html

    :return: 期权价格

    :rtype: pandas.DataFrame

    """

    url = 'http://77.push2.eastmoney.com/api/qt/clist/get'

    params = {

        'pn': '1',

        'pz': '200000',

        'po': '1',

        'np': '1',

        'ut': 'bd1d9ddb04089700cf9c27f6f7426281',

        'fltt': '2',

        'invt': '2',

        'fid': 'f3',

        'fs': 'm:10,m:140,m:141,m:151',

        'fields': 'f1,f2,

你可能感兴趣的:(python,json)