Skip to content

Commit 479e4e4

Browse files
committed
fix: mkdir if not exist
1 parent 6df59bd commit 479e4e4

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

get_stock_data.py

+9
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
import baostock as bs
22
import pandas as pd
3+
import os
4+
35

46
OUTPUT = './stockdata'
57

68

9+
def mkdir(directory):
10+
if not os.path.exists(directory):
11+
os.makedirs(directory)
12+
13+
714
class Downloader(object):
815
def __init__(self,
916
output_dir,
@@ -42,9 +49,11 @@ def run(self):
4249

4350
if __name__ == '__main__':
4451
# 获取全部股票的日K线数据
52+
mkdir('./stockdata/train')
4553
downloader = Downloader('./stockdata/train', date_start='1990-01-01', date_end='2019-11-29')
4654
downloader.run()
4755

56+
mkdir('./stockdata/test')
4857
downloader = Downloader('./stockdata/test', date_start='2019-12-01', date_end='2019-12-31')
4958
downloader.run()
5059

0 commit comments

Comments
 (0)