A toy Gymnasium trading environment can make execution timing and transaction fees explicit.
Build the example
Define the observation at time t, an action for the target position, and a price at which the action is executed. Debit fees on turnover and calculate reward from the change in equity under the chosen convention. Gymnasium step returns observation, reward, terminated, truncated and info. Document how the episode ends and what reset returns.
Use prices of 100, 100 and 100 with one unit of position. A buy-and-sell round trip should lose the total fees under the defined convention. Then change one price and verify the mark-to-market change separately from turnover. Test a hold action that produces zero fees so cost accounting cannot accidentally charge every time step.
Watch the failure boundary
Define whether transaction costs apply to a reversal as two units of turnover or under a different execution model. Expose equity and fees in the info object so a test can account for every step. Keep termination for environment rules distinct from a time-limit truncation in the training loop.
Verify the behavior
Use fictional prices and compare hold, buy-once and frequent-trading baselines. Check that a flat price and positive fees produce a loss when switching positions. Keep observations limited to data that would have been available before the trade, and treat the results as a software simulation.
Sources
Technical references checked .



