예제 #1
0
if __name__ == '__main__':
    from pyalgotrade import bar, plotter
    import utility.windutility as wu
    from utility import dataframefeed
    from pyalgotrade.stratanalyzer import returns

    strat = singleMA
    instrument = '000001.SH'
    fromDate = '20160101'
    toDate = '20160727'
    frequency = bar.Frequency.MINUTE
    paras = [19]
    plot = True

    data = wu.wsi(instrument, 'open, high, low, close, volume', fromDate,
                  toDate)
    # data['adjclose'] = data['close'] * data['adjfactor'] / data['adjfactor'][-1]
    feed = dataframefeed.Feed()
    feed.addBarsFromDataFrame(instrument, data)

    strat = strat(feed, instrument, *paras)

    returnsAnalyzer = returns.Returns()
    strat.attachAnalyzer(returnsAnalyzer)

    if plot:
        # plt = plotter.StrategyPlotter(strat, True, True, True)
        # ma = strat.getMA()
        # plt.getInstrumentSubplot('indicator').addDataSeries('ma', ma)
        plt = plotter.StrategyPlotter(strat)
        # plt.getInstrumentSubplot(instrument).addDataSeries('ma', strat.getMA())
예제 #2
0
import utility.windutility as wu

indexPrice = wu.wsi('000905.SH', 'close', '2016-06-22', '2016-06-23 11:01:00')
futurePrice = wu.wsi('IC1609.CFE', 'close', '2016-06-22', '2016-06-23 11:01:00')
basis = futurePrice - indexPrice
# basis.plot()
futurePrice1 = wu.wsi('IC1607.CFE', 'close', '2016-06-22', '2016-06-23 11:01:00')
futurebasis = futurePrice - futurePrice1
futurebasis.plot()
예제 #3
0
if __name__ == '__main__':
    from pyalgotrade import bar, plotter
    import utility.windutility as wu
    from utility import dataframefeed
    from pyalgotrade.stratanalyzer import returns

    strat = singleMA
    instrument = '000001.SH'
    fromDate = '20160101'
    toDate = '20160727'
    frequency = bar.Frequency.MINUTE
    paras = [19]
    plot = True

    data = wu.wsi(instrument, 'open, high, low, close, volume', fromDate, toDate)
    # data['adjclose'] = data['close'] * data['adjfactor'] / data['adjfactor'][-1]
    feed = dataframefeed.Feed()
    feed.addBarsFromDataFrame(instrument, data)

    strat = strat(feed, instrument, *paras)

    returnsAnalyzer = returns.Returns()
    strat.attachAnalyzer(returnsAnalyzer)

    if plot:
        # plt = plotter.StrategyPlotter(strat, True, True, True)
        # ma = strat.getMA()
        # plt.getInstrumentSubplot('indicator').addDataSeries('ma', ma)
        plt = plotter.StrategyPlotter(strat)
        # plt.getInstrumentSubplot(instrument).addDataSeries('ma', strat.getMA())