Skip to content

Commit 3b4e009

Browse files
committed
Update templates
1 parent 166b91e commit 3b4e009

File tree

13 files changed

+42
-42
lines changed

13 files changed

+42
-42
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from investing_algorithm_framework.core.configuration.setup.default_template_creators import DefaultBotProjectCreator
1+
from investing_algorithm_framework.core.configuration.setup.default_template_creators import DefaultProjectCreator

investing_algorithm_framework/core/configuration/setup/default_template_creators.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,16 @@
66
from investing_algorithm_framework.core.configuration.setup.template_creator import TemplateCreator
77

88

9-
class DefaultBotProjectCreator(TemplateCreator):
10-
TEMPLATE_ROOT_DIR = 'templates/bot_project_directory'
11-
BOT_PROJECT_NAME_PLACEHOLDER = '{{ bot_project_name }}'
12-
BOT_PROJECT_TEMPLATE_DIR_NAME = 'bot_project_template'
9+
class DefaultProjectCreator(TemplateCreator):
10+
TEMPLATE_ROOT_DIR = 'templates/algorithm_project_directory'
11+
PROJECT_NAME_PLACEHOLDER = '{{ project_name }}'
12+
PROJECT_TEMPLATE_DIR_NAME = 'algorithm_project_template'
1313

1414
def configure(self) -> None:
1515
bot_dir = os.path.join(self._bot_project_directory, self._bot_name)
1616

1717
if os.path.exists(bot_dir):
18-
raise ImproperlyConfigured("Bot destination directory {} already exists".format(self._bot_name))
18+
raise ImproperlyConfigured("Project destination directory {} already exists".format(self._bot_name))
1919

2020
def create(self) -> None:
2121

@@ -29,7 +29,7 @@ def create(self) -> None:
2929
path_rest = root[len(template_dir) + 1:]
3030

3131
# Replace template investing_algorithm_framework directory with given investing_algorithm_framework name
32-
path_rest = path_rest.replace(self.BOT_PROJECT_TEMPLATE_DIR_NAME, self._bot_name)
32+
path_rest = path_rest.replace(self.PROJECT_TEMPLATE_DIR_NAME, self._bot_name)
3333

3434
# Create the directories if they don't exist
3535
destination_dir = os.path.join(self._bot_project_directory, path_rest)
@@ -76,15 +76,15 @@ def create(self) -> None:
7676
)
7777

7878
# Format placeholders in file if needed
79-
if filename in ['manage.py-template', 'settings.py-template']:
79+
if filename in ['manage.py-template', 'settings.py-template', 'context.py-template']:
8080

8181
# Read the file
8282
with open(destination_path, 'r') as file:
8383

8484
file_data = file.read()
8585

8686
# Replace the placeholder with the investing_algorithm_framework name
87-
file_data = file_data.replace(self.BOT_PROJECT_NAME_PLACEHOLDER, self._bot_name)
87+
file_data = file_data.replace(self.PROJECT_NAME_PLACEHOLDER, self._bot_name)
8888

8989
# Write the file out again
9090
with open(destination_path, 'w') as file:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from investing_algorithm_framework.core.context import Context
2+
from investing_algorithm_framework.core.states.templates.setup_state import SetupState
3+
from investing_algorithm_framework.core.states.templates.data_providing_state import DataProvidingState
4+
from investing_algorithm_framework.core.states.templates.strategy_state import StrategyState
5+
from investing_algorithm_framework.core.states.templates.ordering_state import OrderingState
6+
7+
# Import custom components
8+
from {{ project_name }}.data_providers.data_providers import MyDataProvider
9+
from {{ project_name }}.strategies.strategies import MyStrategy
10+
from {{ project_name }}.order_executors.order_executors import MyOrderExecutor
11+
12+
# Register Initial state
13+
context = Context()
14+
context.register_initial_state(SetupState)
15+
16+
# Register all data providers
17+
DataProvidingState.register_data_providers([MyDataProvider()])
18+
19+
# Register all strategies
20+
StrategyState.register_strategies([MyStrategy()])
21+
22+
# Register all order executors
23+
OrderingState.register_order_executors([MyOrderExecutor()])
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import os
22
from pathlib import Path
33

4-
BOT_PROJECT_NAME = 'bot'
4+
PROJECT_NAME = '{{ project_name }}'
55

6-
BOT_CONTEXT_CONFIGURATION = 'bot.configuration.context'
6+
CONTEXT_CONFIGURATION = '{{ project_name }}.configuration.context'
77

88
# Change this when not in development, feature or hot-fix branch
99
DEBUG = int(os.environ.get('DEBUG', True))
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
from investing_bot_framework.core.data_providers import DataProvider
2-
from investing_bot_framework.core.utils import TimeUnit
1+
from investing_algorithm_framework.core.data_providers import DataProvider
2+
from investing_algorithm_framework.core.utils import TimeUnit
33

44
"""
55
Define here all your data providers
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from investing_bot_framework.core.order_executors import OrderExecutor
1+
from investing_algorithm_framework.core.order_executors import OrderExecutor
22

33

44
class MyOrderExecutor(OrderExecutor):

0 commit comments

Comments
 (0)