예제 #1
0
def importanceSampling_parallel4(generateSample,args_generateSample,likelihoodRatio,args_likelihoodRatio, N):  
    # not working
    temp = 3
    from IPython.parallel import Client
    p = Client()[:]
    p.use_dill()
    print('This is the parallel output')
    p.map_sync(generateSample,np.arange(6))
    #sample = p.map_sync(generateSample,np.array((10,)))
    #print(sample)
    return(1)
예제 #2
0
def main():
    """ Set up the parallel engine and the data space. Call the parallel engine, then write out the results """

    client = Client()[:]
    client.use_dill()
    client.execute("import furnace.performance, furnace.strategy, numpy, datetime")

    stock_percents = numpy.linspace(0.0, 0.4, 10)
    rebalancing_periods = numpy.arange(1, 40, 1)
    days_in = numpy.arange(1, 250, 1)
    begin = datetime.datetime(2003, 1, 2)
    end = datetime.datetime(2011, 12, 31)
    grid = list(itertools.product(stock_percents, rebalancing_periods, days_in))
    builder = function_builder(begin, end)
    results = client.map(builder, grid)

#TODO: does pandas have a plain 'save to csv' function?
    with open('data.csv', 'wb') as csvfile:
        writer = csv.writer(csvfile)
        writer.writerow(['days_out', 'pct', 'ndays', 'r2r', 'cagr', 'volatility', 'ntrades'])
        writer.writerows(results)