From e4cbbd3ee391819e0d187fe8ec0b9eaf80a274ac Mon Sep 17 00:00:00 2001 From: Florinel Chis Date: Mon, 22 Mar 2021 11:40:52 +0200 Subject: [PATCH] #8 refresh datasets script --- refresh.py | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 refresh.py diff --git a/refresh.py b/refresh.py new file mode 100644 index 00000000..9c067816 --- /dev/null +++ b/refresh.py @@ -0,0 +1,26 @@ +import os, csv, sys +import talib +import yfinance as yf +import pandas +from flask import Flask, escape, request, render_template +from patterns import candlestick_patterns +import datetime + +if __name__ == '__main__': + if(len(sys.argv)<2): + sys.exit('Usage: '+__file__+" [all|symbol]") + symbol = sys.argv[1] + + if(symbol and symbol != 'all'): + data = yf.download(symbol, start="2020-01-01", end=datetime.date.today()) + data.to_csv('datasets/daily/{}.csv'.format(symbol)) + + if(symbol == 'all'): + with open('datasets/symbols.csv') as f: + for line in f: + if "," not in line: + continue + symbol = line.split(",")[0] + data = yf.download(symbol, start="2020-01-01", end=datetime.date.today()) + data.to_csv('datasets/daily/{}.csv'.format(symbol)) +