Guick StartΒΆ

Open main.py

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
 import json
 import logging
 import os
 import time
 from argparse import ArgumentParser
 import datetime

 from finrl.config import config



 def build_parser():
     parser = ArgumentParser()
     parser.add_argument("--mode",dest="mode",
                         help="start mode, train, download_data"
                              " backtest",
                         metavar="MODE", default="train")
     return parser


 def main():
     parser = build_parser()
     options = parser.parse_args()
     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 options.mode == "train":
         import finrl.autotrain.training
         finrl.autotrain.training.train_one()

     elif options.mode == "download_data":
         from finrl.marketdata.yahoodownloader import YahooDownloader
         df = YahooDownloader(start_date = config.START_DATE,
                              end_date = config.END_DATE,
                              ticker_list = config.DOW_30_TICKER).fetch_data()
         now = datetime.datetime.now().strftime('%Y%m%d-%Hh%M')
         df.to_csv("./"+config.DATA_SAVE_DIR+"/"+now+'.csv')

 if __name__ == "__main__":
     main()

Run the library:

python main.py --mode=train

Choices for --mode: start mode, train, download_data, backtest