cmd_coveredcalls.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:options-screener 作者: dcwangmit01 项目源码 文件源码
def run(ctx, config_yaml, output_csv):
    """This command loads config.yaml and the current ENV-ironment,
    creates a single merged dict, and prints to stdout.
    """

    # read the configuration file
    c = app.get_config_dict(ctx, [config_yaml])

    # use cache to reduce web traffic
    session = requests_cache.CachedSession(
        cache_name='cache',
        backend='sqlite',
        expire_after=datetime.timedelta(days=days_to_cache))

    # all data will also be combined into one CSV
    all_df = None

    for ticker in c['config']['options']['covered_calls']:
        option = Options(ticker, 'yahoo', session=session)

        # fetch all data
        df = option.get_all_data()

        # process the data
        df = covered_calls_process_dataframe(df)

        # ensure the all_df (contains all data from all tickers)
        if all_df is None:
            all_df = df.copy(deep=True)
        else:
            all_df = all_df.append(df)

        # output the all_df, which contains all of the tickers
        covered_calls_csv_out(output_csv, all_df)


#####################################################################
# Functions
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号