]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Trader.git/commitdiff
Add debug mode parameter rather than global flag
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 22 Jan 2018 00:03:38 +0000 (01:03 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Mon, 22 Jan 2018 00:03:38 +0000 (01:03 +0100)
portfolio.py

index acb61b24623dec2e07019a2e1ab102a77dec11f5..946a96abdafd8e23be5b799acbfbc2fc3a55d504 100644 (file)
@@ -4,8 +4,6 @@ from decimal import Decimal as D
 # Put your poloniex api key in market.py
 from market import market
 
-debug = False
-
 class Portfolio:
     URL = "https://cryptoportfolio.io/wp-content/uploads/portfolio/json/cryptoportfolio.json"
     liquidities = {}
@@ -408,7 +406,6 @@ class Trade:
                 self.action)
 
 class Order:
-    DEBUG = debug
 
     def __init__(self, action, amount, rate, base_currency, market):
         self.action = action
@@ -436,11 +433,11 @@ class Order:
     def finished(self):
         return self.status == "closed" or self.status == "canceled"
 
-    def run(self):
+    def run(self, debug=False):
         symbol = "{}/{}".format(self.amount.currency, self.base_currency)
         amount = self.amount.value
 
-        if self.DEBUG:
+        if debug:
             print("market.create_order('{}', 'limit', '{}', {}, price={})".format(
                 symbol, self.action, amount, self.rate))
         else: