def print(ctx): """This command loads config.yaml and the current ENV-ironment, creates a single merged dict, and prints to stdout. """ c = app.get_config_dict(ctx) click.echo(utils.YamlUtils.yaml_dict_to_string(c))
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']['long_puts']: option = Options(ticker, 'yahoo', session=session) # fetch all data df = option.get_all_data() # process the data df = long_puts_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 long_puts_csv_out(output_csv, all_df)
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]) # get the client tda = TDAmeritrade() tdc = tda.getClient() # all data will also be combined into one CSV all_df = None for ticker in c['config']['options']['covered_calls']: # fetch all data stock = tdc.quoteDF(ticker) option = tdc.optionsDF(ticker) # process the data df = covered_calls_process_dataframe(stock, option) # 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)