Conversation
algobot/helpers.py
Outdated
| LONG_INTERVAL_MAP = {v: k for k, v in SHORT_INTERVAL_MAP.items()} | ||
|
|
||
|
|
||
| class Paths: |
There was a problem hiding this comment.
All path based information is encapsulated in this class
There was a problem hiding this comment.
We should probably store this class in another file. With that being said, we should really organize the layout of the project.. Everything is kinda all scattered all across right now
There was a problem hiding this comment.
I would advise perhaps doing that in another PR. Doing things incrementally and in small commits is easier. Especially to revert if things go south.
ZENALC
left a comment
There was a problem hiding this comment.
Nice! Thank you for your contribution my friend!
I will have a more thorough review in the next few days and merge
| from binance.helpers import interval_to_milliseconds | ||
|
|
||
| from algobot.helpers import (ROOT_DIR, get_logger, get_normalized_data, | ||
| from algobot import helpers |
There was a problem hiding this comment.
Here also, why not just have from algobot.helpers import ...?
| raise ValueError("Invalid interval.", 4) | ||
|
|
||
| def create_folders_and_change_path(self, folderName: str): | ||
| def create_folders_and_change_path(self, folder_name: str): |
There was a problem hiding this comment.
Nice change! We should really convert camel case to snake case over time
There was a problem hiding this comment.
snake case is the python way. If you're happy with something we could use black?
https://black.readthedocs.io/en/stable/
We can configure it as a pre-commit hook even :)
Although not sure how it handles variable naming come to think about it 🤔
There was a problem hiding this comment.
pylint will help enforce it ;)
There was a problem hiding this comment.
Yeap. We should really start leveraging pylint and mypy
algobot/helpers.py
Outdated
| folder = os.path.basename(targetPath) | ||
| os.mkdir(os.path.join(basePath, folder)) | ||
| if not os.path.exists(target_path): | ||
| os.makedirs(target_path) |
There was a problem hiding this comment.
We can also use the exist_ok kwarg and set that to True so we don't need to check the conditional
There was a problem hiding this comment.
Won't that change the semantics of the function?
As in we return true/false if the directory exists?
|
|
||
|
|
||
| def open_file_or_folder(targetPath: str): | ||
| def open_file_or_folder(target_path: str): |
|
|
||
|
|
||
| def pytest_unconfigure(config): | ||
| from algobot.helpers import PATHS, AppDirTemp |
There was a problem hiding this comment.
Super important this is done here otherwise we init PATHS before setting the env var to control which one gets init
| fileName = fileName if fileName != '' else None | ||
| backtest_folder_path = helpers.PATHS.get_backtest_results_dir() | ||
| create_folder_if_needed(backtest_folder_path) | ||
| inner_path = os.path.join(backtest_folder_path, self.backtester.symbol) |
There was a problem hiding this comment.
We should probably refactor this code to use makedirs()
There was a problem hiding this comment.
create_folder_if_needed calls that under the hood.
| pytest-socket==0.4.0 | ||
| flake8==3.9.0 | ||
| pre-commit==2.11.1 | ||
| flake8==3.9.2 |
There was a problem hiding this comment.
We should migrate to pipenv, so much easier with [dev-packages[ and piplock...
There was a problem hiding this comment.
We could do - but lets leave that to another PR ;)
There is also https://python-poetry.org/
I've not used but looks quite nice.
| assert parse_strategy_name(name) == expected, f"Expected parsed strategy to be: {expected}." | ||
|
|
||
|
|
||
| def test_create_folder_if_needed(): |
There was a problem hiding this comment.
@ZENALC Started adding some tests too but didn't wanna go too overkill yet.
Pycharms is reporting this metric
| self.infoLabel.setText(f'{directory.capitalize()} files have been successfully deleted.') | ||
|
|
||
| if directory == 'Logs': # Reinitialize log folder if old logs were purged. | ||
| if directory.endswith('Logs'): # Reinitialize log folder if old logs were purged. |
There was a problem hiding this comment.
Could prob have this defined as a callback and passed into the caller.
But that's for another PR

Prepare for packaging up as an application by moving user data out of the project repository to the user home directories.
This is a significant change.
Partial work for #29