Initial commit: Crypto trader application

This commit is contained in:
2025-12-25 20:20:40 -05:00
commit 07a04c1bb8
47895 changed files with 2042266 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
"""Tests for Moving Average strategy."""
import pytest
import pandas as pd
from src.strategies.technical.moving_avg_strategy import MovingAverageStrategy
class TestMovingAverageStrategy:
"""Tests for MovingAverageStrategy."""
@pytest.fixture
def strategy(self):
"""Create Moving Average strategy instance."""
return MovingAverageStrategy(
strategy_id=1,
name="test_ma",
symbol="BTC/USD",
timeframe="1h",
parameters={
"short_period": 10,
"long_period": 30,
"ma_type": "SMA"
}
)
@pytest.mark.asyncio
async def test_ma_strategy_initialization(self, strategy):
"""Test Moving Average strategy initialization."""
assert strategy.short_period == 10
assert strategy.long_period == 30
assert strategy.ma_type == "SMA"
@pytest.mark.asyncio
async def test_generate_signal(self, strategy):
"""Test signal generation."""
# Create data with trend
data = pd.DataFrame({
'close': [100 + i * 0.5 for i in range(50)]
})
strategy.current_data = data
signal = await strategy.generate_signal()
assert "signal" in signal
assert signal["signal"] in ["buy", "sell", "hold"]