Skip to content

Commit 8440562

Browse files
committed
Update imports
1 parent 3b4e009 commit 8440562

File tree

12 files changed

+60
-91
lines changed

12 files changed

+60
-91
lines changed

investing_algorithm_framework/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""
22
Invokes investing_algorithm_framework-admin when the investing_algorithm_framework framework module is run as a script.
3-
Example: python -m investing_algorithm_framework createbot SampleBot
3+
Example: python -m investing_algorithm_framework createalgorithm SampleAlgorithm
44
"""
55

66
from investing_algorithm_framework.core.management import execute_from_command_line

investing_algorithm_framework/core/configuration/config_constants.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
FRAMEWORK_CORE_MODULE_NAME = 'investing_algorithm_framework.core'
44

55
# Setting related constants
6-
SETTINGS_BOT_PROJECT_NAME = 'BOT_PROJECT_NAME'
7-
SETTINGS_MODULE_PATH_ENV_NAME = 'INVESTING_BOT_FRAMEWORK_SETTINGS_MODULE'
6+
SETTINGS_ALGORITHM_PROJECT_NAME = 'ALGORITHM_PROJECT_NAME'
7+
SETTINGS_MODULE_PATH_ENV_NAME = 'INVESTING_ALGORITHM_FRAMEWORK_SETTINGS_MODULE'
88
SETTINGS_DATA_PROVIDER_REGISTERED_APPS = 'INSTALLED_DATA_PROVIDER_APPS'
99
SETTINGS_STRATEGY_REGISTERED_APPS = 'INSTALLED_STRATEGY_APPS'
1010
SETTINGS_MAX_WORKERS = 'DEFAULT_MAX_WORKERS'
11-
SETTINGS_BOT_CONTEXT_CONFIGURATION = 'BOT_CONTEXT_CONFIGURATION'
11+
SETTINGS_CONTEXT_CONFIGURATION = 'CONTEXT_CONFIGURATION'
1212
SETTINGS_LOGGING_CONFIG = 'LOGGING'
1313

1414
# Operational constants

investing_algorithm_framework/core/configuration/template.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ class Template:
1010

1111
def __init__(self, bot_project_directory: str, bot_name: str) -> None:
1212
"""
13-
investing_algorithm_framework project directory is the root directory of the given investing_algorithm_framework. The bot_name will be the same as the root project
14-
directory. For simplicity it is explicitly passed as a parameter
13+
investing_algorithm_framework project directory is the root directory of the given
14+
investing_algorithm_framework. The algorithm_name will be the same as the root project directory. For
15+
simplicity it is explicitly passed as a parameter
1516
"""
1617

1718
if bot_project_directory is None:

investing_algorithm_framework/core/data_providers/mixins/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

investing_algorithm_framework/core/data_providers/mixins/rest_api_mixin.py

Lines changed: 0 additions & 68 deletions
This file was deleted.

investing_algorithm_framework/core/resolvers/database_resolver.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ def initialize(self):
154154
def make_declarative_base(model_class):
155155
"""
156156
Creates the declarative base that all models will inherit from.
157-
158-
:param model_class: base model class to pass to :func:`~sqlalchemy.ext.declarative.declarative_base`.
159157
"""
160158

161159
model = declarative_base(cls=model_class)

investing_algorithm_framework/core/states/templates/data_providing_state.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from wrapt import synchronized
55

66
from investing_algorithm_framework.core.events import Observer
7-
from investing_algorithm_framework.core.context.bot_context import BotContext
7+
from investing_algorithm_framework.core.context.context import Context
88
from investing_algorithm_framework.core.exceptions import OperationalException
99
from investing_algorithm_framework.core.states import BotState
1010
from investing_algorithm_framework.core.executors import ExecutionScheduler
@@ -83,7 +83,7 @@ class DataProvidingState(BotState, Observer):
8383

8484
data_provider_scheduler: DataProviderScheduler = None
8585

86-
def __init__(self, context: BotContext) -> None:
86+
def __init__(self, context: Context) -> None:
8787
super(DataProvidingState, self).__init__(context)
8888
self._updated = False
8989
self.data_provider_executor = None

tests/core/executors/test_executor.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test(self) -> None:
2323
assert executor.processing
2424
assert active_count() == 3
2525

26-
sleep(2)
26+
sleep(3)
2727

2828
# # After finishing only 1 thread must be active
2929
assert active_count(), 1
@@ -58,13 +58,7 @@ def test(self) -> None:
5858
assert executor.processing
5959
assert active_count() == 3
6060

61-
sleep(2)
62-
63-
# After finishing only two threads must be active (main + last worker, because max workers is 2)
64-
assert active_count() == 2
65-
assert executor.processing
66-
67-
sleep(1)
61+
sleep(4)
6862

6963
# After finishing only 1 thread must be active
7064
assert active_count(), 1

tests/core/management/__init__.py

Whitespace-only changes.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import os
2+
from tempfile import TemporaryDirectory
3+
from tests.resources.utils import random_string
4+
from investing_algorithm_framework.core.management.commands.create_algorithm import CreateAlgorithmCommand
5+
6+
7+
class TestCreateAlgorithm:
8+
project_name = None
9+
project_dir = None
10+
11+
def setup_method(self):
12+
self.project_name = random_string(10)
13+
14+
def test(self):
15+
16+
with TemporaryDirectory() as tempdir:
17+
18+
command = CreateAlgorithmCommand()
19+
command.handle(name=self.project_name, directory=tempdir)
20+
21+
# Check if manage py is present
22+
assert os.path.isfile(os.path.join(tempdir, 'manage.py'))
23+
24+
# Check if all directories are present
25+
assert os.path.isdir(os.path.join(tempdir, self.project_name, 'data_providers'))
26+
assert os.path.isdir(os.path.join(tempdir, self.project_name, 'order_executors'))
27+
assert os.path.isdir(os.path.join(tempdir, self.project_name, 'strategies'))
28+
assert os.path.isdir(os.path.join(tempdir, self.project_name, 'configuration'))
29+
30+
# Check if all configuration files are present
31+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'configuration', '__init__.py'))
32+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'configuration', 'context.py'))
33+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'configuration', 'settings.py'))
34+
35+
# Check if all data provider files are present
36+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'data_providers', '__init__.py'))
37+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'data_providers', 'data_providers.py'))
38+
39+
# Check if all strategies files are present
40+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'strategies', '__init__.py'))
41+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'strategies', 'strategies.py'))
42+
43+
# Check if all order_executors files are present
44+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'order_executors', '__init__.py'))
45+
assert os.path.isfile(os.path.join(tempdir, self.project_name, 'order_executors', 'order_executors.py'))

0 commit comments

Comments
 (0)