summaryrefslogtreecommitdiff
path: root/shared/tests/test_models.py
diff options
context:
space:
mode:
Diffstat (limited to 'shared/tests/test_models.py')
-rw-r--r--shared/tests/test_models.py38
1 files changed, 20 insertions, 18 deletions
diff --git a/shared/tests/test_models.py b/shared/tests/test_models.py
index b23d71d..04098ce 100644
--- a/shared/tests/test_models.py
+++ b/shared/tests/test_models.py
@@ -8,15 +8,9 @@ from unittest.mock import patch
def test_settings_defaults():
"""Test that Settings has correct defaults."""
- with patch.dict(
- os.environ,
- {
- "BINANCE_API_KEY": "test_key",
- "BINANCE_API_SECRET": "test_secret",
- },
- ):
- from shared.config import Settings
+ from shared.config import Settings
+ with patch.dict(os.environ, {}, clear=False):
settings = Settings()
assert settings.redis_url == "redis://localhost:6379"
assert settings.database_url == "postgresql://trading:trading@localhost:5432/trading"
@@ -33,7 +27,7 @@ def test_candle_creation():
now = datetime.now(timezone.utc)
candle = Candle(
- symbol="BTCUSDT",
+ symbol="AAPL",
timeframe="1m",
open_time=now,
open=Decimal("50000.00"),
@@ -42,7 +36,7 @@ def test_candle_creation():
close=Decimal("50500.00"),
volume=Decimal("100.5"),
)
- assert candle.symbol == "BTCUSDT"
+ assert candle.symbol == "AAPL"
assert candle.timeframe == "1m"
assert candle.open == Decimal("50000.00")
assert candle.high == Decimal("51000.00")
@@ -57,14 +51,14 @@ def test_signal_creation():
signal = Signal(
strategy="rsi_strategy",
- symbol="BTCUSDT",
+ symbol="AAPL",
side=OrderSide.BUY,
price=Decimal("50000.00"),
quantity=Decimal("0.01"),
reason="RSI oversold",
)
assert signal.strategy == "rsi_strategy"
- assert signal.symbol == "BTCUSDT"
+ assert signal.symbol == "AAPL"
assert signal.side == OrderSide.BUY
assert signal.price == Decimal("50000.00")
assert signal.quantity == Decimal("0.01")
@@ -81,7 +75,7 @@ def test_order_creation():
signal_id = str(uuid.uuid4())
order = Order(
signal_id=signal_id,
- symbol="BTCUSDT",
+ symbol="AAPL",
side=OrderSide.BUY,
type=OrderType.MARKET,
price=Decimal("50000.00"),
@@ -99,8 +93,12 @@ def test_signal_conviction_default():
from shared.models import Signal, OrderSide
signal = Signal(
- strategy="rsi", symbol="BTCUSDT", side=OrderSide.BUY,
- price=Decimal("50000"), quantity=Decimal("0.01"), reason="test",
+ strategy="rsi",
+ symbol="AAPL",
+ side=OrderSide.BUY,
+ price=Decimal("50000"),
+ quantity=Decimal("0.01"),
+ reason="test",
)
assert signal.conviction == 1.0
assert signal.stop_loss is None
@@ -112,8 +110,12 @@ def test_signal_with_stops():
from shared.models import Signal, OrderSide
signal = Signal(
- strategy="rsi", symbol="BTCUSDT", side=OrderSide.BUY,
- price=Decimal("50000"), quantity=Decimal("0.01"), reason="test",
+ strategy="rsi",
+ symbol="AAPL",
+ side=OrderSide.BUY,
+ price=Decimal("50000"),
+ quantity=Decimal("0.01"),
+ reason="test",
conviction=0.8,
stop_loss=Decimal("48000"),
take_profit=Decimal("55000"),
@@ -128,7 +130,7 @@ def test_position_unrealized_pnl():
from shared.models import Position
position = Position(
- symbol="BTCUSDT",
+ symbol="AAPL",
quantity=Decimal("0.1"),
avg_entry_price=Decimal("50000"),
current_price=Decimal("51000"),