Market Actions
StockMarketABM.MarketActions bundles routines for constructing markets, managing instruments, and mutating agent portfolios in response to trades.
StockMarketABM.MarketActions.add_holdings! — Methodadd_holdings!(portfolio, instrument, qty)Increase the position for instrument by qty units. Rejects negative inputs.
StockMarketABM.MarketActions.add_instrument! — Methodadd_instrument!(market, instrument, tick)Add a new instrument to the market, creating an empty order book and storing the tick size. Throws an error if the instrument already exists or the tick is not positive.
StockMarketABM.MarketActions.credit_cash! — Methodcredit_cash!(portfolio, amount)Increase portfolio.cash by amount. Rejects negative credits.
StockMarketABM.MarketActions.debit_cash! — Methoddebit_cash!(portfolio, amount)Decrease portfolio.cash by amount, raising an error when funds are insufficient or the amount is negative.
StockMarketABM.MarketActions.ensure_portfolio! — Methodensure_portfolio!(market, agent) -> PortfolioReturn the agent's portfolio, creating a new empty one when the agent is not yet tracked.
StockMarketABM.MarketActions.initialize_market — Methodinitialize_market(; instruments, tick_sizes, accounts) -> MarketCreate a fresh Market with empty order books and portfolios. Instruments and tick sizes can be pre-seeded via the keyword arguments.
StockMarketABM.MarketActions.remove_holdings! — Methodremove_holdings!(portfolio, instrument, qty)Reduce the position for instrument by qty units, dropping the entry when the result hits zero. Rejects negative inputs.