From a83e0f9ca10c6d5e6248637c96ff97400031540e Mon Sep 17 00:00:00 2001 From: idevtier <33418872+usrsem@users.noreply.github.com> Date: Sat, 13 Aug 2022 01:01:49 +0300 Subject: [PATCH] Delete src/gui directory --- src/gui/__init__.py | 0 src/gui/__main__.py | 6 - src/gui/autobacktesters/__init__.py | 0 .../config_backtester_screen.kv | 22 --- .../config_backtester_screen.py | 68 ------- src/gui/backtesting/__init__.py | 0 src/gui/backtesting/single_backtester.py | 84 --------- .../backtesting/single_backtester_screen.kv | 34 ---- .../backtesting/single_backtester_screen.py | 63 ------- src/gui/backtesting/widgets.kv | 37 ---- src/gui/backtesting/widgets.py | 70 -------- src/gui/bot_menu/__init__.py | 0 src/gui/bot_menu/base_bot_menu_screen.kv | 13 -- src/gui/bot_menu/base_bot_menu_screen.py | 65 ------- src/gui/bot_menu/multiple_bot_menu_screen.kv | 1 - src/gui/bot_menu/multiple_bot_menu_screen.py | 45 ----- src/gui/bot_menu/single_bot_menu_screen.kv | 1 - src/gui/bot_menu/single_bot_menu_screen.py | 50 ------ src/gui/bot_selector/__init__.py | 0 src/gui/bot_selector/bot_selector_screen.kv | 16 -- src/gui/bot_selector/bot_selector_screen.py | 80 --------- src/gui/bot_type_selector/__init__.py | 0 .../bot_type_selector_screen.kv | 25 --- .../bot_type_selector_screen.py | 40 ----- src/gui/colors.py | 5 - src/gui/default_widgets.py | 133 -------------- src/gui/haas_toolbox_app.py | 36 ---- src/gui/haastoolbox.kv | 77 -------- src/gui/interface_option_selector/__init__.py | 0 .../interface_option_selector_screen.kv | 18 -- .../interface_option_selector_screen.py | 58 ------ src/gui/interface_selector/__init__.py | 0 .../interface_selector_screen.kv | 15 -- .../interface_selector_screen.py | 67 ------- src/gui/menu/__init__.py | 0 src/gui/menu/menu_screen.kv | 30 ---- src/gui/menu/menu_screen.py | 10 -- src/gui/settings/__init__.py | 0 src/gui/settings/settings_screen.kv | 169 ------------------ src/gui/settings/settings_screen.py | 36 ---- 40 files changed, 1374 deletions(-) delete mode 100644 src/gui/__init__.py delete mode 100644 src/gui/__main__.py delete mode 100644 src/gui/autobacktesters/__init__.py delete mode 100644 src/gui/autobacktesters/config_backtester/config_backtester_screen.kv delete mode 100644 src/gui/autobacktesters/config_backtester/config_backtester_screen.py delete mode 100644 src/gui/backtesting/__init__.py delete mode 100644 src/gui/backtesting/single_backtester.py delete mode 100644 src/gui/backtesting/single_backtester_screen.kv delete mode 100644 src/gui/backtesting/single_backtester_screen.py delete mode 100644 src/gui/backtesting/widgets.kv delete mode 100644 src/gui/backtesting/widgets.py delete mode 100644 src/gui/bot_menu/__init__.py delete mode 100644 src/gui/bot_menu/base_bot_menu_screen.kv delete mode 100644 src/gui/bot_menu/base_bot_menu_screen.py delete mode 100644 src/gui/bot_menu/multiple_bot_menu_screen.kv delete mode 100644 src/gui/bot_menu/multiple_bot_menu_screen.py delete mode 100644 src/gui/bot_menu/single_bot_menu_screen.kv delete mode 100644 src/gui/bot_menu/single_bot_menu_screen.py delete mode 100644 src/gui/bot_selector/__init__.py delete mode 100644 src/gui/bot_selector/bot_selector_screen.kv delete mode 100644 src/gui/bot_selector/bot_selector_screen.py delete mode 100644 src/gui/bot_type_selector/__init__.py delete mode 100644 src/gui/bot_type_selector/bot_type_selector_screen.kv delete mode 100644 src/gui/bot_type_selector/bot_type_selector_screen.py delete mode 100644 src/gui/colors.py delete mode 100644 src/gui/default_widgets.py delete mode 100644 src/gui/haas_toolbox_app.py delete mode 100644 src/gui/haastoolbox.kv delete mode 100644 src/gui/interface_option_selector/__init__.py delete mode 100644 src/gui/interface_option_selector/interface_option_selector_screen.kv delete mode 100644 src/gui/interface_option_selector/interface_option_selector_screen.py delete mode 100644 src/gui/interface_selector/__init__.py delete mode 100644 src/gui/interface_selector/interface_selector_screen.kv delete mode 100644 src/gui/interface_selector/interface_selector_screen.py delete mode 100644 src/gui/menu/__init__.py delete mode 100644 src/gui/menu/menu_screen.kv delete mode 100644 src/gui/menu/menu_screen.py delete mode 100644 src/gui/settings/__init__.py delete mode 100644 src/gui/settings/settings_screen.kv delete mode 100644 src/gui/settings/settings_screen.py diff --git a/src/gui/__init__.py b/src/gui/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/__main__.py b/src/gui/__main__.py deleted file mode 100644 index 6c01156..0000000 --- a/src/gui/__main__.py +++ /dev/null @@ -1,6 +0,0 @@ -from gui.haas_toolbox_app import HaasToolBoxApp - - -def main(): - HaasToolBoxApp().run() - diff --git a/src/gui/autobacktesters/__init__.py b/src/gui/autobacktesters/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/autobacktesters/config_backtester/config_backtester_screen.kv b/src/gui/autobacktesters/config_backtester/config_backtester_screen.kv deleted file mode 100644 index 10c2c44..0000000 --- a/src/gui/autobacktesters/config_backtester/config_backtester_screen.kv +++ /dev/null @@ -1,22 +0,0 @@ -: - MainWindow: - TitleLabel: - text: "Config backtester" - - BoxLayout: - orientation: "vertical" - spacing: 50 - - LogsLayout: - id: logs_layout - - BoxLayout: - size_hint_y: 0.1 - Button: - text: "Change config" - Button: - text: "Start" - on_release: root.start_backtesting() - Button: - text: "To menu" - diff --git a/src/gui/autobacktesters/config_backtester/config_backtester_screen.py b/src/gui/autobacktesters/config_backtester/config_backtester_screen.py deleted file mode 100644 index 4df4463..0000000 --- a/src/gui/autobacktesters/config_backtester/config_backtester_screen.py +++ /dev/null @@ -1,68 +0,0 @@ -from concurrent.futures.thread import ThreadPoolExecutor -from typing import Generator -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder -from api.backtesting.BotConfigBacktester import BotConfigBacktester -from api.bots.BotManager import BotManager -from api.factories.bot_managers_factory import get_bot_manager_by_bot -from loguru import logger as log - -from api.models import Bot - - -Builder.load_file("./src/gui/autobacktesters/config_backtester/config_backtester_screen.kv") - - -class ConfigBacktesterScreen(Screen): - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.bots: set[Bot] = set() - - def setup(self, bots: set[Bot]) -> None: - self.bots = bots - self._update_screen() - - def start_backtesting(self) -> None: - bots_count: int = len(self.bots) - log.debug(f"Starting config backtesting for {bots_count} bots") - - if bots_count == 1: - self.backtest_single_bot() - else: - self.backtest_multiple_bots() - - - def _update_screen(self) -> None: - self.ids.logs_layout.clear() - - def backtest_single_bot(self) -> None: - bot_manager: BotManager = self._get_bot_manager() - bot_manager.set_bot(self.bots.pop()) - - exec = ThreadPoolExecutor(max_workers=1) - backtester = BotConfigBacktester(bot_manager, 50, 5) - backtester.set_logger(self.ids.logs_layout) - exec.submit(backtester.start) - - def backtest_multiple_bots(self) -> None: - exec = ThreadPoolExecutor(max_workers=1) - for manager in self._bot_managers_generator(): - backtester = BotConfigBacktester(manager, 50, 5) - backtester.set_logger(self.ids.logs_layout) - exec.submit(backtester.start) - - - def _bot_managers_generator(self) -> Generator[BotManager, None, None]: - log.debug(f"{self.bots=}") - bot_manager: BotManager = self._get_bot_manager() - log.debug(f"{self.bots=}") - - for bot in self.bots: - bot_manager.set_bot(bot) - yield bot_manager - - def _get_bot_manager(self) -> BotManager: - bot: Bot = self.bots.pop() - self.bots.add(bot) - return get_bot_manager_by_bot(bot) - diff --git a/src/gui/backtesting/__init__.py b/src/gui/backtesting/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/backtesting/single_backtester.py b/src/gui/backtesting/single_backtester.py deleted file mode 100644 index 4afa6d3..0000000 --- a/src/gui/backtesting/single_backtester.py +++ /dev/null @@ -1,84 +0,0 @@ -from api.backtesting.BotBacktester import BotBacketster -from gui.backtesting.widgets import BacktestingInfoLayout -from gui.default_widgets import LogsLayout, TextLabel -from concurrent.futures import ThreadPoolExecutor -from time import monotonic -from typing import Callable, Optional -from loguru import logger as log - - -class SingleBacktester: - def __init__( - self, - backtester: BotBacketster, - logger: LogsLayout, - backtesting_info: BacktestingInfoLayout - ) -> None: - self.backtester: BotBacketster = backtester - self.logger: LogsLayout = logger - self.backtesting_info: BacktestingInfoLayout = backtesting_info - - self.backtesting_actions: dict[tuple[str, str], list[Callable]] - self.hotkeys: set[str] - self.executor = ThreadPoolExecutor(max_workers=1) - - self._init_backtesting_actions_dict() - self._init_backtesting_hotkeys() - - def process_button_release(self, instanse) -> None: - for key, actions in self.backtesting_actions.items(): - if key[0] == instanse.text: - self.logger.info(key[0]) - for action in actions: - self.executor.submit(self._task, action) - - def process_hotkey_release(self, hotkey: str) -> None: - if hotkey in self.hotkeys: - for key, actions in self.backtesting_actions.items(): - if key[1] == hotkey: - for action in actions: - log_row: TextLabel = self.logger.info(key[0]) - self.executor.submit(self._task, action, log_row) - - def stop_backtesting(self) -> None: - self.backtester.stop_backtesting() - - - def _init_backtesting_actions_dict(self) -> None: - self.backtesting_actions = { - ("Backtest up", "k"): [self.backtester.backtest_up], - ("Backtest down", "j"): [self.backtester.backtest_down], - ("Length x2", "l"): [self.backtester.backtesting_length_x2], - ("Length /2", "h"): [self.backtester.backtesting_length_devide2], - ("Backtest up x10", "Shift + k"): self._run_in_range( - self.backtester.backtest_up), - ("Backtest down x10", "Shift + j"): self._run_in_range( - self.backtester.backtest_down), - } - - def _init_backtesting_hotkeys(self) -> None: - self.hotkeys = {key[1] for key in list(self.backtesting_actions)} - - # TODO: Move default value to config - def _run_in_range(self, action: Callable, range_: int = 10) -> list[Callable]: - return [action for _ in range(range_)] - - def _task(self, action: Callable, log_row: Optional[TextLabel] = None): - log.debug("Starting task") - start: float = monotonic() - res = action() - end = monotonic() - start - - log.debug(f"{res=}") - - match res: - case None: - return - case value, roi: - self.logger.info( - f"ROI: [{roi}]; Value: [{value}]; Time: [{end:.2f}s]", - log_row) - self.backtesting_info.update(value, roi) - case ticks: - self.logger.info(f"Ticks: {ticks}", log_row) - diff --git a/src/gui/backtesting/single_backtester_screen.kv b/src/gui/backtesting/single_backtester_screen.kv deleted file mode 100644 index f353cd5..0000000 --- a/src/gui/backtesting/single_backtester_screen.kv +++ /dev/null @@ -1,34 +0,0 @@ -: - MainWindow: - TitleLabel: - text: "Backtesting" - - BoxLayout: - spacing: 20 - - GridLayout: - id: info_grid_layout - cols: 1 - spacing: 0, 20 - - BacktestingInfoLayout: - id: backtesting_info - - LogsLayout: - id: logs_layout - - HotKeysLayout: - id: hotkeys_layout - - - BoxLayout: - size_hint_y: 0.05 - padding: 0, 10 - Button: - id: back_button - text: 'Back option selection' - on_release: root.back_to_option_selector() - Button: - text: 'Back to menu' - on_release: root.manager.current = 'menu' - diff --git a/src/gui/backtesting/single_backtester_screen.py b/src/gui/backtesting/single_backtester_screen.py deleted file mode 100644 index 3a148b0..0000000 --- a/src/gui/backtesting/single_backtester_screen.py +++ /dev/null @@ -1,63 +0,0 @@ -from api.backtesting.BotBacktester import BotBacketster -from api.wrappers.InterfaceWrapper import InterfaceWrapper -from kivy.core.window import Window -from kivy.lang import Builder -from loguru import logger as log -from kivy.uix.screenmanager import Screen -from gui.backtesting.single_backtester import SingleBacktester - - -Builder.load_file("./src/gui/backtesting/single_backtester_screen.kv") - - -class SingleBacktesterScreen(Screen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.gui_backtester: SingleBacktester - - (Window - .request_keyboard(self._keyboard_released, self) # type: ignore - .bind(on_key_down=self._process_shortcut)) - - def setup(self, backtester: BotBacketster) -> None: - self.gui_backtester = SingleBacktester( - backtester, self.ids.logs_layout, self.ids.backtesting_info) - - self._setup_backtesting_actions() - - self.ids.logs_layout.clear() - self.ids.backtesting_info.update( - backtester.option.value, - backtester.manager.bot_roi(), - InterfaceWrapper(backtester.interface).name) - - def back_to_option_selector(self) -> None: - log.debug("Going to interface option selection") - self.gui_backtester.stop_backtesting() - self.manager.get_screen("interface_option_selector").update_data() - self.manager.current = "interface_option_selector" - - - def _setup_backtesting_actions(self) -> None: - if not self.ids.hotkeys_layout.has_hotkeys(): - actions = { - k: self.gui_backtester.process_button_release - for k, _ in self.gui_backtester.backtesting_actions.items() - } - self.ids.hotkeys_layout.add_actions(actions) - - - def _keyboard_released(self): - self.focus = False - - def _process_shortcut(self, window, keycode, text, modifiers): - # TODO: Find better option for setting hotkeys - if self.manager.current != "single_backtester": - return - - if "shift" in modifiers: - text = f"Shift + {text}" - - self.gui_backtester.process_hotkey_release(text) - diff --git a/src/gui/backtesting/widgets.kv b/src/gui/backtesting/widgets.kv deleted file mode 100644 index 1d569f8..0000000 --- a/src/gui/backtesting/widgets.kv +++ /dev/null @@ -1,37 +0,0 @@ -: - size_hint_y: 50 - size_hint_y: None - - -: - height: self.texture_size[1] - font_size: 30 - - -: - size_hint_y: 425 - - -: - id: hotkeys_grid - padding: 20 - cols: 2 - spacing: 10, 20 - size: self.minimum_size - size_hint_x: None - - -: - size_hint: None, None - font_size: 25 - halign: "left" - size: self.texture_size - background_color: 0, 0, 0 - - -: - size_hint: None, None - font_size: 20 - halign: "right" - size: self.texture_size - diff --git a/src/gui/backtesting/widgets.py b/src/gui/backtesting/widgets.py deleted file mode 100644 index 5857886..0000000 --- a/src/gui/backtesting/widgets.py +++ /dev/null @@ -1,70 +0,0 @@ -from api.models import ROI -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.button import Button -from kivy.uix.gridlayout import GridLayout -from kivy.uix.label import Label -from kivy.lang import Builder -from typing import Callable, Optional -from gui.default_widgets import BorderWidget - - -Builder.load_file("./src/gui/backtesting/widgets.kv") - - -class BacktestingInfoLayout(BoxLayout, BorderWidget): - """Class for backtesting info layout""" - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.option_value = BacktestingInfoLabel() - self.bot_roi = BacktestingInfoLabel() - self.interface_name = BacktestingInfoLabel() - - self.add_widget(self.interface_name) - self.add_widget(self.option_value) - self.add_widget(self.bot_roi) - - def update( - self, - option_value: str, - bot_roi: ROI, - interface_name: Optional[str] = None - ) -> None: - self.option_value.text = f"Value: {option_value}" - self.bot_roi.text = f"ROI: {bot_roi}%" - if interface_name is not None: - self.interface_name.text = interface_name - - - -class BacktestingInfoLabel(Label): - """Class for text in backtesting info""" - pass - - -class PlotLayout(BoxLayout, BorderWidget): - """Class for showing plot of backtesting""" - pass - - -class HotKeysLayout(GridLayout, BorderWidget): - """Class for showing buttons and hotkeys""" - def add_actions(self, actions: dict[tuple[str, str], Callable]) -> None: - for (text, hotkey), action in actions.items(): - self.add_widget(ActionButtonLabel( - text=text, on_release=action)) - self.add_widget(ActionHotkeyLabel( - text=f"[ {hotkey} ]")) - - def has_hotkeys(self) -> bool: - return len(self.children) > 0 - - -class ActionButtonLabel(Button): - """Class for backtesting button""" - pass - - -class ActionHotkeyLabel(Label): - """Class for backtesting hotkey""" - pass - diff --git a/src/gui/bot_menu/__init__.py b/src/gui/bot_menu/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/bot_menu/base_bot_menu_screen.kv b/src/gui/bot_menu/base_bot_menu_screen.kv deleted file mode 100644 index 38ca70f..0000000 --- a/src/gui/bot_menu/base_bot_menu_screen.kv +++ /dev/null @@ -1,13 +0,0 @@ -: - MainWindow: - TitleLabel: - text: "Choose action for bot" - - ScrollView: - id: scroll_view - - BoxLayout: - size_hint_y: 0.1 - Button: - text: 'Back to menu' - on_release: root.manager.current = 'menu' diff --git a/src/gui/bot_menu/base_bot_menu_screen.py b/src/gui/bot_menu/base_bot_menu_screen.py deleted file mode 100644 index d53fbc8..0000000 --- a/src/gui/bot_menu/base_bot_menu_screen.py +++ /dev/null @@ -1,65 +0,0 @@ -from collections import defaultdict -from kivy.lang.builder import Builder -from kivy.uix.screenmanager import Screen -from api.models import Bot -from api.type_specifiers import get_bot_type -from gui.default_widgets import ScrollingGridLayout, LabelButton -from typing import Callable, Type - - -Builder.load_file("./src/gui/bot_menu/base_bot_menu_screen.kv") - - -AdditionalOptions = defaultdict[Type[Bot], dict[str, Callable]] -MainOptions = dict[str, Callable] - - -class BaseBotMenuScreen(Screen): - """ - Base class for any bot menu. - Must be implemented 'prepare' method for - executing 'generate_buttons' method - """ - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - - self.bot_actions: ScrollingGridLayout = ScrollingGridLayout() - self.ids.scroll_view.add_widget(self.bot_actions) - - self.main_options: MainOptions = {} - self.additional_options: AdditionalOptions = defaultdict(dict) - - def add_main_option(self, title: str, action: Callable) -> None: - self.main_options[title] = action - - # FIXME: use bot type, not manager - def add_additional_option( - self, - type: Type[Bot], - actions: dict[str, Callable] - ) -> None: - for title, action in actions.items(): - self.additional_options[type][title] = action - - def generate_buttons(self, bot: Bot) -> None: - self._clear_buttons() - bot_type = get_bot_type(bot) - additional_options = self.additional_options[bot_type] - - for label, action in additional_options.items(): - self.bot_actions.add_widget( - LabelButton(text=label, on_release=action) - ) - - for label, action in self.main_options.items(): - self.bot_actions.add_widget( - LabelButton(text=label, on_release=action) - ) - - self.ids.scroll_view.add_widget(self.bot_actions) - - def _clear_buttons(self) -> None: - self.ids.scroll_view.remove_widget(self.bot_actions) - self.bot_actions = ScrollingGridLayout() - diff --git a/src/gui/bot_menu/multiple_bot_menu_screen.kv b/src/gui/bot_menu/multiple_bot_menu_screen.kv deleted file mode 100644 index 0571b51..0000000 --- a/src/gui/bot_menu/multiple_bot_menu_screen.kv +++ /dev/null @@ -1 +0,0 @@ -: diff --git a/src/gui/bot_menu/multiple_bot_menu_screen.py b/src/gui/bot_menu/multiple_bot_menu_screen.py deleted file mode 100644 index e3e7457..0000000 --- a/src/gui/bot_menu/multiple_bot_menu_screen.py +++ /dev/null @@ -1,45 +0,0 @@ -from api.type_specifiers import get_bot_type -from haasomeapi.dataobjects.custombots.MadHatterBot import MadHatterBot - -from haasomeapi.dataobjects.custombots.ScalperBot import ScalperBot - -from api.factories import bot_managers_factory -from api.models import Bot -from gui.bot_menu.base_bot_menu_screen import BaseBotMenuScreen -from gui.default_widgets import LabelButton -from kivy.lang import Builder -from loguru import logger as log - - -Builder.load_file("./src/gui/bot_menu/multiple_bot_menu_screen.kv") - - -class MultipleBotMenuScreen(BaseBotMenuScreen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - - self.bots: set[Bot] = set() - - self.add_additional_option( - MadHatterBot, - {"Config backtesting": self.config_backtesting} - ) - - self.add_additional_option( - ScalperBot, - {"Range backtesting": self.range_backtesting} - ) - - def prepare(self, bots: set[Bot]) -> None: - self.bots.update(bots) - bot: Bot = bots.pop() - bots.add(bot) - - self.generate_buttons(bot) - - def config_backtesting(self, _: LabelButton) -> None: - log.debug(f"Config backtesting") - - def range_backtesting(self, _: LabelButton) -> None: - log.debug(f"Range backtesting") diff --git a/src/gui/bot_menu/single_bot_menu_screen.kv b/src/gui/bot_menu/single_bot_menu_screen.kv deleted file mode 100644 index 0bef180..0000000 --- a/src/gui/bot_menu/single_bot_menu_screen.kv +++ /dev/null @@ -1 +0,0 @@ -: diff --git a/src/gui/bot_menu/single_bot_menu_screen.py b/src/gui/bot_menu/single_bot_menu_screen.py deleted file mode 100644 index 7016b9f..0000000 --- a/src/gui/bot_menu/single_bot_menu_screen.py +++ /dev/null @@ -1,50 +0,0 @@ -from haasomeapi.dataobjects.custombots.MadHatterBot import MadHatterBot -from haasomeapi.dataobjects.custombots.ScalperBot import ScalperBot -from kivy.lang import Builder - -from api.models import Bot -from gui.bot_menu.base_bot_menu_screen import BaseBotMenuScreen -from gui.default_widgets import LabelButton -from loguru import logger as log - - -Builder.load_file("./src/gui/bot_menu/single_bot_menu_screen.kv") - - -class SingleBotMenuScreen(BaseBotMenuScreen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.bot: Bot - - self.add_main_option("Select interface", self.select_interface) - self.add_main_option("Select another bot", self.select_another_bot) - - self.add_additional_option( - MadHatterBot, - {"Config backtesting": self.config_backtesting} - ) - - self.add_additional_option( - ScalperBot, - {"Range backtesting": self.range_backtesting} - ) - - def prepare(self, bot: Bot) -> None: - self.bot = bot - self.generate_buttons(bot) - - def select_interface(self, _: LabelButton) -> None: - self.manager.get_screen("interface_selector").setup(self.bot) - self.manager.current = "interface_selector" - - def select_another_bot(self, _: LabelButton) -> None: - self.manager.current = "bot_selector" - - def config_backtesting(self, _: LabelButton) -> None: - log.debug(f"Config backtesting") - self.manager.get_screen("config_backtester_screen").setup({self.bot}) - self.manager.current = "config_backtester_screen" - - def range_backtesting(self, _: LabelButton) -> None: - log.debug(f"Range backtesting") diff --git a/src/gui/bot_selector/__init__.py b/src/gui/bot_selector/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/bot_selector/bot_selector_screen.kv b/src/gui/bot_selector/bot_selector_screen.kv deleted file mode 100644 index 3620b28..0000000 --- a/src/gui/bot_selector/bot_selector_screen.kv +++ /dev/null @@ -1,16 +0,0 @@ -: - MainWindow: - TitleLabel: - text: "Select bot" - - ScrollView: - id: scroll_view - - BoxLayout: - size_hint_y: 0.1 - Button: - text: 'Back to menu' - on_release: root.manager.current = 'menu' - Button: - text: 'Confirm' - on_release: root.confirm_selected_bots() diff --git a/src/gui/bot_selector/bot_selector_screen.py b/src/gui/bot_selector/bot_selector_screen.py deleted file mode 100644 index 17b96a4..0000000 --- a/src/gui/bot_selector/bot_selector_screen.py +++ /dev/null @@ -1,80 +0,0 @@ -from typing import Type -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder - -from api.bots.BotManager import BotManager -from api.factories.bot_managers_factory import get_bot_manager -from api.models import Bot -from gui.default_widgets import LabelButton, ScrollingGridLayout - -from loguru import logger as log -import gui.colors as colors - - -Builder.load_file("./src/gui/bot_selector/bot_selector_screen.kv") -bot_name = ( - "{bot.name} " - "{bot.priceMarket.primaryCurrency}/" - "{bot.priceMarket.secondaryCurrency}" -) - - -class BotSelectorScreen(Screen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.bot_manager: BotManager - self.bots_map: dict[str, Bot] = {} - self.bots_grid = ScrollingGridLayout() - self.ids.scroll_view.add_widget(self.bots_grid) - self.selected_bots: set[Bot] = set() - - def prepare(self, bot_type: Type) -> None: - self.bot_manager = get_bot_manager(bot_type) - self.update_bots_map() - self.update_bots_buttons() - - def update_bots_map(self) -> None: - self.bots_map.clear() - - for bot in self.bot_manager.get_available_bots(): - name: str = bot_name.format(bot=bot) - self.bots_map[name] = bot - - def update_bots_buttons(self) -> None: - self.clear_buttons() - for name in list(self.bots_map.keys()): - self.bots_grid.add_widget(LabelButton( - text=name, - on_release=self.choose_bot - )) - - def clear_buttons(self) -> None: - self.ids.scroll_view.remove_widget(self.bots_grid) - self.bots_grid = ScrollingGridLayout() - self.ids.scroll_view.add_widget(self.bots_grid) - - def choose_bot(self, instance: LabelButton) -> None: - bot: Bot = self.bots_map[instance.text] - - if bot in self.selected_bots: - self.selected_bots.remove(bot) - instance.color = colors.white - else: - self.selected_bots.add(bot) - instance.color = colors.green - - def confirm_selected_bots(self) -> None: - if not self.selected_bots: - # TODO: Add popup error logging - log.error("Select at least one bot!") - elif len(self.selected_bots) == 1: - self.manager.get_screen("single_bot_menu").prepare(self.selected_bots.pop()) - self.manager.current = "single_bot_menu" - else: - (self - .manager.get_screen("multiple_bot_menu") - .prepare(self.selected_bots) - ) - self.manager.current = "multiple_bot_menu" - self.selected_bots.clear() diff --git a/src/gui/bot_type_selector/__init__.py b/src/gui/bot_type_selector/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/bot_type_selector/bot_type_selector_screen.kv b/src/gui/bot_type_selector/bot_type_selector_screen.kv deleted file mode 100644 index 1e4ef52..0000000 --- a/src/gui/bot_type_selector/bot_type_selector_screen.kv +++ /dev/null @@ -1,25 +0,0 @@ -#: import TitleLabel gui.default_widgets.TitleLabel - - -: - MainWindow: - TitleLabel: - text: "Select bot type" - - ScrollView: - do_scroll_y: True - do_scroll_x: False - - GridLayout: - id: bot_types_grid - cols: 1 - padding: 50 - row_default_height: 60 - row_force_default: True - - BoxLayout: - size_hint_y: 0.1 - Button: - text: 'Back to menu' - on_press: root.manager.current = 'menu' - diff --git a/src/gui/bot_type_selector/bot_type_selector_screen.py b/src/gui/bot_type_selector/bot_type_selector_screen.py deleted file mode 100644 index b1d4ef2..0000000 --- a/src/gui/bot_type_selector/bot_type_selector_screen.py +++ /dev/null @@ -1,40 +0,0 @@ -from gui.default_widgets import LabelButton -from typing import Type -from haasomeapi.dataobjects.custombots.FlashCrashBot import FlashCrashBot -from haasomeapi.dataobjects.custombots.MadHatterBot import MadHatterBot -from haasomeapi.dataobjects.custombots.ScalperBot import ScalperBot -from haasomeapi.dataobjects.tradebot.TradeBot import TradeBot -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder - - -Builder.load_file("./src/gui/bot_type_selector/bot_type_selector_screen.kv") - -bot_types_map: dict[str, Type] = { - "Trade": TradeBot, - "Mad-Hatter": MadHatterBot, - "Scalper": ScalperBot, - "Flash-Crash": FlashCrashBot, -} - - -class BotTypeSelectorScreen(Screen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self._generate_bot_type_buttons() - - def _generate_bot_type_buttons(self) -> None: - for bot_type in list(bot_types_map.keys()): - self.ids.bot_types_grid.add_widget( - LabelButton(text=bot_type, on_release=self.choose_bot_type) - ) - - def choose_bot_type(self, instance: LabelButton) -> None: - text: str = instance.text - bot_type: Type = bot_types_map[text] - print(f"{bot_type=}, {text=}") - - self.manager.get_screen("bot_selector").prepare(bot_type) - self.manager.current = "bot_selector" - diff --git a/src/gui/colors.py b/src/gui/colors.py deleted file mode 100644 index 3f972e4..0000000 --- a/src/gui/colors.py +++ /dev/null @@ -1,5 +0,0 @@ -red = (1, 0, 0, 1) -green = (0, 1, 0, 1) -blue = (0, 0, 1, 1) -black = (0, 0, 0, 1) -white = (1, 1, 1, 1) diff --git a/src/gui/default_widgets.py b/src/gui/default_widgets.py deleted file mode 100644 index e186970..0000000 --- a/src/gui/default_widgets.py +++ /dev/null @@ -1,133 +0,0 @@ -import re -import kivy -from kivy.clock import mainthread -from kivy.uix.scrollview import ScrollView -from kivy.uix.label import Label -from kivy.uix.widget import Widget -from kivy.uix.textinput import TextInput -from kivy.uix.boxlayout import BoxLayout -from kivy.uix.gridlayout import GridLayout -from kivy.uix.button import Button -import gui.colors as colors - - -class Title(Widget): - pass - - -class Subtitle(Widget): - pass - - -class Text(Widget): - pass - - -class BaseLabel(Label): - pass - - -class TitleLabel(BaseLabel, Title): - pass - - -class SubtitleLabel(BaseLabel, Subtitle): - pass - - -class TextLabel(BaseLabel, Text): - pass - - -class IntegerInput(TextInput): - - pat = re.compile('[^0-9]') - - def insert_text(self, substring, from_undo=False): - pat = self.pat - if self.text.startswith("0"): - s = re.sub(pat, "", substring[1:]) - else: - s = re.sub(pat, '', substring) - return super().insert_text(s, from_undo=from_undo) - - -class FloatInput(TextInput): - pat = re.compile('[^0-9]') - def insert_text(self, substring, from_undo=False): - pat = self.pat - if '.' in self.text: - s = re.sub(pat, '', substring) - else: - s = '.'.join( - re.sub(pat, '', s) - for s in substring.split('.', 1) - ) - return super().insert_text(s, from_undo=from_undo) - - -class MainWindow(BoxLayout): - pass - - -class ScrollingGridLayout(GridLayout): - pass - - -class LabelButton(Button): - pass - - -class BorderWidget(Widget): - """Class for drawing borders around window""" - pass - - -class LogsText(Label): - pass - - -class LogsLayout(ScrollView, BorderWidget): - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.scroll_y = 0 - self.logs_grid = ScrollingGridLayout() - self.add_widget(self.logs_grid) - - @mainthread - def info(self, text: str, *args) -> TextLabel: - if len(args) == 1: - return self.update_old_log(text, *args) - else: - label: TextLabel = TextLabel(text=text) - self.logs_grid.add_widget(label) - - if self.scroll_y != 0: - self.scroll_y = 0 - self.scroll_to(label) - - return label - - @mainthread - def debug(self, text: str, *args) -> None: - pass - - @mainthread - def warning(self, text: str, *args) -> None: - pass - - @mainthread - def error(self, text: str, *args) -> None: - pass - - def update_old_log(self, text: str, log_row: TextLabel) -> TextLabel: - log_row.text += f" | {text}" - log_row.color = colors.green - return log_row - - def clear(self) -> None: - self.remove_widget(self.logs_grid) - self.logs_grid = ScrollingGridLayout() - self.add_widget(self.logs_grid) - self.scroll_y = 0 - diff --git a/src/gui/haas_toolbox_app.py b/src/gui/haas_toolbox_app.py deleted file mode 100644 index fb0e413..0000000 --- a/src/gui/haas_toolbox_app.py +++ /dev/null @@ -1,36 +0,0 @@ -from gui.autobacktesters.config_backtester.config_backtester_screen import ConfigBacktesterScreen -from gui.backtesting.single_backtester_screen import SingleBacktesterScreen -from gui.bot_menu.multiple_bot_menu_screen import MultipleBotMenuScreen -from gui.bot_menu.single_bot_menu_screen import SingleBotMenuScreen -from gui.bot_selector.bot_selector_screen import BotSelectorScreen -from gui.bot_type_selector.bot_type_selector_screen \ - import BotTypeSelectorScreen -from gui.interface_selector.interface_selector_screen \ - import InterfaceSelectorScreen -from gui.interface_option_selector.interface_option_selector_screen \ - import InterfaceOptionSelectorScreen -from gui.settings.settings_screen import SettingsScreen -from gui.menu.menu_screen import MenuScreen - -from kivy.app import App -from kivy.uix.screenmanager import ScreenManager - - -class HaasToolBoxApp(App): - def build(self): - sm = ScreenManager() - - sm.add_widget(MenuScreen(name="menu")) - sm.add_widget(SettingsScreen(name="settings")) - sm.add_widget(BotTypeSelectorScreen(name="bot_type_selector")) - sm.add_widget(BotSelectorScreen(name="bot_selector")) - sm.add_widget(InterfaceSelectorScreen(name="interface_selector")) - sm.add_widget(SingleBotMenuScreen(name="single_bot_menu")) - sm.add_widget(MultipleBotMenuScreen(name="multiple_bot_menu")) - sm.add_widget(InterfaceOptionSelectorScreen( - name="interface_option_selector")) - sm.add_widget(SingleBacktesterScreen(name="single_backtester")) - sm.add_widget(ConfigBacktesterScreen(name="config_backtester_screen")) - - return sm - diff --git a/src/gui/haastoolbox.kv b/src/gui/haastoolbox.kv deleted file mode 100644 index 4e5cb2c..0000000 --- a/src/gui/haastoolbox.kv +++ /dev/null @@ -1,77 +0,0 @@ -#: import Title gui.default_widgets.Title -#: import Subtitle gui.default_widgets.Subtitle -#: import Text gui.default_widgets.Text -#: import BaseLabel gui.default_widgets.BaseLabel -#: import TitleLabel gui.default_widgets.TitleLabel -#: import SubtitleLabel gui.default_widgets.SubtitleLabel -#: import TextLabel gui.default_widgets.TextLabel -#: import MainWindow gui.default_widgets.MainWindow -#: import BorderWidget gui.default_widgets.BorderWidget -#: import LogsText gui.default_widgets.LogsText -#: import LogsLayout gui.default_widgets.LogsLayout - - -: - halign: "center" - valign: "center" - font_size: 40 - -<Subtitle>: - halign: "left" - valign: "center" - font_size: 30 - -<Text>: - halign: "left" - valign: "center" - font_size: 20 - -<BaseLabel>: - text_size: self.size - size_hint: 1, 0.1 - -<MainWindow>: - orientation: "vertical" - padding: 20 - -<ScrollingGridLayout>: - padding: 20 - size_hint_y: None - cols: 1 - spacing: 30 - height: self.minimum_height - -<LabelButton>: - id: trade - background_color: 0, 0, 0 - font_size: 30 - halign: "left" - padding: 0, 0 - size: self.texture_size - size_hint: None, None - -<BorderWidget>: - canvas.before: - Color: - rgba: .5, .5, .5, 1 - Line: - width: 2 - rectangle: self.x, self.y, self.width, self.height - -<LogsLayout>: - size_hint_y: 425 - canvas.before: - Color: - rgba: .5, .5, .5, 1 - Line: - width: 4 - rectangle: self.x, self.y, self.width, self.height - -<LogsText>: - padding: 10, 10 - size_hint_y: None - font_size: 25 - height: self.texture_size[1] - text_size: self.width, None - - diff --git a/src/gui/interface_option_selector/__init__.py b/src/gui/interface_option_selector/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/interface_option_selector/interface_option_selector_screen.kv b/src/gui/interface_option_selector/interface_option_selector_screen.kv deleted file mode 100644 index 75a1eab..0000000 --- a/src/gui/interface_option_selector/interface_option_selector_screen.kv +++ /dev/null @@ -1,18 +0,0 @@ -<InterfaceOptionSelectorScreen>: - MainWindow: - TitleLabel: - id: main_label - text: "Select interface option" - - ScrollView: - id: scroll_view - - BoxLayout: - size_hint_y: 0.2 - Button: - text: 'Back to interface selection' - on_press: root.manager.current = "interface_selector" - Button: - text: 'Back to menu' - on_press: root.manager.current = 'menu' - diff --git a/src/gui/interface_option_selector/interface_option_selector_screen.py b/src/gui/interface_option_selector/interface_option_selector_screen.py deleted file mode 100644 index f2eecd0..0000000 --- a/src/gui/interface_option_selector/interface_option_selector_screen.py +++ /dev/null @@ -1,58 +0,0 @@ -from api.backtesting.BotBacktester import BotBacketster -from api.bots.BotManager import BotManager -from api.models import Interface -from haasomeapi.dataobjects.custombots.dataobjects.IndicatorOption import IndicatorOption -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder - -from gui.default_widgets import LabelButton, ScrollingGridLayout -from typing import Callable, Any - - -Builder.load_file( - "./src/gui/interface_option_selector/interface_option_selector_screen.kv") - - -class InterfaceOptionSelectorScreen(Screen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.bot_manager: BotManager - self.interface: Interface - self.grid: ScrollingGridLayout = ScrollingGridLayout() - self.ids.scroll_view.add_widget(self.grid) - - def setup(self, bot_manager: BotManager, interface: Interface) -> None: - self.bot_manager = bot_manager - self.interface = interface - self.clear_buttons() - self.generate_buttons(interface) - - def clear_buttons(self) -> None: - self.ids.scroll_view.remove_widget(self.grid) - self.grid = ScrollingGridLayout() - - def generate_buttons(self, interface: Interface) -> None: - for option in self.bot_manager.interface_options(interface): - print(f"{option.title=}, {option.value=}") - self.grid.add_widget( - LabelButton( - text=f"{option.title}: {option.value}", - on_release=self.process_option(option) - ) - ) - self.ids.scroll_view.add_widget(self.grid) - - def process_option(self, option: IndicatorOption) -> Callable[[Any], None]: - def inner(_): - print(f"Choosed {option.title}: {option.value}") - self.manager.get_screen("single_backtester").setup( - BotBacketster(self.bot_manager, self.interface, option) - ) - self.manager.current = "single_backtester" - return inner - - def update_data(self) -> None: - self.bot_manager.refresh_bot() - self.clear_buttons() - self.generate_buttons(self.interface) diff --git a/src/gui/interface_selector/__init__.py b/src/gui/interface_selector/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/interface_selector/interface_selector_screen.kv b/src/gui/interface_selector/interface_selector_screen.kv deleted file mode 100644 index cce2931..0000000 --- a/src/gui/interface_selector/interface_selector_screen.kv +++ /dev/null @@ -1,15 +0,0 @@ -<InterfaceSelectorScreen>: - MainWindow: - TitleLabel: - text: "Select interface" - - ScrollView: - id: scroll_view - - BoxLayout: - size_hint_y: 0.2 - orientation: "vertical" - Button: - text: 'Back to menu' - on_press: root.manager.current = 'menu' - diff --git a/src/gui/interface_selector/interface_selector_screen.py b/src/gui/interface_selector/interface_selector_screen.py deleted file mode 100644 index b696213..0000000 --- a/src/gui/interface_selector/interface_selector_screen.py +++ /dev/null @@ -1,67 +0,0 @@ -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder - -from api.bots.BotManager import BotManager -from api.factories.bot_managers_factory import get_bot_manager_by_bot -from api.models import Bot -from api.wrappers.InterfaceWrapper import InterfaceWrapper -from gui.default_widgets import LabelButton, ScrollingGridLayout, SubtitleLabel - - -Builder.load_file("./src/gui/interface_selector/interface_selector_screen.kv") - - - -class InterfaceSelectorScreen(Screen): - - def __init__(self, **kwargs) -> None: - super().__init__(**kwargs) - self.bot_manager: BotManager - self.interface_list = self.create_buttons_grid() - self.ids.scroll_view.add_widget(self.interface_list) - - def setup(self, bot: Bot) -> None: - self.bot_manager = get_bot_manager_by_bot(bot) - self.bot_manager.set_bot(bot) - self.update_buttons() - - def update_buttons(self) -> None: - print(f"Updating buttons") - self.clear_buttons() - self.generate_buttons() - self.ids.scroll_view.add_widget(self.interface_list) - - - def clear_buttons(self) -> None: - self.ids.scroll_view.remove_widget(self.interface_list) - self.interface_list = self.create_buttons_grid() - print(f"Buttons cleared") - - def generate_buttons(self) -> None: - types = self.bot_manager.get_available_interface_types() - - for type in types: - label = SubtitleLabel(text=type.__name__) - block = ScrollingGridLayout() - self.interface_list.add_widget(label) - - for interface in self.bot_manager.get_interfaces_by_type(type): - block.add_widget( - LabelButton( - text=InterfaceWrapper(interface).name, - on_release=self.process_interface(interface))) - - self.interface_list.add_widget(block) - - def create_buttons_grid(self) -> ScrollingGridLayout: - return ScrollingGridLayout() - - def process_interface(self, interface): - def inner(_): - print(f"Choosed {interface}") - (self.manager - .get_screen("interface_option_selector") - .setup(self.bot_manager, interface)) - self.manager.current = "interface_option_selector" - return inner - diff --git a/src/gui/menu/__init__.py b/src/gui/menu/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/menu/menu_screen.kv b/src/gui/menu/menu_screen.kv deleted file mode 100644 index 54ec449..0000000 --- a/src/gui/menu/menu_screen.kv +++ /dev/null @@ -1,30 +0,0 @@ -<MenuScreen>: - AnchorLayout: - anchor_x: "center" - anchor_y: "center" - BoxLayout: - center: self.parent.center - size_hint_x: 0.4 - size_hint_y: 0.2 - canvas: - Color: - rgba: 1, 0, 0, 0.5 - Rectangle: - pos: self.pos - size: self.size - - BoxLayout: - padding: 10, 10 - orientation: "vertical" - Button: - text: 'Goto settings' - on_press: root.manager.current = 'settings' - Button: - text: 'Goto bot type selecting' - on_press: root.manager.current = 'bot_type_selector' - Button: - text: 'Goto bot backtesting' - on_press: root.manager.current = 'single_backtester' - Button: - text: 'Quit' - on_press: exit() diff --git a/src/gui/menu/menu_screen.py b/src/gui/menu/menu_screen.py deleted file mode 100644 index b51ee8f..0000000 --- a/src/gui/menu/menu_screen.py +++ /dev/null @@ -1,10 +0,0 @@ -from kivy.uix.screenmanager import Screen -from kivy.lang import Builder - - -Builder.load_file("./src/gui/menu/menu_screen.kv") - - -class MenuScreen(Screen): - pass - diff --git a/src/gui/settings/__init__.py b/src/gui/settings/__init__.py deleted file mode 100644 index e69de29..0000000 diff --git a/src/gui/settings/settings_screen.kv b/src/gui/settings/settings_screen.kv deleted file mode 100644 index 3c0c22c..0000000 --- a/src/gui/settings/settings_screen.kv +++ /dev/null @@ -1,169 +0,0 @@ -#: import uri api.models.uri - - -<SettingsSection>: - cols: 2 - row_default_height: 40 - row_force_default: True - size_hint_y: None - padding: 30, 0, 0, 10 - height: self.minimum_height - - -<SettingsScreen>: - MainWindow: - TitleLabel: - text: "Settings page" - - ScrollView: - do_scroll_y: True - do_scroll_x: False - - ScrollingGridLayout: - - SubtitleLabel: - text: "API" - SettingsSection: - TextLabel: - text: "Server" - TextInput: - id: server - text: str(root.config.server) - on_text_validate: root.set_property(self.text, "server", uri) - multiline: False - - TextLabel: - text: "Secret:" - TextInput: - id: secret - text: root.config.secret - on_text_validate: root.set_property(self.text, "secret", str) - multiline: False - - - SubtitleLabel: - text: "Date" - SettingsSection: - TextLabel: - text: "Year:" - IntegerInput: - id: year - text: str(root.config.year) - on_text_validate: root.set_property(self.text, "year", int) - multiline: False - - TextLabel: - text: "Month:" - IntegerInput: - id: month - text: str(root.config.month) - on_text_validate: root.set_property(self.text, "year", int) - multiline: False - - TextLabel: - text: "Day:" - IntegerInput: - id: day - text: str(root.config.day) - on_text_validate: root.set_property(self.text, "day", int) - multiline: False - - TextLabel: - text: "Hour:" - IntegerInput: - id: hour - text: str(root.config.hour) - on_text_validate: root.set_property(self.text, "hour", int) - multiline: False - - TextLabel: - text: "Min:" - IntegerInput: - text: str(root.config.min) - id: min - on_text_validate: root.set_property(self.text, "min", int) - multiline: False - - - SubtitleLabel: - text: "Scalper range backtesting" - SettingsSection: - TextLabel: - text: "Target percentage start:" - FloatInput: - id: target_percentage_start - text: str(root.config.target_percentage_start) - on_text_validate: root.set_property(self.text, "target_percentage_start", float) - multiline: False - - TextLabel: - text: "Target percentage end:" - FloatInput: - id: target_percentage_end - text: str(root.config.target_percentage_end) - on_text_validate: root.set_property(self.text, "target_percentage_end", float) - multiline: False - - TextLabel: - text: "Target percentage step:" - FloatInput: - id: target_percentage_step - text: str(root.config.target_percentage_step) - on_text_validate: root.set_property(self.text, "target_percentage_step", float) - multiline: False - - TextLabel: - text: "Stop loss start:" - FloatInput: - id: stop_loss_start - text: str(root.config.stop_loss_start) - on_text_validate: root.set_property(self.text, "stop_loss_start", float) - multiline: False - - TextLabel: - text: "Stop loss end:" - FloatInput: - id: stop_loss_end - text: str(root.config.stop_loss_end) - on_text_validate: root.set_property(self.text, "stop_loss_end", float) - multiline: False - - TextLabel: - text: "Stop loss step:" - FloatInput: - id: stop_loss_step - text: str(root.config.stop_loss_step) - on_text_validate: root.set_property(self.text, "stop_loss_step", float) - multiline: False - - - SubtitleLabel: - text: "Config backtesting" - SettingsSection: - TextLabel: - text: "Top bots count:" - TextInput: - id: config_backtesting_top_bots_count - text: str(root.config.config_backtesting_top_bots_count) - on_text_validate: root.set_property(self.text, "config_backtesting_top_bots_count", int) - multiline: False - - TextLabel: - text: "Batch size:" - IntegerInput: - id: config_backtesting_batch_size - text: str(root.config.config_backtesting_batch_size) - on_text_validate: root.set_property(self.text, "config_backtesting_batch_size", int) - multiline: False - - - BoxLayout: - size_hint: 1, 0.2 - orientation: "vertical" - Button: - text: 'Save settings' - on_press: root.dispatch("on_save") - Button: - text: 'Back to menu' - on_press: root.manager.current = 'menu' - diff --git a/src/gui/settings/settings_screen.py b/src/gui/settings/settings_screen.py deleted file mode 100644 index b9036d8..0000000 --- a/src/gui/settings/settings_screen.py +++ /dev/null @@ -1,36 +0,0 @@ -from api.models import Config -from typing import Type -from kivy.uix.gridlayout import GridLayout -from kivy.uix.screenmanager import Screen - -from kivy.properties import ObjectProperty -from kivy.lang import Builder - - -Builder.load_file("./src/gui/settings/settings_screen.kv") -my_config = Config() - - -class SettingsSection(GridLayout): - pass - - -class SettingsScreen(Screen): - config = ObjectProperty(my_config) - - __events__ = ("on_save", ) - - def on_save(self) -> None: - print("Saving config...") - print(my_config) - - def set_property(self, value: str, name: str, type: Type) -> None: - try: - setattr(self.config, name, type(value)) - print(f"Attr saved {getattr(self.config, name)}") - self.ids[name].background_color = (1, 1, 1) - self.ids[name].text = str(getattr(self.config, name)) - except ValueError: - print(f"Wrong format: {value=}, {name=}, {type=}") - self.ids[name].background_color = (1, 0, 0) -