Beispiel #1
0
from zipline.data import load_from_yahoo
d = load_from_yahoo(stocks=['AAPL'], start="2015/09/01", end="2015/10/10")
print(d)
Beispiel #2
0
    

    plt.show()
if __name__ == '__main__':
    from datetime import datetime
    import pytz
    from zipline.algorithm import TradingAlgorithm
    from zipline.utils.factory import load_from_yahoo

    # Set the simulation start and end dates.
    start = datetime(2005, 11, 14, 0, 0, 0, 0, pytz.utc)
    end = datetime(2013, 10, 14, 0, 0, 0, 0, pytz.utc)

    # Load price data from yahoo.

    data = load_from_yahoo(stocks=['AAPL', 'AXP', 'BA', 'CAT', 'CSCO', 'CVX', 'DD', 'DIS', 'GE', 'GS', 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'KO', 'MCD', 'MMM', 'MRK', 'MSFT', 'NKE', 'PFE', 'PG', 'TRV', 'UNH', 'UTX', 'V', 'VZ', 'WMT', 'XOM'], indexes={}, start=start,
                           end=end)
    
    benchmarks = get_benchmark_returns("^DJI", start, end)
    
    data.bench = benchmarks
    end2 = datetime(2013, 10, 14, 0, 0, 0, 0, pytz.utc)
    start2 = datetime(2007, 5, 07, 0, 0, 0, 0, pytz.utc)

    dw= web.DataReader("^GSPC", "yahoo", start=start2, end = end2)
    data.dowJones = dw
    
    # Create and run the algorithm.
    algo = TradingAlgorithm(initialize=initialize, handle_data=handle_data,
                            identifiers=['AAPL', 'AXP', 'BA', 'CAT', 'CSCO', 'CVX', 'DD', 'DIS', 'GE', 'GS', 'HD', 'IBM', 'INTC', 'JNJ', 'JPM', 'KO', 'MCD', 'MMM', 'MRK', 'MSFT', 'NKE', 'PFE', 'PG', 'TRV', 'UNH', 'UTX', 'V', 'VZ', 'WMT', 'XOM'])