Python 3.6 The experiment is to do the following
I have this following code with given daily EOD/OHLC stock data getting it from quandl for every day.
class YahooQuote(Quote):
''' Daily quotes from Yahoo. Date format='yyyy-mm-dd' '''
def __init__(self,symbol,date,end_date=datetime.date.today().isoformat()):
super(YahooQuote,self).__init__()
self.symbol = symbol.upper()
url_string = "https://www.quandl.com/api/v3/datasets/NSE/CEATLTD.csv?&order=asc&collapse=daily&start_date=2017-04-18&end_date=2017-05-19&api_key=rFp-5oz3wKzJtNAuvzxC"
csv = urllib.request.urlopen(url_string).readlines()
csv.pop(0)
print(csv)
for bar in range(0,len(csv)):
ds,open_,high,low,last,close,volume,adjc = csv[bar].decode().rstrip().split(',')
open_,high,low,last,close,volume,adjc = [float(x) for x in [open_,high,low,last,close,volume,adjc]]
dt = datetime.datetime.strptime(ds,'%Y-%m-%d')
The csv has the daily EOD data from 2017-04-18
to 2017-05-19
in OHLC format
I want this data to be converted to Weekly in one CSV and Monthly in another CSV.How to do that in very efficient way in python.
While doing Weekly conversion up to the date given, the data should be updated.
i referred some of the existing code in the link since i am new i am not able to proceed.Any python expert help with right code will help solving the issues.
Convert daily pandas stock data to monthly data using first trade day of the month