Skip to content

Commit d082394

Browse files
committed
Pin resource directory
1 parent 4cf6064 commit d082394

6 files changed

+38
-12
lines changed

tests/scenarios/test_run_backtest_algorithm_param.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
import time
2+
import os
23
from datetime import datetime, timedelta, timezone
34
from unittest import TestCase
45

56
from investing_algorithm_framework import create_app, BacktestDateRange, \
6-
Algorithm
7+
Algorithm, RESOURCE_DIRECTORY
78
from tests.resources.strategies_for_testing.strategy_v1 import \
89
CrossOverStrategyV1
910

@@ -14,7 +15,10 @@ def test_run(self):
1415
"""
1516
"""
1617
start_time = time.time()
17-
app = create_app(name="GoldenCrossStrategy")
18+
# RESOURCE_DIRECTORY should always point to the parent directory/resources
19+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
20+
config = {RESOURCE_DIRECTORY: resource_directory}
21+
app = create_app(name="GoldenCrossStrategy", config=config)
1822
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1923
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
2024
start_date = end_date - timedelta(days=100)

tests/scenarios/test_run_backtest_multiple_strategies_param.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import os
12
from datetime import datetime, timedelta, timezone
23
from unittest import TestCase
34

4-
from investing_algorithm_framework import create_app, BacktestDateRange
5+
from investing_algorithm_framework import create_app, BacktestDateRange, \
6+
RESOURCE_DIRECTORY
57
from tests.resources.strategies_for_testing.strategy_v1 import \
68
CrossOverStrategyV1
79
from tests.resources.strategies_for_testing.strategy_v2 import \
@@ -13,7 +15,10 @@ class Test(TestCase):
1315
def test_run(self):
1416
"""
1517
"""
16-
app = create_app(name="GoldenCrossStrategy")
18+
# RESOURCE_DIRECTORY should always point to the parent directory/resources
19+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
20+
config = {RESOURCE_DIRECTORY: resource_directory}
21+
app = create_app(name="GoldenCrossStrategy", config=config)
1722
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1823
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
1924
start_date = end_date - timedelta(days=100)

tests/scenarios/test_run_backtest_single_strategy_param.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import os
12
from datetime import datetime, timedelta, timezone
23
from unittest import TestCase
34

4-
from investing_algorithm_framework import create_app, BacktestDateRange
5+
from investing_algorithm_framework import create_app, BacktestDateRange, \
6+
RESOURCE_DIRECTORY
57
from tests.resources.strategies_for_testing.strategy_v1 import \
68
CrossOverStrategyV1
79

@@ -11,7 +13,10 @@ class Test(TestCase):
1113
def test_run(self):
1214
"""
1315
"""
14-
app = create_app(name="GoldenCrossStrategy")
16+
# RESOURCE_DIRECTORY should always point to the parent directory/resources
17+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
18+
config = {RESOURCE_DIRECTORY: resource_directory}
19+
app = create_app(name="GoldenCrossStrategy", config=config)
1520
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1621
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
1722
start_date = end_date - timedelta(days=100)

tests/scenarios/test_run_backtest_strategies_attribute.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import os
12
from datetime import datetime, timedelta, timezone
23
from unittest import TestCase
34

4-
from investing_algorithm_framework import create_app, BacktestDateRange
5+
from investing_algorithm_framework import create_app, BacktestDateRange, \
6+
RESOURCE_DIRECTORY
57
from tests.resources.strategies_for_testing.strategy_v1 import \
68
CrossOverStrategyV1
79

@@ -11,7 +13,10 @@ class Test(TestCase):
1113
def test_run(self):
1214
"""
1315
"""
14-
app = create_app(name="GoldenCrossStrategy")
16+
# RESOURCE_DIRECTORY should always point to the parent directory/resources
17+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
18+
config = {RESOURCE_DIRECTORY: resource_directory}
19+
app = create_app(name="GoldenCrossStrategy", config=config)
1520
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1621
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
1722
start_date = end_date - timedelta(days=100)

tests/scenarios/test_run_backtests_algorithms_param.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import os
12
from datetime import datetime, timedelta, timezone
23
from unittest import TestCase
34

45
from investing_algorithm_framework import create_app, BacktestDateRange, \
5-
Algorithm
6+
Algorithm, RESOURCE_DIRECTORY
67
from tests.resources.strategies_for_testing.strategy_v1 import \
78
CrossOverStrategyV1
89
from tests.resources.strategies_for_testing.strategy_v3 import \
@@ -14,7 +15,9 @@ class Test(TestCase):
1415
def test_run(self):
1516
"""
1617
"""
17-
app = create_app(name="GoldenCrossStrategy")
18+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
19+
config = {RESOURCE_DIRECTORY: resource_directory}
20+
app = create_app(name="GoldenCrossStrategy", config=config)
1821
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1922
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
2023
start_date = end_date - timedelta(days=100)

tests/scenarios/test_run_backtests_strategies_param.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import os
12
from datetime import datetime, timedelta, timezone
23
from unittest import TestCase
34

4-
from investing_algorithm_framework import create_app, BacktestDateRange
5+
from investing_algorithm_framework import create_app, BacktestDateRange, \
6+
RESOURCE_DIRECTORY
57
from tests.resources.strategies_for_testing.strategy_v1 import \
68
CrossOverStrategyV1
79
from tests.resources.strategies_for_testing.strategy_v3 import \
@@ -13,7 +15,9 @@ class Test(TestCase):
1315
def test_run(self):
1416
"""
1517
"""
16-
app = create_app(name="GoldenCrossStrategy")
18+
resource_directory = os.path.join(os.path.dirname(__file__), '..', 'resources')
19+
config = {RESOURCE_DIRECTORY: resource_directory}
20+
app = create_app(name="GoldenCrossStrategy", config=config)
1721
app.add_market(market="BINANCE", trading_symbol="EUR", initial_balance=400)
1822
end_date = datetime(2023, 12, 2, tzinfo=timezone.utc)
1923
start_date = end_date - timedelta(days=100)

0 commit comments

Comments
 (0)