跳转至

KLine

KLineMapping

字段映射 股票-KLine

KLine

KLine(
    market_code: Annotated[
        Optional[str], 市场代码, False
    ] = None,
    security_code: Annotated[
        Optional[str], 证券代码, False
    ] = None,
    plate_code: Annotated[
        Optional[str], 板块代码, False
    ] = None,
    end_date: Annotated[
        Optional[str], 开始时间, False
    ] = "20500101",
    size: Annotated[Optional[int], 返回数据条数, False] = 120,
    period: Annotated[
        Literal[
            "1m",
            "5m",
            "15m",
            "30m",
            "60m",
            "1D",
            "1W",
            "1M",
        ],
        "",
        False,
    ] = "5m",
    adjust: Annotated[
        Literal["前复权", "后赋权", "不赋权"], "", False
    ] = "前复权",
    verbose: Annotated[
        Optional[bool], 是否显示日志, False
    ] = False,
    logger: Annotated[
        Optional[Callable], 日志对象, False
    ] = None,
    **kwargs: Annotated[Any, 其他参数, False]
)

查询 股票-KLine

注意:非交易日时,1分钟线1m无数据。

Notes
from wisecon.stock.kline import *

# 0. 查询沪深300 K线数据
data = KLine(market_code="000300", period="1D", size=5).load()
data.to_frame(chinese_column=True)

# 1. 查询股票的 K线数据
data = KLine(security_code="300069", period="1D", size=5).load()
data.to_frame(chinese_column=True)

# 2. 查询板块的 K线数据
data = KLine(plate_code="BK0887", period="1D", size=5).load()
print(data.to_markdown(chinese_column=True))

Parameters:

Name Type Description Default
market_code Annotated[Optional[str], 市场代码, False]

市场代码

None
security_code Annotated[Optional[str], 证券代码, False]

股票代码

None
plate_code Annotated[Optional[str], 板块代码, False]

板块代码

None
end_date Annotated[Optional[str], 开始时间, False]

截止日期

'20500101'
size Annotated[Optional[int], 返回数据条数, False]

返回数据条数

120
period Annotated[Literal['1m', '5m', '15m', '30m', '60m', '1D', '1W', '1M'], '', False]

K线周期["1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"]

'5m'
adjust Annotated[Literal['前复权', '后赋权', '不赋权'], '', False]

复权类型["前复权", "后赋权", "不赋权"]

'前复权'
verbose Annotated[Optional[bool], 是否显示日志, False]

是否打印日志

False
logger Annotated[Optional[Callable], 日志对象, False]

日志对象

None
**kwargs Annotated[Any, 其他参数, False]

其他参数

{}
Source code in wisecon\stock\kline\kline.py
def __init__(
        self,
        market_code: Annotated[Optional[str], "市场代码", False] = None,
        security_code: Annotated[Optional[str], "证券代码", False] = None,
        plate_code: Annotated[Optional[str], "板块代码", False] = None,
        end_date: Annotated[Optional[str], "开始时间", False] = "20500101",
        size: Annotated[Optional[int], "返回数据条数", False] = 120,
        period: Annotated[Literal["1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"], "", False] = "5m",
        adjust: Annotated[Literal["前复权", "后赋权", "不赋权"], "", False] = "前复权",
        verbose: Annotated[Optional[bool], "是否显示日志", False] = False,
        logger: Annotated[Optional[Callable], "日志对象", False] = None,
        **kwargs: Annotated[Any, "其他参数", False]
):
    """
    Notes:
        ```python
        from wisecon.stock.kline import *

        # 0. 查询沪深300 K线数据
        data = KLine(market_code="000300", period="1D", size=5).load()
        data.to_frame(chinese_column=True)

        # 1. 查询股票的 K线数据
        data = KLine(security_code="300069", period="1D", size=5).load()
        data.to_frame(chinese_column=True)

        # 2. 查询板块的 K线数据
        data = KLine(plate_code="BK0887", period="1D", size=5).load()
        print(data.to_markdown(chinese_column=True))
        ```

    Args:
        market_code: 市场代码
        security_code: 股票代码
        plate_code: 板块代码
        end_date: 截止日期
        size: 返回数据条数
        period: K线周期`["1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"]`
        adjust: 复权类型`["前复权", "后赋权", "不赋权"]`
        verbose: 是否打印日志
        logger: 日志对象
        **kwargs: 其他参数
    """
    self.market_code = market_code
    self.security_code = security_code
    self.plate_code = plate_code
    self.end_date = end_date
    self.size = size
    self.period = period
    self.adjust = adjust
    self.mapping = KLineMapping()
    self.verbose = verbose
    self.logger = logger
    self.kwargs = kwargs
    self.request_set(description="股票-KLine")
    self.validate_date_format(date=end_date, _format="%Y%m%d")

KlineMinMapping

字段映射 股票-KlineMin

KlineMin

KlineMin(
    security_code: Annotated[
        Optional[str], 证券代码, False
    ] = None,
    plate_code: Annotated[
        Optional[str], 板块代码, False
    ] = None,
    n_days: Annotated[Optional[int], 数据时限, False] = 1,
    verbose: Annotated[
        Optional[bool], 是否打印日志, False
    ] = False,
    logger: Annotated[
        Optional[Callable], 日志对象, False
    ] = None,
    **kwargs: Annotated[Any, 其他参数, False]
)

查询 股票-KlineMin,可以获取最大近5天的分钟级K线数据

查询股票1分钟级的K线数据

Notes
from wisecon.stock.kline import *

# 1. 查询股票的 K线数据
data = KlineMin(security_code="300069", n_days=1).load()
data.to_frame(chinese_column=True)

# 2. 查询板块的 K线数据
data = KlineMin(plate_code="BK0887", n_days=1).load()
print(data.to_markdown(chinese_column=True))

Parameters:

Name Type Description Default
security_code Annotated[Optional[str], 证券代码, False]

股票代码

None
plate_code Annotated[Optional[str], 板块代码, False]

板块代码

None
n_days Annotated[Optional[int], 数据时限, False]

查询天数

1
verbose Annotated[Optional[bool], 是否打印日志, False]

是否打印日志

False
logger Annotated[Optional[Callable], 日志对象, False]

日志对象

None
**kwargs Annotated[Any, 其他参数, False]

其他参数

{}
Source code in wisecon\stock\kline\kline_min.py
def __init__(
        self,
        security_code: Annotated[Optional[str], "证券代码", False] = None,
        plate_code: Annotated[Optional[str], "板块代码", False] = None,
        n_days: Annotated[Optional[int], "数据时限", False] = 1,
        verbose: Annotated[Optional[bool], "是否打印日志", False] = False,
        logger: Annotated[Optional[Callable], "日志对象", False] = None,
        **kwargs: Annotated[Any, "其他参数", False]
):
    """
    查询股票1分钟级的K线数据

    Notes:
        ```python
        from wisecon.stock.kline import *

        # 1. 查询股票的 K线数据
        data = KlineMin(security_code="300069", n_days=1).load()
        data.to_frame(chinese_column=True)

        # 2. 查询板块的 K线数据
        data = KlineMin(plate_code="BK0887", n_days=1).load()
        print(data.to_markdown(chinese_column=True))
        ```

    Args:
        security_code: 股票代码
        plate_code: 板块代码
        n_days: 查询天数
        verbose: 是否打印日志
        logger: 日志对象
        **kwargs: 其他参数
    """
    self.security_code = security_code
    self.plate_code = plate_code
    self.n_days = n_days
    self.mapping = KlineMinMapping()
    self.verbose = verbose
    self.logger = logger
    self.kwargs = kwargs
    self.request_set(description="股票-KlineMin")
    self.validate_n_days()

validate_n_days

validate_n_days()
Source code in wisecon\stock\kline\kline_min.py
def validate_n_days(self):
    """"""
    if self.n_days > 5:
        raise ValueError("n_days should be less than or equal to 5")