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

Python paths.data_path函数代码示例

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

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



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

示例1: most_recent_data

    def most_recent_data(bundle_name, timestamp, environ=None):
        """Get the path to the most recent data after ``date``for the
        given bundle.

        Parameters
        ----------
        bundle_name : str
            The name of the bundle to lookup.
        timestamp : datetime
            The timestamp to begin searching on or before.
        environ : dict, optional
            An environment dict to forward to zipline_root.
        """
        if bundle_name not in bundles:
            raise UnknownBundle(bundle_name)

        try:
            candidates = os.listdir(pth.data_path([bundle_name], environ=environ))
            return pth.data_path(
                [bundle_name, max(filter(complement(pth.hidden), candidates), key=from_bundle_ingest_dirname)],
                environ=environ,
            )
        except (ValueError, OSError) as e:
            if getattr(e, "errno", ~errno.ENOENT) != errno.ENOENT:
                raise
            raise ValueError("no data for bundle %r on or before %s" % (bundle_name, timestamp))
开发者ID:umuzungu,项目名称:zipline,代码行数:26,代码来源:core.py


示例2: _list_bundle

 def _list_bundle(self):
     return {
         os.path.join(pth.data_path(['bundle', d], environ=self.environ))
         for d in os.listdir(
             pth.data_path(['bundle'], environ=self.environ),
         )
     }
开发者ID:nathanwolfe,项目名称:zipline-minute-bars,代码行数:7,代码来源:test_core.py


示例3: ingestions_for_bundle

def ingestions_for_bundle(bundle, environ=None):
    return sorted(
        (from_bundle_ingest_dirname(ing)
         for ing in os.listdir(pth.data_path([bundle], environ))
         if not pth.hidden(ing)),
        reverse=True,
    )
开发者ID:SJCosgrove,项目名称:quantopianresearch,代码行数:7,代码来源:core.py


示例4: bundles

def bundles():
    """List all of the available data bundles.
    """
    for bundle in sorted(bundles_module.bundles.keys()):
        try:
            ingestions = sorted(
                (str(bundles_module.from_bundle_ingest_dirname(ing))
                 for ing in os.listdir(pth.data_path([bundle]))
                 if not pth.hidden(ing)),
                reverse=True,
            )
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise
            ingestions = []

        # If we got no ingestions, either because the directory didn't exist or
        # because there were no entries, print a single message indicating that
        # no ingestions have yet been made.
        for timestamp in ingestions or ["<no ingestions>"]:
            print("%s %s" % (bundle, timestamp))
开发者ID:Ericlafevers,项目名称:zipline,代码行数:21,代码来源:__main__.py


示例5: bundles

def bundles():
    """List all of the available data bundles.
    """
    for bundle in sorted(bundles_module.bundles.keys()):
        try:
            ingestions = sorted(
                (str(bundles_module.from_bundle_ingest_dirname(ing))
                 for ing in os.listdir(pth.data_path([bundle]))
                 if not pth.hidden(ing)),
                reverse=True,
            )
        except IOError as e:
            if e.errno != errno.ENOENT:
                raise
            ingestions = []

        print(
            '\n'.join(
                '%s %s' % (bundle, line)
                for line in (
                    ingestions if ingestions else ('<no ingestions>',)
                )
            ),
        )
开发者ID:LukeeeeBennett,项目名称:zipline,代码行数:24,代码来源:__main__.py


示例6: adjustment_db_path

def adjustment_db_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        adjustment_db_relative(bundle_name, timestr, environ),
        environ=environ,
    )
开发者ID:RoyHsiao,项目名称:zipline,代码行数:5,代码来源:core.py


示例7: daily_equity_path

def daily_equity_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        daily_equity_relative(bundle_name, timestr, environ),
        environ=environ,
    )
开发者ID:RoyHsiao,项目名称:zipline,代码行数:5,代码来源:core.py


示例8: clean

    def clean(name,
              before=None,
              after=None,
              keep_last=None,
              environ=os.environ):
        """Clean up data that was created with ``ingest`` or
        ``$ python -m zipline ingest``

        Parameters
        ----------
        name : str
            The name of the bundle to remove data for.
        before : datetime, optional
            Remove data ingested before this date.
            This argument is mutually exclusive with: keep_last
        after : datetime, optional
            Remove data ingested after this date.
            This argument is mutually exclusive with: keep_last
        keep_last : int, optional
            Remove all but the last ``keep_last`` ingestions.
            This argument is mutually exclusive with:
              before
              after
        environ : mapping, optional
            The environment variables. Defaults of os.environ.

        Returns
        -------
        cleaned : set[str]
            The names of the runs that were removed.

        Raises
        ------
        BadClean
            Raised when ``before`` and or ``after`` are passed with
            ``keep_last``. This is a subclass of ``ValueError``.
        """
        try:
            all_runs = sorted(
                filter(
                    complement(pth.hidden),
                    os.listdir(pth.data_path([name], environ=environ)),
                ),
                key=from_bundle_ingest_dirname,
            )
        except OSError as e:
            if e.errno != errno.ENOENT:
                raise
            raise UnknownBundle(name)
        if ((before is not None or after is not None) and
                keep_last is not None):
            raise BadClean(before, after, keep_last)

        if keep_last is None:
            def should_clean(name):
                dt = from_bundle_ingest_dirname(name)
                return (
                    (before is not None and dt < before) or
                    (after is not None and dt > after)
                )

        else:
            last_n_dts = set(all_runs[-keep_last:])

            def should_clean(name):
                return name not in last_n_dts

        cleaned = set()
        for run in all_runs:
            if should_clean(run):
                path = pth.data_path([name, run], environ=environ)
                shutil.rmtree(path)
                cleaned.add(path)

        return cleaned
开发者ID:RoyHsiao,项目名称:zipline,代码行数:75,代码来源:core.py


示例9: ingest

    def ingest(name,
               environ=os.environ,
               timestamp=None,
               show_progress=False):
        """Ingest data for a given bundle.

        Parameters
        ----------
        name : str
            The name of the bundle.
        environ : mapping, optional
            The environment variables. By default this is os.environ.
        timestamp : datetime, optional
            The timestamp to use for the load.
            By default this is the current time.
        show_progress : bool, optional
            Tell the ingest function to display the progress where possible.
        """
        try:
            bundle = bundles[name]
        except KeyError:
            raise UnknownBundle(name)

        if timestamp is None:
            timestamp = pd.Timestamp.utcnow()
        timestamp = timestamp.tz_convert('utc').tz_localize(None)
        timestr = to_bundle_ingest_dirname(timestamp)
        cachepath = cache_path(name, environ=environ)
        pth.ensure_directory(pth.data_path([name, timestr], environ=environ))
        pth.ensure_directory(cachepath)
        with dataframe_cache(cachepath, clean_on_failure=False) as cache, \
                ExitStack() as stack:
            # we use `cleanup_on_failure=False` so that we don't purge the
            # cache directory if the load fails in the middle
            if bundle.create_writers:
                wd = stack.enter_context(working_dir(
                    pth.data_path([], environ=environ))
                )
                daily_bars_path = wd.ensure_dir(
                    *daily_equity_relative(
                        name, timestr, environ=environ,
                    )
                )
                daily_bar_writer = BcolzDailyBarWriter(
                    daily_bars_path,
                    nyse_cal,
                    bundle.calendar[0],
                    bundle.calendar[-1]
                )
                # Do an empty write to ensure that the daily ctables exist
                # when we create the SQLiteAdjustmentWriter below. The
                # SQLiteAdjustmentWriter needs to open the daily ctables so
                # that it can compute the adjustment ratios for the dividends.

                daily_bar_writer.write(())
                minute_bar_writer = BcolzMinuteBarWriter(
                    bundle.calendar[0],
                    wd.ensure_dir(*minute_equity_relative(
                        name, timestr, environ=environ)
                    ),
                    bundle.opens,
                    bundle.closes,
                    minutes_per_day=bundle.minutes_per_day,
                )
                asset_db_writer = AssetDBWriter(
                    wd.getpath(*asset_db_relative(
                        name, timestr, environ=environ,
                    ))
                )

                adjustment_db_writer = stack.enter_context(
                    SQLiteAdjustmentWriter(
                        wd.getpath(*adjustment_db_relative(
                            name, timestr, environ=environ)),
                        BcolzDailyBarReader(daily_bars_path),
                        bundle.calendar,
                        overwrite=True,
                    )
                )
            else:
                daily_bar_writer = None
                minute_bar_writer = None
                asset_db_writer = None
                adjustment_db_writer = None
            bundle.ingest(
                environ,
                asset_db_writer,
                minute_bar_writer,
                daily_bar_writer,
                adjustment_db_writer,
                bundle.calendar,
                cache,
                show_progress,
                pth.data_path([name, timestr], environ=environ),
            )
开发者ID:RoyHsiao,项目名称:zipline,代码行数:95,代码来源:core.py


示例10: cache_path

def cache_path(bundle_name, environ=None):
    return pth.data_path(
        [bundle_name, '.cache'],
        environ=environ,
    )
开发者ID:JasonGiedymin,项目名称:zipline,代码行数:5,代码来源:core.py


示例11: daily_equity_path

def daily_equity_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        [bundle_name, timestr, 'daily_equities.bcolz'],
        environ=environ,
    )
开发者ID:JasonGiedymin,项目名称:zipline,代码行数:5,代码来源:core.py


示例12: asset_db_path

def asset_db_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        [bundle_name, timestr, 'assets-%d.sqlite' % ASSET_DB_VERSION],
        environ=environ,
    )
开发者ID:JasonGiedymin,项目名称:zipline,代码行数:5,代码来源:core.py


示例13: asset_db_path

def asset_db_path(bundle_name, timestr, environ=None, db_version=None):
    return pth.data_path(
        asset_db_relative(bundle_name, timestr, environ, db_version),
        environ=environ,
    )
开发者ID:SJCosgrove,项目名称:quantopianresearch,代码行数:5,代码来源:core.py


示例14: ingest

    def ingest(name,
               environ=os.environ,
               timestamp=None,
               assets_versions=(),
               show_progress=False):
        """Ingest data for a given bundle.

        Parameters
        ----------
        name : str
            The name of the bundle.
        environ : mapping, optional
            The environment variables. By default this is os.environ.
        timestamp : datetime, optional
            The timestamp to use for the load.
            By default this is the current time.
        assets_versions : Iterable[int], optional
            Versions of the assets db to which to downgrade.
        show_progress : bool, optional
            Tell the ingest function to display the progress where possible.
        """
        try:
            bundle = bundles[name]
        except KeyError:
            raise UnknownBundle(name)

        calendar = get_calendar(bundle.calendar_name)

        start_session = bundle.start_session
        end_session = bundle.end_session

        if start_session is None or start_session < calendar.first_session:
            start_session = calendar.first_session

        if end_session is None or end_session > calendar.last_session:
            end_session = calendar.last_session

        if timestamp is None:
            timestamp = pd.Timestamp.utcnow()
        timestamp = timestamp.tz_convert('utc').tz_localize(None)

        timestr = to_bundle_ingest_dirname(timestamp)
        cachepath = cache_path(name, environ=environ)
        pth.ensure_directory(pth.data_path([name, timestr], environ=environ))
        pth.ensure_directory(cachepath)
        with dataframe_cache(cachepath, clean_on_failure=False) as cache, \
                ExitStack() as stack:
            # we use `cleanup_on_failure=False` so that we don't purge the
            # cache directory if the load fails in the middle
            if bundle.create_writers:
                wd = stack.enter_context(working_dir(
                    pth.data_path([], environ=environ))
                )
                daily_bars_path = wd.ensure_dir(
                    *daily_equity_relative(
                        name, timestr, environ=environ,
                    )
                )
                daily_bar_writer = BcolzDailyBarWriter(
                    daily_bars_path,
                    calendar,
                    start_session,
                    end_session,
                )
                # Do an empty write to ensure that the daily ctables exist
                # when we create the SQLiteAdjustmentWriter below. The
                # SQLiteAdjustmentWriter needs to open the daily ctables so
                # that it can compute the adjustment ratios for the dividends.

                daily_bar_writer.write(())
                minute_bar_writer = BcolzMinuteBarWriter(
                    wd.ensure_dir(*minute_equity_relative(
                        name, timestr, environ=environ)
                    ),
                    calendar,
                    start_session,
                    end_session,
                    minutes_per_day=bundle.minutes_per_day,
                )
                assets_db_path = wd.getpath(*asset_db_relative(
                    name, timestr, environ=environ,
                ))
                asset_db_writer = AssetDBWriter(assets_db_path)

                adjustment_db_writer = stack.enter_context(
                    SQLiteAdjustmentWriter(
                        wd.getpath(*adjustment_db_relative(
                            name, timestr, environ=environ)),
                        BcolzDailyBarReader(daily_bars_path),
                        calendar.all_sessions,
                        overwrite=True,
                    )
                )
            else:
                daily_bar_writer = None
                minute_bar_writer = None
                asset_db_writer = None
                adjustment_db_writer = None
                if assets_versions:
                    raise ValueError('Need to ingest a bundle that creates '
#.........这里部分代码省略.........
开发者ID:SJCosgrove,项目名称:quantopianresearch,代码行数:101,代码来源:core.py


示例15: fundamental_db_path

def fundamental_db_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        fundamental_db_releative(bundle_name, timestr, environ),
        environ=environ,
    )
开发者ID:huangzhengyong,项目名称:zipline,代码行数:5,代码来源:core.py


示例16: cache_path

def cache_path(bundle_name, environ=None):
    return pth.data_path(
        cache_relative(bundle_name, environ),
        environ=environ,
    )
开发者ID:RoyHsiao,项目名称:zipline,代码行数:5,代码来源:core.py


示例17: adjustment_db_path

def adjustment_db_path(bundle_name, timestr, environ=None):
    return pth.data_path(
        [bundle_name, timestr, 'adjustments.sqlite'],
        environ=environ,
    )
开发者ID:JasonGiedymin,项目名称:zipline,代码行数:5,代码来源:core.py


示例18: minute_equity_path

def minute_equity_path(bundle_name, timestr, environ=None):
    return pth.data_path([bundle_name, timestr, "minute_equities.bcolz"], environ=environ)
开发者ID:umuzungu,项目名称:zipline,代码行数:2,代码来源:core.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python preprocess.preprocess函数代码示例发布时间:2022-05-26
下一篇:
Python math_utils.tolerant_equals函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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