def get_testing_data():
    DATA_PATH = 'data/sp10/'
    ## specify testing data
    # get data for testing
    dateSelected, stockPrice = du.getData(DATA_PATH, 'week')
    # get testing data index
    TestTimeIndex = range(len(dateSelected) / 10 * 9, len(dateSelected))
    # get testing time period Date for estimating return (startDate, endDate)
    TestDate = [(dateSelected[i - 1][0], dateSelected[i][0])
                for i in TestTimeIndex]

    # get testing return
    stockReturn = du.logReturn(stockPrice)
    TestReturn = [stockReturn[i - 1] for i in TestTimeIndex]

    return TestDate, TestReturn, stockPrice, TestTimeIndex, dateSelected
import EigenPortfolio as ep
import oracle as oc
import math
import numpy as np
from utils import plotAndEval as pe
from utils import readin, yfReader, dataUtil as du
import bestStock as bs

#Re_ep, D, M= ep.main()

# get return from senarios other than baseline
#Re_oa = oa.main()
# note here the form of date is [('2014-11-05', 10), ('2014-11-12', 15), ('2014-11-19', 20), ...],
# different from what pe.plotEval() expects, but should still work
dateSelected, stockPrice = du.getData()
c = [0.001] * 10
c_0 = 0.001
startingFund = 10000
Time = range(len(stockPrice) / 3, len(stockPrice))
print stockPrice
'''
Re_oa = oa.solveOracle(stockPrice, startingFund,c, c_0)
Re_bs = bs.bestStock(stockPrice)
print len(Re_oa), len(Re_bs), len(dateSelected)
pe = pe.plotEval(dateSelected[:-1], 2014)
pe.addReturn(Re_oa, 'Oracle')
pe.addReturn(Re_bs, 'BestStock')
pe.generatePlot()
'''
'''
示例#3
0
            historicalData = logReturn_x[i*B:(i+1)*B]
            compareReturn = logReturn_x0[i*B:(i+1)*B]
            currentReturn = sess.run(reward, {x: historicalData, y_: compareReturn, previousPortfolio: PrePortfolio, previousReturn: PreReturn} )
            testReturn.append(currentReturn)
            test_accumulate = test_accumulate * (sess.run(-reward_minus, {x: historicalData,y_: compareReturn, previousPortfolio: PrePortfolio, previousReturn: PreReturn}))
            test_step.run(feed_dict={x: historicalData, y_: compareReturn, previousPortfolio: PrePortfolio, previousReturn: PreReturn})
            prePortfolio = sess.run(currentPortfolio,  {x: historicalData,y_: compareReturn,  previousPortfolio: PrePortfolio, previousReturn: PreReturn})
            preReturn = currentReturn
<<<<<<< HEAD
            
    return testReturn



# get data (date, stockPrice)
dateSelected, stockPrice = dataUtil.getData()
    
# get time for baseline estimation  
Time = range(len(dateSelected)/2,len(dateSelected)) 
=======

return testReturn


"""
# get data (date, stockPrice)
dateSelected, stockPrice = dataUtil.getData()

# get time for baseline estimation
Time = range(10+(len(dateSelected)-10)/2+1,len(dateSelected))
>>>>>>> 6b28f2aa0a7cf39b8b43dd38c302e5046d72d081
示例#4
0
epochs = 400
transCostParams = {'c': np.array([[c] for _ in range(D)]), 'c0': c}
baselineTransCostParams = np.zeros(D + 1) + c

# resultsDirectory = 'results/allresults/' + du.getCurrentTimestamp()
# os.mkdir(resultsDirectory)

# now call logger.info to log
# logger = du.setupLogger(resultsDirectory)
resultsDirectory = 'results/allresults/' + du.getCurrentTimestamp()
os.mkdir(resultsDirectory)
logger = du.setupLogger(resultsDirectory)
logger.info('results saved to ' + resultsDirectory)
## specify testing data
# get data for testing
dateSelected, stockPrice = du.getData(DATA_PATH, 'week', getAll=True)
# get testing data index
TestTimeIndex = range(len(dateSelected) / 10 * 9, len(dateSelected))
'''
TestIndex = [i-N-1 for i in TestTimeIndex]
ValidationIndex = range(TestIndex[0]/9*8, TestIndex[0])
TestDate = [(dateSelected[i-1][0],dateSelected[i][0]) for i in TestTimeIndex]
TrainIndex = range(TestIndex[0]/9*8)
'''
L = 4
# epochs and tolerance for training
epochs = 25
tol = 1e-7


def main():
transCostParams = {
'c': np.array([ [c] for _ in range(D) ]),
'c0': c
}
baselineTransCostParams = np.zeros(D + 1) + c

# resultsDirectory = 'results/allresults/' + du.getCurrentTimestamp()
# os.mkdir(resultsDirectory)

# now call logger.info to log
# logger = du.setupLogger(resultsDirectory)


## specify testing data
# get data for testing
dateSelected, stockPrice = du.getData(DATA_PATH, 'week')
# get testing data index
TestTimeIndex = range(len(dateSelected)/10*9, len(dateSelected))
# get testing time period Date for estimating return (startDate, endDate)
TestDate = [(dateSelected[i-1][0],dateSelected[i][0]) for i in TestTimeIndex]
<<<<<<< HEAD
TrainIndex = range(TestIndex[0]/9*8)
=======

resultsDirectory = 'results/allresults/' + du.getCurrentTimestamp()
os.mkdir(resultsDirectory)

# now call logger.info to log
logger = du.setupLogger(resultsDirectory)

>>>>>>> 78d807912e0887374959b8022e66aa5ee0eb5a6c