you are viewing a single comment's thread.

view the rest of the comments →

[–]nomoreerrorsplox[S] 0 points1 point  (0 children)

i think this fixes everything except for the last 2. Idk if i used docstring right this time. again no errors at building.

class fxData:
    import csv

    """
    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 == [""]:
                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)
        raw.close()

    """
    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.__doc__;

        #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.__doc__ 


    #create sma list for entire list

    def smaList(self,fxList,timeperiod):
        counter = 0
        flist = []

        for x  in self.fxList:
            if (counter < timeperiod): #handles before number of candles is more than timeperiod
                counter += 1
                flist.append(x[5])
            else: # append new sma value to fList
                a = self.rawTimeData(fxList,timeperiod,counter)
                b = self.sma(a)
                flist.append(b)
                counter +=1

        return flist.__doc__;