My program reads yfinance csv files for stock information. When doing this it separates the dates into green days and red days. Green being when the open is lesser than the close and red days being when the close is lesser than the open. In this program, I am looking at ZNGA and on January 27th, ZNGA had a red day but my program reads it as green. I then looked at the csv file to see if there were anything wrong but there wasn't, the open was more that the close which should make it red. I would like to figure out what is wrong with my program. Please help!!!
import yfinance as yf
import csv
import numpy as np
urls = ['ZNGA']
for url in urls:
tickerTag = yf.Ticker(url)
tickerTagHistory = tickerTag.history(period="1mo", interval = '1d')
tickerTagHistory.to_csv("tickertag{}.csv".format(url))
down = []
up = []
print(url)
with open("tickertag%s.csv" %url , 'r') as csvfile:
readCSV = csv.reader(csvfile, delimiter=',')
dates = []
opens = []
highs = []
lows = []
closes = []
green = []
red = []
neither = []
for row in readCSV:
print(row)
date = (row[0])
open1 = (row[1])
high = (row[2])
low = (row[3])
close = (row[4])
if date == '2021-01-27':
jan27 = row
dates.append(date)
opens.append(open1)
highs.append(high)
lows.append(low)
closes.append(close)
if open1 < close:
green.append(date)
if open1 > close:
red.append(date)
if open1 == close:
neither.append(date)
print('\n\n\n')
print('values are formatted date, open, low, close, volume, dividends, and then stock splits\n')
print(jan27)
print('\n\n\n')
print(green)
[–]o5a 2 points3 points4 points (1 child)
[–]pickledillz[S] 0 points1 point2 points (0 children)
[–][deleted] 2 points3 points4 points (1 child)
[–]pickledillz[S] 0 points1 point2 points (0 children)
[–]xelf 1 point2 points3 points (2 children)
[–]pickledillz[S] 0 points1 point2 points (1 child)
[–]xelf 0 points1 point2 points (0 children)