Esempio n. 1
0
def loadFeatures(filepath, timewindow):
    
    filename = createPath(filepath, 'Timewindow Features', 'CSV', 'timewindowFeatures' + str(timewindow) + '.csv')
    f = csv.reader(open(filename))
    
    featuresList = []
    
    count = 0
    
    for line in f:
        if count > 0:
            day,price,ema,rsi,macd=line
            featuresList.append({'price': float(price),
                                'ema': float(ema),
                                'rsi': float(rsi),
                                'macd': float(macd)
                                })
        count += 1
        
    return featuresList
Esempio n. 2
0
def loadFeatures(filepath, timewindow):

    filename = createPath(filepath, 'Timewindow Features', 'CSV',
                          'timewindowFeatures' + str(timewindow) + '.csv')
    f = csv.reader(open(filename))

    featuresList = []

    count = 0

    for line in f:
        if count > 0:
            day, price, ema, rsi, macd = line
            featuresList.append({
                'price': float(price),
                'ema': float(ema),
                'rsi': float(rsi),
                'macd': float(macd)
            })
        count += 1

    return featuresList
Esempio n. 3
0
def loadModels(filepath, modelType):

    filename = createPath(filepath)
    f = csv.reader(open(filename))

    models = []

    count = 0

    for line in f:
        if count > 0:

            if modelType == "emaOnly":

                timewindow, constant, ema, R2, AIC = line
                models.append({
                    'timewindow': int(timewindow),
                    'constant': float(constant),
                    'ema': float(ema)
                })

            elif modelType == "mr":

                timewindow, constant, ema, rsi, macd, R2, AIC = line
                models.append({
                    'timewindow': int(timewindow),
                    'constant': float(constant),
                    'ema': float(ema),
                    'rsi': float(rsi),
                    'macd': float(macd)
                })

            elif modelType == "ga":

                timewindow = line[0].strip('"')
                constant = line[3].strip('"')
                ema = line[4].strip('"')
                rsi = line[5].strip('"')
                macd = line[6].strip('"')

                models.append({
                    'timewindow': int(float(timewindow)),
                    'constant': float(constant),
                    'ema': float(ema),
                    'rsi': float(rsi),
                    'macd': float(macd)
                })

            elif modelType == "coevolve":

                timewindow = line[1].strip('"')
                constant = line[6].strip('"')
                ema = line[7].strip('"')
                rsi = line[8].strip('"')
                macd = line[9].strip('"')

                models.append({
                    'timewindow': int(float(timewindow)),
                    'constant': float(constant),
                    'ema': float(ema),
                    'rsi': float(rsi),
                    'macd': float(macd)
                })
        count += 1

    return models
Esempio n. 4
0
def loadStock(ticker):
    path = createPath(ticker + '.csv')
    return loadFile(path)
Esempio n. 5
0
def loadModels(filepath, modelType):
    
    filename = createPath(filepath)
    f = csv.reader(open(filename))
    
    models = []
    
    count = 0
    
    for line in f:
        if count > 0:
            
            if modelType == "emaOnly":
            
                timewindow,constant,ema,R2,AIC=line
                models.append({'timewindow': int(timewindow),
                               'constant': float(constant),
                               'ema': float(ema)
                                    })
                
            elif modelType == "mr":
            
                timewindow,constant,ema,rsi, macd, R2,AIC=line
                models.append({'timewindow': int(timewindow),
                               'constant': float(constant),
                               'ema': float(ema),
                               'rsi': float(rsi),
                               'macd': float(macd)
                                    })
                
            elif modelType == "ga":
            
                timewindow = line[0].strip('"')
                constant = line[3].strip('"')
                ema = line[4].strip('"')
                rsi = line[5].strip('"')
                macd = line[6].strip('"')
                
                models.append({'timewindow': int(float(timewindow)),
                               'constant': float(constant),
                               'ema': float(ema),
                               'rsi': float(rsi),
                               'macd': float(macd)
                                    })
                
            elif modelType == "coevolve":
            
                timewindow = line[1].strip('"')
                constant = line[6].strip('"')
                ema = line[7].strip('"')
                rsi = line[8].strip('"')
                macd = line[9].strip('"')
                
                models.append({'timewindow': int(float(timewindow)),
                               'constant': float(constant),
                               'ema': float(ema),
                               'rsi': float(rsi),
                               'macd': float(macd)
                                    })    
        count += 1
        
    return models
Esempio n. 6
0
def loadStock(ticker):
    path = createPath(ticker + '.csv')
    return loadFile(path)