def main(): args = parse_args() redis = StrictRedis(host=args.redis_host, port=args.redis_port, db=args.redis_db) data_impl = get_authenticated_data_impl(args.ycharts_user, args.ycharts_pw) data_client = RedisMultiprocessingLimiter(data_impl, args.batch_poll_timeout, args.num_calls_per_batch, args.seconds_per_batch, args.redis_host, args.redis_port, args.redis_db, args.pool_size) # Just keep start/end date at None/None for now data = gather_data_with_multiprocess_client(data_client, args.ticker, args.time_length, None, None) push_to_redis(redis, data, args.ticker)
def main(): args = parse_args() redis = StrictRedis(host=args.redis_host, port=args.redis_port, db=args.redis_db) data_impl = get_authenticated_data_impl(args.ycharts_user, args.ycharts_pw) data_client = RedisMultiprocessingLimiter( data_impl, args.batch_poll_timeout, args.num_calls_per_batch, args.seconds_per_batch, args.redis_host, args.redis_port, args.redis_db, args.pool_size ) # Just keep start/end date at None/None for now data = gather_data_with_multiprocess_client( data_client, args.ticker, args.time_length, None, None ) push_to_redis(redis, data, args.ticker)
def post_initialize(context, data): """ Since `initialize` doesn't actually enable us to see the parameters of when our simulation is starting/ending we need to create a `post_initialize` func to handle gathering extra data from pytrader """ if context.sim_params.period_start == data[data.keys()[0]]["dt"]: redis = StrictRedis(host="localhost", port=6379, db=0) data_impl = get_authenticated_data_impl("*****@*****.**", getpass()) # Since we are currently using YCharts our data schema is a little weird start_date = context.sim_params.period_start.strftime("%Y-%m-%d") end_date = context.sim_params.period_end.strftime("%Y-%m-%d") for ticker in data.keys(): try: pytrader_data = pull_from_redis(redis, ticker, start_date, end_date) except RecordsNotFoundError: pytrader_data = gather_data_with_single_process_client(data_impl, ticker, None, start_date, end_date) push_to_redis(redis, pytrader_data, ticker) del pytrader_data["price"] # Delete the price col, we don't need it pytrader_data = calculate_diffs(pytrader_data) context.pytrader_data[ticker] = pytrader_data
def post_initialize(context, data): """ Since `initialize` doesn't actually enable us to see the parameters of when our simulation is starting/ending we need to create a `post_initialize` func to handle gathering extra data from pytrader """ if context.sim_params.period_start == data[data.keys()[0]]["dt"]: redis = StrictRedis(host="localhost", port=6379, db=0) data_impl = get_authenticated_data_impl("*****@*****.**", getpass()) # Since we are currently using YCharts our data schema is a little weird start_date = context.sim_params.period_start.strftime("%Y-%m-%d") end_date = context.sim_params.period_end.strftime("%Y-%m-%d") for ticker in data.keys(): try: pytrader_data = pull_from_redis(redis, ticker, start_date, end_date) except RecordsNotFoundError: pytrader_data = gather_data_with_single_process_client( data_impl, ticker, None, start_date, end_date) push_to_redis(redis, pytrader_data, ticker) del pytrader_data[ "price"] # Delete the price col, we don't need it pytrader_data = calculate_diffs(pytrader_data) context.pytrader_data[ticker] = pytrader_data