Nine Star Ki (九星気学)¶
A Nine Star Ki engine computing the principal, monthly, daily, and tendency stars, plus the annual and monthly Lo Shu flying-star charts rendered into the summary.
from fortune_telling_core import Querent, ReadingRequest
from fortune_telling_core.traditions.nine_star_ki import (
DayStarEscapement,
NINE_STAR_KI_DECK,
NINE_STAR_KI_SPREAD,
build_engine,
)
engine = build_engine(
target_year=2026,
day_star_escapement=DayStarEscapement.JIAZI_AT_OR_BEFORE_SOLSTICE,
)
request = ReadingRequest(
deck_id=NINE_STAR_KI_DECK.id,
spread_id=NINE_STAR_KI_SPREAD.id,
querent=Querent(
id="sample",
display_name="Sample",
attributes={
"birth_datetime": "1990-01-01T12:00:00+00:00",
"latitude": "51.5074",
"longitude": "-0.1278",
},
),
)
reading = engine.cast(request)
Day-star escapement¶
Daily stars reverse direction around the winter and summer solstices, but schools differ on the
anchor day used for the first star in the new arc. build_engine() accepts
day_star_escapement, and requests may override it with the day_star_escapement option.
The default is jiazi_at_or_before_solstice, which preserves this package's original behavior:
Star 1 or Star 9 is anchored to the Jia-Zi day at or before the active solstice. The alternative
first_jiazi_after_solstice follows the Daily Flying Star convention that anchors Star 1 or Star 9
to the first Jia-Zi day after the relevant solstice. The selected value is recorded in
Reading.provenance.notes.
Annual chart year¶
The annual flying-star chart year is resolved most-specific-first: an explicit target_year
attribute wins, then the request-level as_of moment, then the
engine's build-time target_year, then requested_at.
nine_star_ki ¶
NINE_STAR_KI_DECK
module-attribute
¶
NINE_STAR_KI_DECK = Deck(
id="nsk.deck.stars.v1",
symbols=tuple(
(
Symbol(
id=star.symbol_id,
name=star.cjk,
attributes={
"number": str(star.number),
"slug": star.slug,
"cjk": star.cjk,
"color": star.color,
"element": star.element,
"trigram": star.trigram,
"home_palace": star.home_palace,
},
)
)
for star in STARS
),
)
NINE_STAR_KI_SPREAD
module-attribute
¶
NINE_STAR_KI_SPREAD = Spread(
id="nsk.spread.natal.v1",
name="Nine Star Ki",
positions=(
Position(
"principal",
"Principal Star",
"Year star from the Risshun solar year.",
),
Position(
"monthly",
"Monthly Star",
"Month star from the sectional solar month.",
),
Position(
"daily",
"Daily Star",
"Day star from the solstice escapement cycle.",
),
Position(
"tendency",
"Tendency Star",
"Inclination star from the natal year chart.",
),
),
)
DayStarEscapement ¶
Bases: StrEnum
Daily-star solstice reversal schools.
JIAZI_AT_OR_BEFORE_SOLSTICE is this package's compatibility default:
the active winter or summer solstice is rounded to a civil day, then the
nearest preceding Jia-Zi day is assigned Star 1 for the forward arc or
Star 9 for the backward arc.
FIRST_JIAZI_AFTER_SOLSTICE follows a documented Daily Flying Star
convention in which Star 1 or Star 9 presides on the first Jia-Zi day
after the relevant solstice. See the "Daily Flying Star" rules cited on
https://en.wikipedia.org/wiki/Flying_Star_Feng_Shui.
NineStarKiEngine ¶
NineStarKiEngine(
ephemeris: Ephemeris | None = None,
*,
time_model: TimeModel = TimeModel.CLOCK,
day_star_escapement: DayStarEscapement = DayStarEscapement.JIAZI_AT_OR_BEFORE_SOLSTICE,
target_year: int | None = None,
)
Bases: AbstractEngine
Nine Star Ki engine using shared solar-term astronomy.
The engine deterministically computes principal, monthly, daily, and tendency stars, then renders annual and monthly flying-star charts into the reading summary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeris
|
Ephemeris | None
|
Optional backend implementing the shared ephemeris protocol.
Defaults to |
None
|
time_model
|
TimeModel
|
Default time adjustment model used when the request does not specify one. |
CLOCK
|
day_star_escapement
|
DayStarEscapement
|
Default daily-star solstice reversal school used
when the request does not specify |
JIAZI_AT_OR_BEFORE_SOLSTICE
|
target_year
|
int | None
|
Default annual chart year. When omitted, the request year is used. |
None
|
Source code in src/fortune_telling_core/traditions/nine_star_ki/engine.py
deck ¶
Return the Nine Star Ki deck.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ReadingRequest
|
Reading request whose |
required |
Returns:
| Type | Description |
|---|---|
Deck
|
The bundled nine-star deck. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the requested deck is unsupported. |
Source code in src/fortune_telling_core/traditions/nine_star_ki/engine.py
spread ¶
Return the Nine Star Ki spread.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ReadingRequest
|
Reading request whose |
required |
Returns:
| Type | Description |
|---|---|
Spread
|
The bundled Nine Star Ki spread. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If the requested spread is unsupported. |
Source code in src/fortune_telling_core/traditions/nine_star_ki/engine.py
draw ¶
Compute Nine Star Ki placements as a deterministic draw.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ReadingRequest
|
Reading request with |
required |
rng
|
Rng
|
Ignored. The argument is present for |
required |
Returns:
| Type | Description |
|---|---|
Draw
|
A draw with natal and chart selections. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If required birth data or options are invalid. |
EphemerisError
|
If the configured ephemeris cannot compute solar terms. |
Source code in src/fortune_telling_core/traditions/nine_star_ki/engine.py
cast ¶
Compute a Nine Star Ki chart without a caller RNG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
ReadingRequest
|
Reading request containing birth data and optional chart configuration. |
required |
Returns:
| Type | Description |
|---|---|
Reading
|
A reading with star placements and chart summary text. |
Raises:
| Type | Description |
|---|---|
ValidationError
|
If required birth data or options are invalid. |
EphemerisError
|
If the configured ephemeris cannot compute solar terms. |
Source code in src/fortune_telling_core/traditions/nine_star_ki/engine.py
build_engine ¶
build_engine(
ephemeris: Ephemeris | None = None,
*,
time_model: TimeModel = TimeModel.CLOCK,
day_star_escapement: DayStarEscapement = DayStarEscapement.JIAZI_AT_OR_BEFORE_SOLSTICE,
target_year: int | None = None,
) -> NineStarKiEngine
Create a Nine Star Ki engine.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ephemeris
|
Ephemeris | None
|
Optional ephemeris backend. Defaults to the built-in pure-Python backend. |
None
|
time_model
|
TimeModel
|
Default time adjustment model. |
CLOCK
|
day_star_escapement
|
DayStarEscapement
|
Default daily-star solstice reversal school. |
JIAZI_AT_OR_BEFORE_SOLSTICE
|
target_year
|
int | None
|
Default annual chart year. |
None
|
Returns:
| Type | Description |
|---|---|
NineStarKiEngine
|
A new |