Skip to content

Commit 5e1c817

Browse files
committed
chore: bump version to 2.12.3
1 parent 2210201 commit 5e1c817

10 files changed

Lines changed: 1668 additions & 744 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.12.3] - 2026-06-06
9+
10+
### Fixed
11+
12+
- **PTrade market-data compatibility**`get_history` and `get_price` DataFrame returns now preserve legacy PTrade-style integer positional access for column Series, avoiding pandas `FutureWarning`/`KeyError` when strategies use examples like `series[-1]`.
13+
- **history cache shape isolation**`get_history` now distinguishes single-stock string requests from one-element list requests in its cache key, preventing call-order-dependent return shapes.
14+
- **daily date-index resolution** — prebuilt and lazy daily date indexes now use the same int64 nanosecond contract. Datetime indexes stored at non-nanosecond resolution, including pandas 3 `datetime64[us]`, no longer miss exact dates and fall back to the wrong trading day.
15+
- **valuation date lookup**`get_fundamentals(table="valuation")` normalizes datetime-index lookups to nanoseconds before searching, keeping realtime market-cap calculations on the requested trading day.
16+
17+
### Tests
18+
19+
- Added contract tests for lazy vs prebuilt daily date indexes, PTrade market-data return shapes, legacy positional Series access, fundamentals/valuation date behavior, and pandas 3 non-nanosecond datetime indexes.
20+
821
## [2.12.2] - 2026-05-27
922

1023
### Fixed

README.de.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/)
88
[![License](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
99
[![License: Commercial](https://img.shields.io/badge/License-Commercial--Available-red)](licenses/LICENSE-COMMERCIAL.md)
10-
[![Version](https://img.shields.io/badge/Version-2.12.2-orange.svg)](#)
10+
[![Version](https://img.shields.io/badge/Version-2.12.3-orange.svg)](#)
1111
[![PyPI](https://img.shields.io/pypi/v/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1212
[![PyPI - Downloads](https://img.shields.io/pypi/dm/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1313

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ English | [中文](README.zh-CN.md) | [Deutsch](README.de.md)
77
[![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/)
88
[![License](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
99
[![License: Commercial](https://img.shields.io/badge/License-Commercial--Available-red)](licenses/LICENSE-COMMERCIAL.md)
10-
[![Version](https://img.shields.io/badge/Version-2.12.2-orange.svg)](#)
10+
[![Version](https://img.shields.io/badge/Version-2.12.3-orange.svg)](#)
1111
[![PyPI](https://img.shields.io/pypi/v/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1212
[![PyPI - Downloads](https://img.shields.io/pypi/dm/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1313

README.zh-CN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
[![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/)
88
[![License](https://img.shields.io/badge/License-AGPL--3.0-blue.svg)](LICENSE)
99
[![License: Commercial](https://img.shields.io/badge/License-Commercial--Available-red)](licenses/LICENSE-COMMERCIAL.md)
10-
[![Version](https://img.shields.io/badge/Version-2.12.2-orange.svg)](#)
10+
[![Version](https://img.shields.io/badge/Version-2.12.3-orange.svg)](#)
1111
[![PyPI](https://img.shields.io/pypi/v/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1212
[![PyPI - Downloads](https://img.shields.io/pypi/dm/simtradelab.svg)](https://pypi.org/project/simtradelab/)
1313

poetry.lock

Lines changed: 996 additions & 697 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Poetry configuration
22
[tool.poetry]
33
name = "simtradelab"
4-
version = "2.12.2"
4+
version = "2.12.3"
55
description = "Lightweight quantitative backtesting framework with PTrade API simulation | 轻量级量化回测框架"
66
authors = ["kay <kayou@duck.com>"]
77
license = "AGPL-3.0-or-later"

src/simtradelab/ptrade/api.py

Lines changed: 125 additions & 42 deletions
Large diffs are not rendered by default.

tests/unit/test_api.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
测试交易API
66
"""
77

8-
import pytest
8+
import numpy as np
99
import pandas as pd
10+
import pytest
1011

1112
from simtradelab.ptrade.lifecycle_controller import LifecyclePhase, PTradeLifecycleError
1213

@@ -82,6 +83,21 @@ def test_get_history(self, ptrade_api):
8283
# 应该返回DataFrame或dict
8384
assert result is None or isinstance(result, (pd.DataFrame, dict))
8485

86+
def test_prebuilt_date_index_matches_lazy_contract(self, ptrade_api):
87+
"""预构建索引应与懒加载索引使用相同的 int64 日期契约。"""
88+
stock = '600000.SH'
89+
query_dt = pd.Timestamp('2024-01-02 14:30')
90+
91+
ptrade_api.prebuild_date_index(stocks=[stock])
92+
93+
date_dict, sorted_i8 = ptrade_api.get_stock_date_index(stock)
94+
assert isinstance(sorted_i8, np.ndarray)
95+
assert sorted_i8.dtype == np.dtype('int64')
96+
assert date_dict[pd.Timestamp('2024-01-02').value] == 1
97+
98+
stock_df = ptrade_api.data_context.stock_data_dict[stock]
99+
assert ptrade_api._resolve_daily_index(stock, stock_df, query_dt) == 1
100+
85101

86102
class TestStockStatusAPI:
87103
"""测试股票状态API"""

0 commit comments

Comments
 (0)