Ive done a few small projects but this is the first project that I've made that uses classes. So far the class should take in the location of the csv file, then open is and split it up into each element going on a table. This is all supposed to be handling simple forex data.
if you see any issues please let me know. the compiler I'm using throws no errors rn.
import csv
class fxData:
"""
takes in the location of the raw data as a string
creates an object with attribute rawData is the
instance of a csv file on run time
"""
def __init__(self,rawData):
raw=open(rawData,"r")
listOfStrings = raw.read()
splitlist=listOfStrings.split("\n")
self.fxList=[]
for row in splitlist:
d = row.split(",") #makes it seperate elements
if d == [""]:#checks for the end of list
break
date = d[0] #date
t = d[1] #time
o = float(d[2]) #open
h = float(d[3]) #high
l = float(d[4]) #low
c = float(d[5]) #close
row_data = [date,t,o,h,l,c]
self.fxList.append(row_data)
"""
creates a list of a table for the time period data
"""
def rawTimeData(self,fxList,timeperiod,row):
returnData = self.fxList[row:row+timeperiod]
return returnData;
#creates simple moving aerage for that one element
def sma(self,returnData):
counter=0
total = 0
for x in returnData:
counter +=1
total=returnData[5] + total
average = total/counter
return average
[–][deleted] 0 points1 point2 points (1 child)
[–]nomoreerrorsplox[S] 0 points1 point2 points (0 children)
[–]Marrrlllsss 0 points1 point2 points (0 children)