feat: add market data architecture and complete migration through build 039
This commit is contained in:
52
app/tests/unit/trading/strategies/test_scalp_quote.py
Normal file
52
app/tests/unit/trading/strategies/test_scalp_quote.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# app/tests/unit/trading/strategies/test_scalp_quote.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
|
||||
import src.trading.strategies.scalp as module
|
||||
from src.market_data.acquisition.models.quote import Quote
|
||||
from src.trading.strategies.scalp import ScalpStrategy
|
||||
|
||||
|
||||
def _quote(
|
||||
*,
|
||||
last: str = "100.5",
|
||||
bid: str = "100.0",
|
||||
ask: str = "101.0",
|
||||
) -> Quote:
|
||||
return Quote(
|
||||
symbol="BTC/USD_LEVERAGE",
|
||||
last_price=Decimal(last),
|
||||
bid_price=Decimal(bid),
|
||||
ask_price=Decimal(ask),
|
||||
exchange_timestamp=None,
|
||||
received_at=datetime.now(timezone.utc),
|
||||
source="dzengi",
|
||||
)
|
||||
|
||||
|
||||
def test_scalp_uses_midpoint_from_quote() -> None:
|
||||
result = ScalpStrategy()._analysis_price(_quote())
|
||||
|
||||
assert result == 100.5
|
||||
|
||||
|
||||
def test_scalp_quote_snapshot_is_json_compatible_projection() -> None:
|
||||
result = ScalpStrategy()._quote_snapshot(_quote())
|
||||
|
||||
assert result == {
|
||||
"symbol": "BTC/USD_LEVERAGE",
|
||||
"last_price": 100.5,
|
||||
"bid_price": 100.0,
|
||||
"ask_price": 101.0,
|
||||
"source": "dzengi",
|
||||
}
|
||||
|
||||
|
||||
def test_scalp_has_no_legacy_market_snapshot_call() -> None:
|
||||
source = inspect.getsource(module.ScalpStrategy)
|
||||
|
||||
assert "get_quote(" in source
|
||||
52
app/tests/unit/trading/strategies/test_trend_quote.py
Normal file
52
app/tests/unit/trading/strategies/test_trend_quote.py
Normal file
@@ -0,0 +1,52 @@
|
||||
# app/tests/unit/trading/strategies/test_trend_quote.py
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import inspect
|
||||
from datetime import datetime, timezone
|
||||
from decimal import Decimal
|
||||
|
||||
import src.trading.strategies.trend as module
|
||||
from src.market_data.acquisition.models.quote import Quote
|
||||
from src.trading.strategies.trend import TrendStrategy
|
||||
|
||||
|
||||
def _quote(
|
||||
*,
|
||||
last: str = "100.5",
|
||||
bid: str = "100.0",
|
||||
ask: str = "101.0",
|
||||
) -> Quote:
|
||||
return Quote(
|
||||
symbol="BTC/USD_LEVERAGE",
|
||||
last_price=Decimal(last),
|
||||
bid_price=Decimal(bid),
|
||||
ask_price=Decimal(ask),
|
||||
exchange_timestamp=None,
|
||||
received_at=datetime.now(timezone.utc),
|
||||
source="dzengi",
|
||||
)
|
||||
|
||||
|
||||
def test_trend_uses_midpoint_from_quote() -> None:
|
||||
result = TrendStrategy()._analysis_price(_quote())
|
||||
|
||||
assert result == 100.5
|
||||
|
||||
|
||||
def test_trend_quote_snapshot_is_json_compatible_projection() -> None:
|
||||
result = TrendStrategy()._quote_snapshot(_quote())
|
||||
|
||||
assert result == {
|
||||
"symbol": "BTC/USD_LEVERAGE",
|
||||
"last_price": 100.5,
|
||||
"bid_price": 100.0,
|
||||
"ask_price": 101.0,
|
||||
"source": "dzengi",
|
||||
}
|
||||
|
||||
|
||||
def test_trend_has_no_legacy_market_snapshot_call() -> None:
|
||||
source = inspect.getsource(module.TrendStrategy)
|
||||
|
||||
assert "get_quote(" in source
|
||||
Reference in New Issue
Block a user