feat: quadratic market impact — larger trades cost more

1-lot fills at bid/ask. 4-lot moves the market.
impact_scale = 1 + (|delta|/max_position)^2, ranges [1.0, 2.0].
Teaches the model that max-size positions are 2x more expensive to enter.
Makes the 9-exposure granularity meaningful — 25% positions are cheaper
to enter/exit than 100% positions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jgrusewski
2026-03-23 09:34:11 +01:00
parent a247c77543
commit ac61fbb8f8

View File

@@ -473,7 +473,13 @@ extern "C" __global__ void experience_env_step(
float tx_cost = 0.0f;
if (delta != 0.0f) {
tx_cost = fabsf(delta) * raw_close * tx_cost_multiplier * spread_scale;
/* Market impact: larger trades cost more (quadratic in size).
* A 1-lot order fills at bid/ask. A 4-lot order moves the market.
* impact_scale = 1 + |delta/max_position|^2 — ranges from 1.0 to 2.0.
* This teaches the model that scaling to max position is expensive. */
float size_ratio = fabsf(delta) / (max_position > 0.0f ? max_position : 1.0f);
float impact_scale = 1.0f + size_ratio * size_ratio;
tx_cost = fabsf(delta) * raw_close * tx_cost_multiplier * spread_scale * impact_scale;
cash -= delta * raw_close;
cash -= tx_cost;
position = target_position;