#!/usr/bin/env python import backtrader as bt from algo_base import * import importlib import json import boto3 prefix = '/opt/ml/' hyper_params_path = os.path.join(prefix, 'input/config/hyperparameters.json') with open(hyper_params_path, 'r') as f: config = json.load(f) algo_name=config['algo_name'] print("import:%s" % algo_name) if 's3' in config: try: s3_bucket=config['s3'] print("s3_bucket=%s" % s3_bucket) s3 = boto3.client('s3') s3.download_file(s3_bucket, algo_name+'/'+algo_name+'.py', '/opt/program/'+algo_name+'.py') except Exception as e: print(e) cls = getattr(importlib.import_module(algo_name), 'MyStrategy') print(cls) algo=AlgoStrategy(config,cls) algo.run()