get_historical_k_data
Fetch historical OHLCV data for Chinese A-share stocks by specifying stock code, date range, frequency, and adjustment settings. Supports daily, weekly, monthly, and intraday intervals.
Instructions
Fetches historical K-line (OHLCV) data for a Chinese A-share stock.
Args:
code: The stock code in Baostock format (e.g., 'sh.600000', 'sz.000001').
start_date: Start date in 'YYYY-MM-DD' format.
end_date: End date in 'YYYY-MM-DD' format.
frequency: Data frequency. Valid options (from Baostock):
'd': daily
'w': weekly
'm': monthly
'5': 5 minutes
'15': 15 minutes
'30': 30 minutes
'60': 60 minutes
Defaults to 'd'.
adjust_flag: Adjustment flag for price/volume. Valid options (from Baostock):
'1': Forward adjusted (后复权)
'2': Backward adjusted (前复权)
'3': Non-adjusted (不复权)
Defaults to '3'.
fields: Optional list of specific data fields to retrieve (must be valid Baostock fields).
If None or empty, default fields will be used (e.g., date, code, open, high, low, close, volume, amount, pctChg).
Returns:
A Markdown formatted string containing the K-line data table, or an error message.
The table might be truncated if the result set is too large.
Input Schema
Name | Required | Description | Default |
---|---|---|---|
adjust_flag | No | 3 | |
code | Yes | ||
end_date | Yes | ||
fields | No | ||
frequency | No | d | |
start_date | Yes |
Input Schema (JSON Schema)
{
"properties": {
"adjust_flag": {
"default": "3",
"title": "Adjust Flag",
"type": "string"
},
"code": {
"title": "Code",
"type": "string"
},
"end_date": {
"title": "End Date",
"type": "string"
},
"fields": {
"anyOf": [
{
"items": {
"type": "string"
},
"type": "array"
},
{
"type": "null"
}
],
"default": null,
"title": "Fields"
},
"frequency": {
"default": "d",
"title": "Frequency",
"type": "string"
},
"start_date": {
"title": "Start Date",
"type": "string"
}
},
"required": [
"code",
"start_date",
"end_date"
],
"title": "get_historical_k_dataArguments",
"type": "object"
}