baseDir = '/Users/eugene/Downloads/Data/' # baseDir = '/Users/eugene/Downloads/marketQuotationData/' # 沪深300 上证50 中证500 instruments = [ '000300.SH', '000016.SH', '000905.SH', '002047.SZ', '600015.SH', '600674.SH', '000566.SZ' ] instrument = instruments[6] initCapital = 10000 #100000000.0 # 一亿 startYear = 2015 yearNum = 2 # startYear = 2014; yearNum = 3 # startYear = 2014; yearNum = 2 winK = 15 df = readWSDFile(baseDir, instrument, startYear, yearNum) print 'Day count:', len(df) # print df.head(5) dfi = readWSDIndexFile(baseDir, instrument, startYear, yearNum) X, y, actionDates = prepareData(df, dfi, win=winK) print np.shape(X), np.shape(actionDates), np.shape(y) print y normalizer = preprocessing.Normalizer().fit(X) # fit does nothing X_norm = normalizer.transform(X) gamma, C, score = optimizeSVM(X_norm, y, kFolds=10) print 'gamma=', gamma, 'C=', C, 'score=', score clf = svm.SVC(kernel='rbf', gamma=gamma, C=C) # clf = svm.SVC(kernel='rbf', gamma=0.125, C=0.125) # clf = svm.SVC(kernel='rbf', gamma=512, C=32768) # clf = svm.SVC(kernel='rbf', gamma=2048, C=32768)
''' def annualizedReturnRatioSingle(portfolio, C=100000.0, T=250.0, D=250.0): import math return math.pow(portfolio/C, D/T) - 1 baseDir = '/Users/eugene/Downloads/Data/' # baseDir = '/Users/eugene/Downloads/marketQuotationData/' # 沪深300 上证50 中证500 instruments = ['000300.SH', '000016.SH', '000905.SH'] instrument = instruments[2] initCapital = 100000000.0 # 一亿 startYear = 2015; yearNum = 1 # startYear = 2014; yearNum = 2 df = readWSDFile(baseDir, instrument, startYear, yearNum) print 'Day count:', len(df) # print df.head(5) dfi = readWSDIndexFile(baseDir, instrument, startYear, yearNum) X, y, actionDates = prepareData(df, dfi, win=16) print np.shape(X), np.shape(actionDates), np.shape(y); print y normalizer = preprocessing.Normalizer().fit(X) # fit does nothing X_norm = normalizer.transform(X) # gamma, C, score = optimizeSVM(X_norm, y, kFolds=10); print 'gamma=',gamma, 'C=',C, 'score=',score # clf = svm.SVC(kernel='rbf', gamma=0.125, C=0.125) clf = svm.SVC(kernel='rbf', gamma=512, C=32768) # clf = svm.SVC(kernel='rbf', gamma=2048, C=32768) # clf = svm.SVC(kernel='rbf', gamma=2048, C=32768) # clf = svm.SVC(kernel='rbf', gamma=0.125, C=0.125) # clf = svm.SVC(kernel='rbf', gamma=0.125, C=0.125)