-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
10 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
mlflow server --host 127.0.0.1 --port 5050 | ||
python3 run.py | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,10 @@ | ||
import json | ||
import pytest | ||
from flask import Flask | ||
from flask_testing import TestCase | ||
from app import create_app, db | ||
from app.models.backtest import Indicator, Backtest, Parameter, Result | ||
import unittest | ||
from app.services.backtest_service import BacktestService | ||
|
||
class BacktestTestCase(TestCase): | ||
def create_app(self): | ||
app = create_app('testing') # Assume you have a testing config | ||
return app | ||
|
||
def setUp(self): | ||
db.create_all() | ||
# Add sample indicators | ||
indicator1 = Indicator(name='Indicator 1', description='Description 1') | ||
indicator2 = Indicator(name='Indicator 2', description='Description 2') | ||
db.session.add(indicator1) | ||
db.session.add(indicator2) | ||
db.session.commit() | ||
|
||
def tearDown(self): | ||
db.session.remove() | ||
db.drop_all() | ||
|
||
def test_run_backtest(self): | ||
with open('backtest_request.json') as f: | ||
data = json.load(f) | ||
|
||
response = self.client.post('/backtest', json=data) | ||
self.assertEqual(response.status_code, 201) | ||
self.assertIn('backtest_id', response.json) | ||
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__': | ||
pytest.main() | ||
unittest.main() |