]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/blobdiff - main.py
Add quiet flag for running
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git] / main.py
diff --git a/main.py b/main.py
index 856d449fc16cf94263c81ad45b11bcb406a12ce0..55981bf94d82c966aea93e3f89ea25a01cdb7c79 100644 (file)
--- a/main.py
+++ b/main.py
@@ -63,7 +63,8 @@ def make_order(market, value, currency, action="acquire",
 def get_user_market(config_path, user_id, debug=False):
     pg_config, report_path = parse_config(config_path)
     market_config = list(fetch_markets(pg_config, str(user_id)))[0][0]
-    return market.Market.from_config(market_config, debug=debug)
+    args = type('Args', (object,), { "debug": debug, "quiet": False })()
+    return market.Market.from_config(market_config, args, user_id=user_id, report_path=report_path)
 
 def fetch_markets(pg_config, user):
     connection = psycopg2.connect(**pg_config)
@@ -109,6 +110,9 @@ def parse_args(argv):
     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")
@@ -131,7 +135,7 @@ def parse_args(argv):
 def process(market_config, user_id, report_path, args):
     try:
         market.Market\
-                .from_config(market_config, debug=args.debug, user_id=user_id, report_path=report_path)\
+                .from_config(market_config, args, user_id=user_id, report_path=report_path)\
                 .process(args.action, before=args.before, after=args.after)
     except Exception as e:
         print("{}: {}".format(e.__class__.__name__, e))