Example #1
0
            data_source='bloomberg',  # use Bloomberg as data source
            tickers=tickers,  # ticker (Thalesians)
            fields=['close'],  # which fields to download
            vendor_tickers=vendor_tickers,  # ticker (Bloomberg)
            vendor_fields=['PX_LAST'],  # which Bloomberg fields to download
            cache_algo='internet_load_return')  # how to return data

        daily_vals = ltsf.harvest_time_series(time_series_request)

        pf = PlotFactory()

        gp = GraphProperties()

        gp.title = 'Spot values'
        gp.file_output = 'output_data/demo.png'
        gp.html_file_output = 'output_data/demo.htm'
        gp.source = 'Thalesians/BBG'

        # plot using PyThalesians
        pf.plot_line_graph(daily_vals, adapter='pythalesians', gp=gp)

        # plot using Bokeh (still needs a lot of work!)
        pf.plot_line_graph(daily_vals, adapter='bokeh', gp=gp)

    # do more complicated charts using several different Matplotib stylesheets (which have been customised)
    if False:
        ltsf = LightTimeSeriesFactory()

        # load market data
        start = '01 Jan 1970'
        end = datetime.datetime.utcnow()
                finish_date = datetime.date.today(),            # finish date
                freq = 'daily',                                 # daily data
                data_source = 'google',                         # use Bloomberg as data source
                tickers = ['Apple', 'S&P500 ETF'],                  # ticker (Thalesians)
                fields = ['close'],                                 # which fields to download
                vendor_tickers = ['aapl', 'spy'],                   # ticker (Google)
                vendor_fields = ['Close'],                          # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

    ltsf = LightTimeSeriesFactory()
    tsc = TimeSeriesCalcs()

    df = tsc.create_mult_index_from_prices(ltsf.harvest_time_series(time_series_request))

    gp = GraphProperties()
    gp.html_file_output = "output_data/apple.htm"
    gp.title = "S&P500 vs Apple"

    # plot first with PyThalesians and then Bokeh
    # just needs 1 word to change
    gp.display_legend = False

    pf = PlotFactory()
    pf.plot_generic_graph(df, type = 'line', adapter = 'pythalesians', gp = gp)
    pf.plot_generic_graph(df, type = 'line', adapter = 'bokeh', gp = gp)

# test simple Bokeh bar charts - monthly returns over past 6 months
if True:
    from datetime import timedelta
    ltsf = LightTimeSeriesFactory()
Example #3
0
        freq='daily',  # daily data
        data_source='google',  # use Bloomberg as data source
        tickers=['Apple', 'S&P500 ETF'],  # ticker (Thalesians)
        fields=['close'],  # which fields to download
        vendor_tickers=['aapl', 'spy'],  # ticker (Google)
        vendor_fields=['Close'],  # which Bloomberg fields to download
        cache_algo='internet_load_return')  # how to return data

    ltsf = LightTimeSeriesFactory()
    tsc = TimeSeriesCalcs()

    df = tsc.create_mult_index_from_prices(
        ltsf.harvest_time_series(time_series_request))

    gp = GraphProperties()
    gp.html_file_output = "output_data/apple.htm"
    gp.title = "S&P500 vs Apple"

    # plot first with PyThalesians and then Bokeh
    # just needs 1 word to change
    gp.display_legend = False

    pf = PlotFactory()
    pf.plot_generic_graph(df, type='line', adapter='pythalesians', gp=gp)
    pf.plot_generic_graph(df, type='line', adapter='bokeh', gp=gp)

# test simple Bokeh bar charts - monthly returns over past 6 months
if True:
    from datetime import timedelta
    ltsf = LightTimeSeriesFactory()
Example #4
0
                data_source = 'bloomberg',                      # use Bloomberg as data source
                tickers = tickers,                              # ticker (Thalesians)
                fields = ['close'],                             # which fields to download
                vendor_tickers = vendor_tickers,                # ticker (Bloomberg)
                vendor_fields = ['PX_LAST'],                    # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        daily_vals = ltsf.harvest_time_series(time_series_request)

        pf = PlotFactory()

        gp = GraphProperties()

        gp.title = 'Spot values'
        gp.file_output = 'demo.png'
        gp.html_file_output = 'demo.htm'
        gp.source = 'Thalesians/BBG'

        # plot using PyThalesians
        pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp)

        # plot using Bokeh (still needs a lot of work!)
        pf.plot_line_graph(daily_vals, adapter = 'bokeh', gp = gp)

    # do more complicated charts using several different Matplotib stylesheets (which have been customised)
    if True:
        ltsf = LightTimeSeriesFactory()

        # load market data
        start = '01 Jan 1970'
        end = datetime.datetime.utcnow()
            tickers=tickers,  # ticker (Thalesians)
            fields=["close"],  # which fields to download
            vendor_tickers=vendor_tickers,  # ticker (Bloomberg)
            vendor_fields=["PX_LAST"],  # which Bloomberg fields to download
            cache_algo="internet_load_return",
        )  # how to return data

        daily_vals = ltsf.harvest_time_series(time_series_request)

        pf = PlotFactory()

        gp = GraphProperties()

        gp.title = "Spot values"
        gp.file_output = "output_data/demo.png"
        gp.html_file_output = "output_data/demo.htm"
        gp.source = "Thalesians/BBG"

        # plot using PyThalesians
        pf.plot_line_graph(daily_vals, adapter="pythalesians", gp=gp)

        # plot using Bokeh (still needs a lot of work!)
        pf.plot_line_graph(daily_vals, adapter="bokeh", gp=gp)

    # do more complicated charts using several different Matplotib stylesheets (which have been customised)
    if False:
        ltsf = LightTimeSeriesFactory()

        # load market data
        start = "01 Jan 1970"
        end = datetime.datetime.utcnow()
if True:

    time_series_request = TimeSeriesRequest(
                start_date = "01 Jan 2013",                     # start date
                finish_date = datetime.date.today(),            # finish date
                freq = 'daily',                                 # daily data
                data_source = 'google',                         # use Bloomberg as data source
                tickers = ['Apple', 'S&P500 ETF'],                  # ticker (Thalesians)
                fields = ['close'],                                 # which fields to download
                vendor_tickers = ['aapl', 'spy'],                   # ticker (Google)
                vendor_fields = ['Close'],                          # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

    ltsf = LightTimeSeriesFactory()
    tsc = TimeSeriesCalcs()

    df = tsc.create_mult_index_from_prices(ltsf.harvest_time_series(time_series_request))

    gp = GraphProperties()
    gp.html_file_output = "apple.htm"
    gp.title = "S&P500 vs Apple"

    # plot first with PyThalesians and then Plotly (via Cufflinks)
    # just needs 1 word to change
    # (although, note that AdapterCufflinks does have some extra parameters that can be set in
    # GraphProperties)
    gp.display_legend = False

    pf = PlotFactory()
    pf.plot_generic_graph(df, type = 'line', adapter = 'pythalesians', gp = gp)
    pf.plot_generic_graph(df, type = 'line', adapter = 'bokeh', gp = gp)
                data_source = 'bloomberg',                      # use Bloomberg as data source
                tickers = tickers,                              # ticker (Thalesians)
                fields = ['close'],                             # which fields to download
                vendor_tickers = vendor_tickers,                # ticker (Bloomberg)
                vendor_fields = ['PX_LAST'],                    # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        daily_vals = ltsf.harvest_time_series(time_series_request)

        pf = PlotFactory()

        gp = GraphProperties()

        gp.title = 'Spot values'
        gp.file_output = 'output_data/demo.png'
        gp.html_file_output = 'output_data/demo.htm'
        gp.source = 'Thalesians/BBG'

        # plot using PyThalesians
        pf.plot_line_graph(daily_vals, adapter = 'pythalesians', gp = gp)

        # plot using Bokeh (still needs a lot of work!)
        pf.plot_line_graph(daily_vals, adapter = 'bokeh', gp = gp)

    # do more complicated charts using several different Matplotib stylesheets (which have been customised)
    if True:
        ltsf = LightTimeSeriesFactory()

        # load market data
        start = '01 Jan 1970'
        end = datetime.datetime.utcnow()