跳转至

KLine

KLineMapping

字段映射 股票-KLine

KLine

KLine(
    security_code: Optional[str] = None,
    plate_code: Optional[str] = None,
    end_date: Optional[str] = "20500101",
    size: Optional[int] = 120,
    period: Literal[
        "1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"
    ] = "5m",
    adjust: Literal[
        "前复权", "后赋权", "不赋权"
    ] = "前复权",
    verbose: Optional[bool] = False,
    logger: Optional[Callable] = None,
    **kwargs: Any
)

查询 股票-KLine

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

Notes
from wisecon.stock.kline import *

# 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
security_code Optional[str]

股票代码

None
plate_code Optional[str]

板块代码

None
end_date Optional[str]

截止日期

'20500101'
size Optional[int]

返回数据条数

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

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

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

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

'前复权'
verbose Optional[bool]

是否打印日志

False
logger Optional[Callable]

日志对象

None
**kwargs Any

其他参数

{}
Source code in wisecon\stock\kline\kline.py
def __init__(
        self,
        security_code: Optional[str] = None,
        plate_code: Optional[str] = None,
        end_date: Optional[str] = "20500101",
        size: Optional[int] = 120,
        period: Literal["1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"] = "5m",
        adjust: Literal["前复权", "后赋权", "不赋权"] = "前复权",
        verbose: Optional[bool] = False,
        logger: Optional[Callable] = None,
        **kwargs: Any
):
    """
    Notes:
        ```python
        from wisecon.stock.kline import *

        # 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:
        security_code: 股票代码
        plate_code: 板块代码
        end_date: 截止日期
        size: 返回数据条数
        period: K线周期`["1m", "5m", "15m", "30m", "60m", "1D", "1W", "1M"]`
        adjust: 复权类型`["前复权", "后赋权", "不赋权"]`
        verbose: 是否打印日志
        logger: 日志对象
        **kwargs: 其他参数
    """
    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: Optional[str] = None,
    plate_code: Optional[str] = None,
    n_days: Optional[int] = 1,
    verbose: Optional[bool] = False,
    logger: Optional[Callable] = None,
    **kwargs: Any
)

查询 股票-KlineMin,可以获取最大近5天的分钟级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 Optional[str]

股票代码

None
plate_code Optional[str]

板块代码

None
n_days Optional[int]

查询天数

1
verbose Optional[bool]

是否打印日志

False
logger Optional[Callable]

日志对象

None
**kwargs Any

其他参数

{}
Source code in wisecon\stock\kline\kline_min.py
def __init__(
        self,
        security_code: Optional[str] = None,
        plate_code: Optional[str] = None,
        n_days: Optional[int] = 1,
        verbose: Optional[bool] = False,
        logger: Optional[Callable] = None,
        **kwargs: Any
):
    """
    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")