Releases: apl9000/athena
Releases Β· apl9000/athena
Athena v0.4.0
Release of Athena v0.4.0.
Athena v0.3.0
The "Tax Realism Release". Adds pluggable tax accounting via a
TaxRegime protocol with two implementations: Canadian ACB with the
superficial-loss rule and US FIFO with the wash-sale rule and
short-term/long-term classification. Additive and back-compatible β
existing v0.2 strategies that don't set taxRegime get the NoTaxes
default and behave identically.
Added
- AthenaCore:
TaxLot(per-share basis withwashSaleAdjustment),
Disposition(per-sale realized P&L withholdingPeriod,
washSaleDisallowed, andtaxableRealizedPnL),HoldingPeriod
(.shortTerm/.longTermwith strict > 365-day classification),
TaxYearSummary(per-year per-currency aggregation with gross
gain/loss, ST/LT split, and washed amounts),TaxRegimeprotocol
withdispose(fill:lots:)andreconcileDisallowance(...)hooks,
NoTaxesdefault.Portfoliogainslots(live FIFO inventory) and
lotHistory(immutable audit log); both are populated on buy fills
and consumed/scaled by sells and splits β only when a tax regime is
set. - AthenaCore (TaxRegimes):
CanadianACB(pooled basis at sale time
per CRA convention + superficial-loss disallowance),USWashSale
(FIFO lot consumption + ST/LT classification + wash-sale
disallowance). Both regimes share a generic Β±30-day reconciliation
helper. - AthenaBrokers:
SimulatedBroker.taxRegimeinit parameter and
recordedDispositions()accessor; provisional dispositions are
recorded during the run and reconciled at end-of-backtest. - AthenaBacktest:
BacktestConfig.taxRegime.BacktestResult
gainsdispositions: [Disposition],taxYearSummaries: [TaxYearSummary], andfinalLots: [TaxLot](all default-empty for
back-compat). Engine performs end-of-run reconciliation so
forward-looking 30-day rules can adjust earlier dispositions. - TaxAwareExample: demonstrates US wash-sale triggering with full
loss disallowance and replacement-lot basis adjustment.
Design notes
- Forward-looking reconciliation. Wash-sale and superficial-loss
rules can't be settled at the time of sale because a replacement
purchase 20 days later would retroactively disallow the loss. The
broker records provisional dispositions; the engine asks the regime
to reconcile them once the run ends and the full Β±30-day window has
materialized. - Lot work is conditional. When
taxRegimeisNoTaxes, the
Portfolio does zero lot work β v0.2 callers see no overhead and no
behavioral change. - CanadianACB uses pooled basis at the moment of sale (matching
CRA convention and the existingPosition.avgCostfield), but still
walks lots FIFO to attribute open-dates for reporting. - A lot can't replace itself. Reconciliation skips lots whose
openDatematches the disposition'sopenDateso the lot being
sold isn't mistakenly counted as its own replacement.
Known limitations
- FIFO only; specific-identification deferred.
- Tax events use the disposition currency; cross-currency reporting
(USD dispositions β CAD home currency) deferred to multi-currency
release. - Single-portfolio model β spousal-account ACB pooling out of scope.
- Stock dividends, DRIP, and return-of-capital still deferred.
Athena v0.2.0
The "Correctness Release". Closes two known v0.1 limitations: stop/stop-limit
order fills and corporate actions (splits + cash dividends). Additive,
non-breaking β existing v0.1 strategies continue to work unchanged.
Added
- AthenaBrokers: stop and stop-limit order fill semantics in
SimulatedBroker. Stops trigger when bar high/low crosses the stop
price; gap-throughs fill at the open as worst-case. Stop-limits convert
to a limit order at the limit price on trigger; gap-through-limit
fills at open if open is on the favorable side, otherwise fills at
limit if reached intra-bar. - AthenaCore:
CorporateActionenum (.split(ratio:),
.cashDividend(perShare:)),CorporateActionEvent,
CorporateActionSourceprotocol,NoCorporateActionsdefault.
PortfoliogainsapplySplit(symbol:ratio:)(multiplies share count,
divides per-share ACB; total cost basis preserved) and
applyCashDividend(symbol:perShare:)(credits cash, no ACB change). - AthenaData:
CSVCorporateActionSourcereading
Date,Symbol,Type,Valueschema withsplitandcashDividendtypes. - AthenaBacktest:
BacktestConfig.corporateActionsparameter; engine
applies actions at the start of each bar before broker fills and
indicator updates. - ProtectiveStopExample: demonstrates a buy-and-hold position with a
10% protective stop using a GTC sell stop order.
Design notes
- Position adjustment, not price adjustment. Bars stay raw; positions
and cash adjust on ex-date. Strategies see real prices (matching live
trading). If you use pre-adjusted bars (e.g. Yahoo "Adj Close"), simply
omit a corporate-action source.
Known limitations
- Spin-offs not yet supported (complex ACB allocation, deferred).
- Stock dividends and DRIP reinvestment not yet supported.
- Return-of-capital tax treatment deferred to a future TaxRegime release.
- Multi-currency FX adjustments on USD dividends deferred to multi-currency
phase. - No tax-aware accounting (deferred to a future release).
- macOS only in CI; Linux support is best-effort.
- Real market data is not committed; users provide their own.
Athena v0.1.0
Initial public release.
Added
- AthenaCore:
Symbol,Currency,Money,Bar,Order,OrderType,
TimeInForce,Side,Fill,Position,Portfolio(actor with
ACB-tracked positions),Clockprotocol withSystemClockand
BacktestClock,Strategyprotocol,StrategyContext,Brokerprotocol,
BrokerError,IndicatorProviderprotocol. - AthenaIndicators: incremental
SMA,EMA,RSI(Wilder's smoothing),
MACD,BollingerBands,ATR(Wilder's smoothing).IndicatorCache
actor exposing all six viaIndicatorProviderwith per-symbol isolation. - AthenaBrokers:
SimulatedBrokerwith next-bar-open market fills and
intra-bar limit fills.CommissionModelimplementations:FreeCommission,
FixedCommission,PerShareCommission,QuestradeStockCommission.
SlippageModelimplementations:NoSlippage,FixedBpsSlippage,
VolumeImpactSlippage. - AthenaData:
CSVDataSourcefor Yahoo Finance-format daily OHLCV CSVs
with date-range filtering. - AthenaBacktest:
BacktestEngineactor wiring portfolio, broker,
indicators, strategy, and clock.BacktestResultwithtotalReturn,
maxDrawdown, andsharpe. - MACrossoverExample: end-to-end example running a 50/200 simple moving
average crossover strategy on SPY daily bars. - BuyAndHoldExample: baseline benchmark β buy on bar 1, hold to the end.
- RSIMeanReversionExample: RSI(14) oversold/overbought entries on SPY.
- BollingerBreakoutExample: long on close above the upper Bollinger band,
exit on a return to the middle band. - MACDSignalExample: MACD(12,26,9) signal-line crossover, with state
tracking so trades fire only on transitions. - CI: GitHub Actions workflow running build, test, and β₯90% line
coverage gate on every push and PR. - CD: GitHub Actions workflow producing a release on every
v*.*.*tag,
with notes auto-extracted from this changelog. - Apache 2.0 license, README, and CONTRIBUTING guide.
Known limitations
- Stop and stop-limit orders are accepted but not yet filled (returns nil).
- No corporate actions (splits, dividends, spin-offs).
- No tax-aware accounting (deferred to v0.2).
- macOS only in CI; Linux support is best-effort.
- Real market data (
data/SPY.csv) is not committed; users provide their own.