+ if report_path is not None and not \
+ os.path.exists(report_path):
+ os.makedirs(report_path)
+
+def parse_args(argv):
+ parser = configargparse.ArgumentParser(
+ description="Run the trade bot.")
+
+ parser.add_argument("-c", "--config",
+ default="config.ini",
+ required=False, is_config_file=True,
+ help="Config file to load (default: config.ini)")
+ parser.add_argument("--before",
+ default=False, action='store_const', const=True,
+ help="Run the steps before the cryptoportfolio update")
+ parser.add_argument("--after",
+ default=False, action='store_const', const=True,
+ help="Run the steps after the cryptoportfolio update")
+ parser.add_argument("--quiet",
+ default=False, action='store_const', const=True,
+ help="Don't print messages")
+ parser.add_argument("--debug",
+ default=False, action='store_const', const=True,
+ help="Run in debug mode")
+ parser.add_argument("--user",
+ default=None, required=False, help="Only run for that user")
+ parser.add_argument("--action",
+ action='append',
+ help="Do a different action than trading (add several times to chain)")
+ parser.add_argument("--parallel", action='store_true', default=True, dest="parallel")
+ parser.add_argument("--no-parallel", action='store_false', dest="parallel")
+ parser.add_argument("--report-db", action='store_true', default=True, dest="report_db",
+ help="Store report to database (default)")
+ parser.add_argument("--no-report-db", action='store_false', dest="report_db",
+ help="Don't store report to database")
+ parser.add_argument("--report-redis", action='store_true', default=False, dest="report_redis",
+ help="Store report to redis")
+ parser.add_argument("--no-report-redis", action='store_false', dest="report_redis",
+ help="Don't store report to redis (default)")
+ parser.add_argument("--report-path", required=False,
+ help="Where to store the reports (default: absent, don't store)")
+ parser.add_argument("--no-report-path", action='store_const', dest='report_path', const=None,
+ help="Don't store the report to file (default)")
+ parser.add_argument("--db-host", default="localhost",
+ help="Host access to database (default: localhost)")
+ parser.add_argument("--db-port", default=5432,
+ help="Port access to database (default: 5432)")
+ parser.add_argument("--db-user", default="cryptoportfolio",
+ help="User access to database (default: cryptoportfolio)")
+ parser.add_argument("--db-password", default="cryptoportfolio",
+ help="Password access to database (default: cryptoportfolio)")
+ parser.add_argument("--db-database", default="cryptoportfolio",
+ help="Database access to database (default: cryptoportfolio)")
+ parser.add_argument("--redis-host", default="localhost",
+ help="Host access to database (default: localhost). Use path for socket")
+ parser.add_argument("--redis-port", default=6379,
+ help="Port access to redis (default: 6379)")
+ parser.add_argument("--redis-database", default=0,
+ help="Redis database to use (default: 0)")
+
+ parsed = parser.parse_args(argv)
+ if parsed.action is None:
+ parsed.action = ["sell_all"]
+ return parsed
+
+def process(market_config, market_id, user_id, args):