def verify(fileName, todayIndex): tomorrowIndex = todayIndex + 1 global groupSize, predictSize, config if outputCharts == True: chart = chartprinter.new(fileName, tomorrowIndex, config.algo, groupSize, predictSize) else: chart = None data, headers = para.readFile(fileName) if tomorrowIndex - groupSize < 0: return None if tomorrowIndex + predictSize > len(data['Close']): return None getKnownData = getKnownFun(tomorrowIndex) getFutureData = getFutureFun(tomorrowIndex, predictSize) knownData = {} futureData = {} for key in data: knownData[key] = getKnownData(data[key]) futureData[key] = getFutureData(data[key]) defaultEarnings = getDefaultEarnings(futureData) strategy = decideStrategy(knownData, groupSize, predictSize, chart) if strategy == None: return (1, False, defaultEarnings) #dontTrade result, traded = applyStrategy(strategy, futureData) return (result, traded, defaultEarnings)
def predict(): global groupSize, predictSize, config fileName = 'chinasp.csv' todayIndex = 6230 chart = chartprinter.new(fileName, todayIndex, config.algo, predictSize) data, headers = para.readFile(fileName) getKnownData = getKnownFun(todayIndex) knownData = {} for key in data: knownData[key] = getKnownData(data[key]) strategy = decideStrategy(knownData, groupsize, predictSize, chart) if strategy == None: print("don't trade")