feat(execution): per-account Alpaca GTC brackets, guardrails, shorts, options, reconcile
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016DvdRZkyCy9NJpHYDdPqmS
This commit is contained in:
1 parent
aa1ae0c95e
commit
709870b1d5
8 files changed
+813
No files matched your search
@@ -0,0 +1,28 @@
|
||||
"""Pure tests for bracket level math (long + short). No network."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import pytest
|
||||
|
||||
from execution.broker import bracket_levels
|
||||
|
||||
|
||||
def test_long_levels_ordered():
|
||||
side, entry, stop, take = bracket_levels(100.0, 0.07, 0.15, "long")
|
||||
assert side == "buy"
|
||||
assert stop < entry < take
|
||||
assert (stop, take) == (93.0, 115.0)
|
||||
|
||||
|
||||
def test_short_levels_inverted_and_ordered():
|
||||
side, entry, stop, take = bracket_levels(100.0, 0.07, 0.15, "short")
|
||||
assert side == "sell"
|
||||
# short: profit below (take), loss above (stop)
|
||||
assert take < entry < stop
|
||||
assert (take, stop) == (85.0, 107.0)
|
||||
|
||||
|
||||
def test_tiny_take_does_not_invert_long():
|
||||
# adaptive buffer keeps entry inside the band even when take_pct is small
|
||||
side, entry, stop, take = bracket_levels(100.0, 0.10, 0.03, "long")
|
||||
assert stop < entry < take
|
||||
Reference in new issue
Block a user