Skip to content

Commit

Permalink
Merge pull request AI4Finance-Foundation#562 from AI4Finance-Foundati…
Browse files Browse the repository at this point in the history
…on/directory_func

Directory func
  • Loading branch information
zhumingpassional authored Apr 9, 2022
2 parents a4e6766 + 1dbedf7 commit bacca16
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
30 changes: 19 additions & 11 deletions FinRL_StockTrading_NeurIPS_2018.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@

from finrl import config
from finrl import config_tickers
from finrl.main import check_make_directories
from finrl.main import check_and_make_directories
import os

import pandas as pd
Expand All @@ -101,21 +101,29 @@

import itertools

from finrl.config import (
DATA_SAVE_DIR,
TRAINED_MODEL_DIR,
TENSORBOARD_LOG_DIR,
RESULTS_DIR,
)

'''
Use check_make_directories() to replace the following
Use check_and_make_directories() to replace the following
# if not os.path.exists("./" + config.DATA_SAVE_DIR):
# os.makedirs("./" + config.DATA_SAVE_DIR)
# if not os.path.exists("./" + config.TRAINED_MODEL_DIR):
# os.makedirs("./" + config.TRAINED_MODEL_DIR)
# if not os.path.exists("./" + config.TENSORBOARD_LOG_DIR):
# os.makedirs("./" + config.TENSORBOARD_LOG_DIR)
# if not os.path.exists("./" + config.RESULTS_DIR):
# os.makedirs("./" + config.RESULTS_DIR)
if not os.path.exists("./" + config.DATA_SAVE_DIR):
os.makedirs("./" + config.DATA_SAVE_DIR)
if not os.path.exists("./" + config.TRAINED_MODEL_DIR):
os.makedirs("./" + config.TRAINED_MODEL_DIR)
if not os.path.exists("./" + config.TENSORBOARD_LOG_DIR):
os.makedirs("./" + config.TENSORBOARD_LOG_DIR)
if not os.path.exists("./" + config.RESULTS_DIR):
os.makedirs("./" + config.RESULTS_DIR)
'''

check_make_directories()
check_and_make_directories([DATA_SAVE_DIR, TRAINED_MODEL_DIR, TENSORBOARD_LOG_DIR, RESULTS_DIR])




Expand Down
19 changes: 9 additions & 10 deletions finrl/main.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from typing import List
from argparse import ArgumentParser
from finrl import config
from finrl.config_tickers import DOW_30_TICKER
Expand Down Expand Up @@ -37,21 +38,19 @@ def build_parser():
)
return parser

def check_make_directories():
if not os.path.exists("./" + config.DATA_SAVE_DIR):
os.makedirs("./" + config.DATA_SAVE_DIR)
if not os.path.exists("./" + config.TRAINED_MODEL_DIR):
os.makedirs("./" + config.TRAINED_MODEL_DIR)
if not os.path.exists("./" + config.TENSORBOARD_LOG_DIR):
os.makedirs("./" + config.TENSORBOARD_LOG_DIR)
if not os.path.exists("./" + config.RESULTS_DIR):
os.makedirs("./" + config.RESULTS_DIR)

# "./" will be added in front of each directory
def check_and_make_directories(directories: List[str]):
for directory in directories:
if not os.path.exists("./" + directory):
os.makedirs("./" + directory)



def main():
parser = build_parser()
options = parser.parse_args()
check_make_directories()
check_and_make_directories([DATA_SAVE_DIR, TRAINED_MODEL_DIR, TENSORBOARD_LOG_DIR, RESULTS_DIR])

if options.mode == "train":
from finrl import train
Expand Down

0 comments on commit bacca16

Please sign in to comment.