• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python lighttimeseriesfactory.LightTimeSeriesFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中pythalesians.market.loaders.lighttimeseriesfactory.LightTimeSeriesFactory的典型用法代码示例。如果您正苦于以下问题:Python LightTimeSeriesFactory类的具体用法?Python LightTimeSeriesFactory怎么用?Python LightTimeSeriesFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: __init__

    def __init__(self):
        self.logger = LoggerManager().getLogger(__name__)

        self._all_econ_tickers = pandas.read_csv(Constants().all_econ_tickers)
        self._econ_country_codes = pandas.read_csv(Constants().econ_country_codes)
        self._econ_country_groups = pandas.read_csv(Constants().econ_country_groups)

        self.time_series_factory = LightTimeSeriesFactory()
开发者ID:swaraj007,项目名称:pythalesians,代码行数:8,代码来源:histecondatafactory.py


示例2: __init__

    def __init__(self):
        super(StrategyTemplate, self).__init__()
        self.logger = LoggerManager().getLogger(__name__)

        ##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
        self.tsfactory = LightTimeSeriesFactory()
        self.DUMP_CSV = 'output_data/'
        self.DUMP_PATH = 'output_data/' + datetime.date.today().strftime("%Y%m%d") + ' '
        self.FINAL_STRATEGY = 'Thalesians FX CTA'
        self.SCALE_FACTOR = 3
        
        return
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:12,代码来源:strategyfxcta_example.py


示例3: StrategyFXCTA_Example

class StrategyFXCTA_Example(StrategyTemplate):

    def __init__(self):
        super(StrategyTemplate, self).__init__()
        self.logger = LoggerManager().getLogger(__name__)

        ##### FILL IN WITH YOUR OWN PARAMETERS FOR display, dumping, TSF etc.
        self.tsfactory = LightTimeSeriesFactory()
        self.DUMP_CSV = 'output_data/'
        self.DUMP_PATH = 'output_data/' + datetime.date.today().strftime("%Y%m%d") + ' '
        self.FINAL_STRATEGY = 'Thalesians FX CTA'
        self.SCALE_FACTOR = 3
        
        return

    ###### Parameters and signal generations (need to be customised for every model)
    def fill_backtest_request(self):

        ##### FILL IN WITH YOUR OWN BACKTESTING PARAMETERS
        br = BacktestRequest()

        # get all asset data
        br.start_date = "04 Jan 1989"
        br.finish_date = datetime.datetime.utcnow()
        br.spot_tc_bp = 0.5
        br.ann_factor = 252

        br.plot_start = "01 Apr 2015"
        br.calc_stats = True
        br.write_csv = False
        br.plot_interim = True
        br.include_benchmark = True

        # have vol target for each signal
        br.signal_vol_adjust = True
        br.signal_vol_target = 0.1
        br.signal_vol_max_leverage = 5
        br.signal_vol_periods = 20
        br.signal_vol_obs_in_year = 252
        br.signal_vol_rebalance_freq = 'BM'
        br.signal_vol_resample_freq = None

        # have vol target for portfolio
        br.portfolio_vol_adjust = True
        br.portfolio_vol_target = 0.1
        br.portfolio_vol_max_leverage = 5
        br.portfolio_vol_periods = 20
        br.portfolio_vol_obs_in_year = 252
        br.portfolio_vol_rebalance_freq = 'BM'
        br.portfolio_vol_resample_freq = None

        # tech params
        br.tech_params.sma_period = 200

        return br

    def fill_assets(self):
        ##### FILL IN WITH YOUR ASSET DATA

        # for FX basket
        full_bkt    = ['EURUSD', 'USDJPY', 'GBPUSD', 'AUDUSD', 'USDCAD',
                       'NZDUSD', 'USDCHF', 'USDNOK', 'USDSEK']

        basket_dict = {}

        for i in range(0, len(full_bkt)):
            basket_dict[full_bkt[i]] = [full_bkt[i]]

        basket_dict['Thalesians FX CTA'] = full_bkt

        br = self.fill_backtest_request()

        self.logger.info("Loading asset data...")

        vendor_tickers = ['FRED/DEXUSEU', 'FRED/DEXJPUS', 'FRED/DEXUSUK', 'FRED/DEXUSAL', 'FRED/DEXCAUS',
                          'FRED/DEXUSNZ', 'FRED/DEXSZUS', 'FRED/DEXNOUS', 'FRED/DEXSDUS']

        time_series_request = TimeSeriesRequest(
                    start_date = br.start_date,                     # start date
                    finish_date = br.finish_date,                   # finish date
                    freq = 'daily',                                 # daily data
                    data_source = 'quandl',                         # use Quandl as data source
                    tickers = full_bkt,                             # ticker (Thalesians)
                    fields = ['close'],                                 # which fields to download
                    vendor_tickers = vendor_tickers,                    # ticker (Quandl)
                    vendor_fields = ['close'],                          # which Bloomberg fields to download
                    cache_algo = 'internet_load_return')                # how to return data

        asset_df = self.tsfactory.harvest_time_series(time_series_request)

        # signalling variables
        spot_df = asset_df
        spot_df2 = None

        return asset_df, spot_df, spot_df2, basket_dict

    def construct_signal(self, spot_df, spot_df2, tech_params, br):

        ##### FILL IN WITH YOUR OWN SIGNALS

#.........这里部分代码省略.........
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:101,代码来源:strategyfxcta_example.py


示例4: TimeSeriesRequest

###### calculate seasonal moves in EUR/USD and GBP/USD (using Quandl data)
if True:
    time_series_request = TimeSeriesRequest(
                start_date = "01 Jan 1970",                     # start date
                finish_date = datetime.date.today(),            # finish date
                freq = 'daily',                                 # daily data
                data_source = 'quandl',                         # use Quandl as data source
                tickers = ['EURUSD',                            # ticker (Thalesians)
                           'GBPUSD'],
                fields = ['close'],                                 # which fields to download
                vendor_tickers = ['FRED/DEXUSEU', 'FRED/DEXUSUK'],  # ticker (Quandl)
                vendor_fields = ['close'],                          # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

    ltsf = LightTimeSeriesFactory()

    df = ltsf.harvest_time_series(time_series_request)

    df_ret = tsc.calculate_returns(df)

    day_of_month_seasonality = seasonality.bus_day_of_month_seasonality(df_ret, partition_by_month = False)
    day_of_month_seasonality = tsc.convert_month_day_to_date_time(day_of_month_seasonality)

    gp = GraphProperties()
    gp.date_formatter = '%b'
    gp.title = 'FX spot moves by time of year'
    gp.scale_factor = 3
    gp.file_output = "output_data/20150724 FX spot seas.png"

    pf.plot_line_graph(day_of_month_seasonality, adapter='pythalesians', gp = gp)
开发者ID:humdings,项目名称:pythalesians,代码行数:30,代码来源:seasonality_examples.py


示例5: TimeSeriesRequest

# just change "False" to "True" to run any of the below examples

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 = "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)
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:30,代码来源:bokeh_examples.py


示例6: TimeSeriesRequest

    import datetime

    time_series_request = TimeSeriesRequest(
        start_date="01 Jan 1970",  # start date
        finish_date=datetime.date.today(),  # finish date
        freq='daily',  # daily data
        data_source='quandl',  # use Quandl as data source
        tickers=['EURUSD',  # ticker (Thalesians)
                 'GBPUSD'],
        fields=['close'],  # which fields to download
        vendor_tickers=['FRED/DEXUSEU', 'FRED/DEXUSUK'],  # ticker (Quandl)
        vendor_fields=['close'],  # which Bloomberg fields to download
        cache_algo='internet_load_return')  # how to return data

    ltsf = LightTimeSeriesFactory()

    daily_vals = ltsf.harvest_time_series(time_series_request)

    techind = TechIndicator()
    tech_params = TechParams()
    tech_params.sma_period = 20

    techind.create_tech_ind(daily_vals, 'SMA', tech_params=tech_params)

    sma = techind.get_techind()
    signal = techind.get_signal()

    combine = daily_vals.join(sma, how='outer')

    pf = PlotFactory()
开发者ID:NunoEdgarGub1,项目名称:pythalesians,代码行数:30,代码来源:techindicator_examples.py


示例7: LightTimeSeriesFactory

                                  'AUDUSD BGN Curncy'],
                vendor_fields = ['PX_LAST'],   # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        # tickers for overnight deposit data, which is necessary for computing total return indices
        time_series_request_deposit = copy.copy(time_series_request_spot)
        time_series_request_deposit.tickers = ['EURON', 'USDON', 'GBPON', 'AUDON']
        time_series_request_deposit.vendor_tickers = ['EUDR1T CMPN Curncy', 'USDR1T CMPN Curncy',
                                                      'BPDR1T CMPN Curncy', 'ADDR1T CMPN Curncy']

        # tickers for getting total return indices from Bloomberg directly
        time_series_request_total_ret = copy.copy(time_series_request_spot)
        time_series_request_total_ret.tickers = ['EURUSD', 'GBPUSD', 'AUDUSD']
        time_series_request_total_ret.vendor_tickers = ['EURUSDCR BGN Curncy', 'GBPUSDCR BGN Curncy', 'AUDUSDCR BGN Curncy']

        ltsf = LightTimeSeriesFactory()

        df = None
        spot_df = ltsf.harvest_time_series(time_series_request_spot)
        deposit_df = ltsf.harvest_time_series(time_series_request_deposit)

        deposit_df = deposit_df.fillna(method = 'ffill')
        deposit_df = deposit_df.fillna(method = 'bfill') # bit of a hack - because some deposit data sparse
        tot_df = ltsf.harvest_time_series(time_series_request_total_ret)
        tsc = TimeSeriesCalcs()

        tot_df = tsc.create_mult_index_from_prices(tot_df) # rebase index at 100

        # we can change the
        tenor = 'ON'
开发者ID:hedgefair,项目名称:pythalesians,代码行数:30,代码来源:indicesfx_examples.py


示例8: timedelta

        start_date = finish_date - timedelta(days=60)

        # fetch NFP times from Bloomberg
        time_series_request = TimeSeriesRequest(
                start_date = start_date,                # start date
                finish_date = finish_date,              # finish date
                category = "events",
                freq = 'daily',                         # daily data
                data_source = 'bloomberg',              # use Bloomberg as data source
                tickers = ['NFP'],
                fields = ['release-date-time-full'],                    # which fields to download
                vendor_tickers = ['NFP TCH Index'], # ticker (Bloomberg)
                vendor_fields = ['ECO_FUTURE_RELEASE_DATE_LIST'],   # which Bloomberg fields to download
                cache_algo = 'internet_load_return')                # how to return data

        ltsf = LightTimeSeriesFactory()
        ts_filter = TimeSeriesFilter()

        df_event_times = ltsf.harvest_time_series(time_series_request)

        utc_time = pytz.utc
        df_event_times = pandas.DataFrame(index = df_event_times['NFP.release-date-time-full'])
        df_event_times.index = df_event_times.index.tz_localize(utc_time)    # work in UTC time
        df_event_times = ts_filter.filter_time_series_by_date(start_date, finish_date, df_event_times)

        # get last NFP time
        start_date = df_event_times.index[-1] - timedelta(minutes=1)
        finish_date = start_date + timedelta(minutes=4)

        tickers = ['EURUSD', 'JPYUSD', 'GBPUSD']
        vendor_tickers = ['EURUSD BGN Curncy', 'USDJPY BGN Curncy', 'GBPUSD BGN Curncy']
开发者ID:NunoEdgarGub1,项目名称:pythalesians,代码行数:31,代码来源:tick_examples.py


示例9: ticker

                    finish_date = datetime.date.today(),            # finish date
                    freq = 'daily',                                 # daily data
                    data_source = 'bloomberg',                      # use Bloomberg as data source
                    tickers = ['EURUSD',                            # ticker (Thalesians)
                               'GBPUSD',
                               'USDJPY',
                               'AUDUSD'],
                    fields = ['close', 'high', 'low'],              # which fields to download
                    vendor_tickers = ['EURUSD BGN Curncy',          # ticker (Bloomberg)
                                      'GBPUSD BGN Curncy',
                                      'USDJPY BGN Curncy',
                                      'AUDUSD BGN Curncy'],
                    vendor_fields = ['PX_LAST', 'PX_HIGH', 'PX_LOW'],   # which Bloomberg fields to download
                    cache_algo = 'internet_load_return')                # how to return data

            ltsf = LightTimeSeriesFactory()

            from pythalesians.util.constants import Constants

            # use different thread numbers, thread and multiprocessor Python libraries
            # note that speed of download depends on many factors, such as length of time series
            # so not always quickest to use threading!
            thread_no = [1,2,3,4]

            thread_technique = ["thread", "multiprocessor"]
            diag = []

            for tech in thread_technique:
                # change the static variable in Constants which govern the threading we use
                Constants.time_series_factory_thread_technique = tech
开发者ID:BryanFletcher,项目名称:pythalesians,代码行数:30,代码来源:paralleldata_examples.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python timeseriescalcs.TimeSeriesCalcs类代码示例发布时间:2022-05-27
下一篇:
Python plotfactory.PlotFactory类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap