当前位置: 首页>>代码示例>>Python>>正文


Python TimeSeriesCalcs.rolling_corr方法代码示例

本文整理汇总了Python中pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs.rolling_corr方法的典型用法代码示例。如果您正苦于以下问题:Python TimeSeriesCalcs.rolling_corr方法的具体用法?Python TimeSeriesCalcs.rolling_corr怎么用?Python TimeSeriesCalcs.rolling_corr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs的用法示例。


在下文中一共展示了TimeSeriesCalcs.rolling_corr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ticker

# 需要导入模块: from pythalesians.timeseries.calcs.timeseriescalcs import TimeSeriesCalcs [as 别名]
# 或者: from pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs import rolling_corr [as 别名]
                           'AUDUSD'],
                fields = ['close'],                             # which fields to download
                vendor_tickers = ['EURUSD BGN Curncy',          # ticker (Bloomberg)
                                  'GBPUSD BGN Curncy',
                                  'AUDUSD BGN Curncy'],
                vendor_fields = ['PX_LAST'],                    # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        ltsf = LightTimeSeriesFactory()

        df = None
        df = ltsf.harvest_time_series(time_series_request)

        tsc = TimeSeriesCalcs()
        df = tsc.calculate_returns(df)
        df = tsc.rolling_corr(df['EURUSD.close'], 20, data_frame2 = df[['GBPUSD.close', 'AUDUSD.close']])

        gp = GraphProperties()
        gp.title = "1M FX rolling correlations"
        gp.scale_factor = 3

        pf = PlotFactory()
        pf.plot_line_graph(df, adapter = 'pythalesians', gp = gp)

    ###### download daily data from Bloomberg for AUD/JPY, NZD/JPY spot with S&P500, then calculate correlation
    if True:
        time_series_request = TimeSeriesRequest(
                start_date="01 Jan 2015",  # start date
                finish_date=datetime.date.today(),  # finish date
                freq='daily',  # daily data
                data_source='bloomberg',  # use Bloomberg as data source
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:33,代码来源:correlation_examples.py

示例2: TimeSeriesRequest

# 需要导入模块: from pythalesians.timeseries.calcs.timeseriescalcs import TimeSeriesCalcs [as 别名]
# 或者: from pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs import rolling_corr [as 别名]
        time_series_request = TimeSeriesRequest(
                start_date = "01 Jan 2014",                     # start date
                finish_date = datetime.date.today(),            # finish date
                freq = 'daily',                                 # daily data
                data_source = 'bloomberg',                      # use Bloomberg as data source
                tickers = ['EURUSD',                            # ticker (Thalesians)
                           'GBPUSD',
                           'AUDUSD'],
                fields = ['close'],                             # which fields to download
                vendor_tickers = ['EURUSD BGN Curncy',          # ticker (Bloomberg)
                                  'GBPUSD BGN Curncy',
                                  'AUDUSD BGN Curncy'],
                vendor_fields = ['PX_LAST'],                    # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        ltsf = LightTimeSeriesFactory()

        df = None
        df = ltsf.harvest_time_series(time_series_request)

        tsc = TimeSeriesCalcs()
        df = tsc.calculate_returns(df)
        df = tsc.rolling_corr(df['EURUSD.close'], 20, data_frame2 = df[['GBPUSD.close', 'AUDUSD.close']])

        gp = GraphProperties()
        gp.title = "1M FX rolling correlations"

        pf = PlotFactory()
        pf.plot_line_graph(df, adapter = 'pythalesians', gp = gp)

开发者ID:swaraj007,项目名称:pythalesians,代码行数:31,代码来源:correlation_examples.py


注:本文中的pythalesians.timeseries.calcs.timeseriescalcs.TimeSeriesCalcs.rolling_corr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。