-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build out user dir #31
base: master
Are you sure you want to change the base?
Changes from all commits
e0a6be0
1d1d20f
a0f146c
acb1bd9
eeba548
f115f41
b8027a1
ef4a981
bca643d
71fb806
a5a6542
e7af0ac
5393bca
ab8ae45
2c7edb2
e3710fb
73b605e
b69a08e
f2094be
9c6737f
463e9bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,8 @@ | |
from binance.client import Client | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here also, why not just have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated all |
||
from algobot.helpers import (PATHS, get_logger, get_normalized_data, | ||
get_ups_and_downs) | ||
from algobot.typing_hints import DATA_TYPE | ||
|
||
|
@@ -142,12 +143,12 @@ def get_database_file(self) -> str: | |
Retrieves database file path. | ||
:return: Database file path. | ||
""" | ||
database_folder = os.path.join(ROOT_DIR, 'Databases') | ||
database_folder = PATHS.get_database_dir() | ||
if not os.path.exists(database_folder): | ||
os.mkdir(database_folder) | ||
os.makedirs(database_folder) | ||
|
||
filePath = os.path.join(database_folder, f'{self.symbol}.db') | ||
return filePath | ||
file_path = os.path.join(database_folder, f'{self.symbol}.db') | ||
return file_path | ||
|
||
def create_table(self): | ||
""" | ||
|
@@ -521,19 +522,20 @@ def get_interval_minutes(self) -> int: | |
else: | ||
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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice change! We should really convert camel case to snake case over time There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 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. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. pylint will help enforce it ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeap. We should really start leveraging pylint and mypy |
||
""" | ||
Creates appropriate folders for data storage then changes current working directory to it. | ||
:param folderName: Folder to create. | ||
:param folder_name: Folder to create. | ||
""" | ||
os.chdir(ROOT_DIR) | ||
if not os.path.exists(folderName): # Create CSV folder if it doesn't exist | ||
os.mkdir(folderName) | ||
os.chdir(folderName) # Go inside the folder. | ||
if not os.path.exists(folder_name): | ||
helpers.create_folder_if_needed(folder_name) | ||
|
||
if not os.path.exists(self.symbol): # Create symbol folder inside CSV folder if it doesn't exist. | ||
os.chdir(folder_name) | ||
|
||
if not os.path.exists(self.symbol): | ||
os.mkdir(self.symbol) | ||
os.chdir(self.symbol) # Go inside the folder. | ||
|
||
os.chdir(self.symbol) | ||
|
||
def write_csv_data(self, totalData: list, fileName: str, armyTime: bool = True) -> str: | ||
""" | ||
|
@@ -544,7 +546,7 @@ def write_csv_data(self, totalData: list, fileName: str, armyTime: bool = True) | |
:return: Absolute path to CSV file. | ||
""" | ||
currentPath = os.getcwd() | ||
self.create_folders_and_change_path(folderName="CSV") | ||
self.create_folders_and_change_path(PATHS.get_csv_dir()) | ||
|
||
with open(fileName, 'w') as f: | ||
f.write("Date_UTC, Open, High, Low, Close, Volume, Quote_Asset_Volume, Number_of_Trades, " | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably refactor this code to use makedirs()
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
create_folder_if_needed
calls that under the hood.