Skip to content

Commit

Permalink
Update backtest service functionality and corresponding unit tests A…
Browse files Browse the repository at this point in the history
…ddresses issue #28
  • Loading branch information
SelamT94 committed Jun 21, 2024
1 parent 18ad4fa commit e11411e
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
9 changes: 9 additions & 0 deletions app/services/backtest_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import sys
import os
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), '..', '..')))
from scripts.backtest_runner import run_backtest, RsiBollingerBandsStrategy

class BacktestService:
@staticmethod
def execute_backtest(symbol, start_date, end_date):
return run_backtest(RsiBollingerBandsStrategy, symbol, start_date, end_date)
10 changes: 10 additions & 0 deletions tests/unit/test_backtest_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import unittest
from app.services.backtest_service import BacktestService

class TestBacktestService(unittest.TestCase):
def test_execute_backtest(self):
result = BacktestService.execute_backtest('BTC/USDT', '2023-06-20', '2024-06-20')
self.assertIn('Ending Portfolio Value', result)

if __name__ == '__main__':
unittest.main()

0 comments on commit e11411e

Please sign in to comment.