English | 中文
A VeighNa (vn.py) database adapter that keeps bar and tick history in Apache
IoTDB, using the Tree data model over the native RPC interface of the
apache-iotdb Python client.
- Registers as the
iotdbdatabase adapter and implements VeighNa'sBaseDatabasefor bars and ticks. - Writes
Tabletbatches of at most 1000 rows into one device per series:<database>.bars.s<symbol>.s<exchange>.s<interval>for bars and<database>.ticks.s<symbol>.s<exchange>for ticks. Identifier components are base32-encoded into path-safe segments and decoded again for overviews. - Loads bars and ticks with inclusive time bounds and derives overviews (count plus start and end time) from the stored timeseries.
- Counts the points, deletes the device range, and closes the pool on demand.
| Component | Supported |
|---|---|
| Apache IoTDB server | 2.0.x, Tree model, timestamp_precision=ms |
| Data model | Tree only; Table-model tables are neither created nor translated |
| Protocol | Native Thrift RPC on port 6667 |
| Python | 3.10 and 3.12 (both run in CI) |
| VeighNa | 4.x vnpy.trader.database interface |
apache-iotdb>=2.0.4,<3.0 is the adapter's only runtime dependency; VeighNa
itself is required to use it and to run the tests.
Requires Python 3.10 or newer and access to PyPI.
git clone https://github.com/iotdb-ecosystem/vnpy-iotdb-storage.git
cd vnpy-iotdb-storage
python -m venv .venv
. .venv/bin/activate
python -m pip install -e ".[test]"The test extra adds vnpy>=4.0 and pytest>=8. VeighNa pulls pyside6 and
ta-lib, which ship wheels, so no compiler is needed. Not on PyPI: use a clone.
python -m pip install -e ".[test]"
python -m pytest -qCI runs exactly that command on both Python versions. The suite is offline:
tests/conftest.py points VeighNa's settings at a temporary directory and pins
database.timezone to Asia/Shanghai; the adapter tests replace the session
pool and Tablet with fakes.
Not run in CI, because it needs a server:
tests/test_iotdb_database.py::test_live_market_data writes, reads, lists and
deletes real market data; it is skipped unless IOTDB_TEST_PORT,
IOTDB_TEST_USER and IOTDB_TEST_PASSWORD are set.
The adapter reads VeighNa's global settings (vt_setting.json in the working
directory, or the Trader UI). Restart Trader after editing them.
| Setting | Meaning | Example |
|---|---|---|
database.name |
Adapter module name | iotdb |
database.host |
IoTDB RPC host | 127.0.0.1 |
database.port |
IoTDB RPC port | 6667 |
database.database |
Tree database, name or root.name |
vnpy |
database.user |
IoTDB user | root |
database.password |
IoTDB password | root |
database.timezone |
Timezone for naive datetimes | Asia/Shanghai |
database.iotdb.* |
pool_size, wait_timeout_ms, query_timeout_ms |
5, 30000, 30000 |
{
"database.name": "iotdb",
"database.host": "127.0.0.1",
"database.port": 6667,
"database.database": "vnpy",
"database.user": "root",
"database.password": "root",
"database.timezone": "Asia/Shanghai"
}from vnpy_iotdb import Database
db = Database() # reads the settings above, creates root.vnpy if needed
db.save_bar_data([bar])
bars = db.load_bar_data(bar.symbol, bar.exchange, bar.interval, start, end)
db.close()With database.name set to iotdb, the VeighNa data manager and CTA engine
use the adapter directly.
Independent project. Maintained here; contributions and adoption inquiries are welcome.
Apache-2.0 - see LICENSE. Derived from the vn.py project (MIT, Copyright (c) 2021-present, Xiaoyou Chen); see NOTICE.