Make `MarketSimulator`, `TransactionCost`, `HoldingCost` agnostic to asset class and subclass them to specialize them
Closed this issue · 0 comments
enzbus commented
Introduce classes such as StockMarketSimulator
, StockTransactionCost
, ..., that specialize the parameters to a given asset class. Other ones could be FuturesMarketSimulator
(still using YFinance
), HousingMarketSimulator
(using Case-Shiller via FRED
), ...
The general classes would have little to no default parameters. Subclasses would only override the __init__
, essentially to make it easier for users (because the full list of parameters could be difficult to understand).
Rationale
- original interface had no default parameters and costs specialized to stocks (
per_share_cost
,spread_on_borrowing_stocks_percent
, ..., were introduced in 2023) - it's better design to have a general interface that can be specialized, rather than a special one that can be generalized
- the specialized ones (i.e., the current ones) should be kept, in order to make the examples more terse; important logic in the examples should be avoided
- separate the logic of general models (e.g., transaction cost) from selection of accurate parameters - both are important, conflating them makes the code too heavy
- specialized classes would be very little code and easy to maintain; each one should get an example (same applies to policies and constraints!)