From: Ismaƫl Bouya Date: Mon, 22 Jan 2018 00:03:38 +0000 (+0100) Subject: Add debug mode parameter rather than global flag X-Git-Tag: v0.1~33 X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FProjets%2FCryptomonnaies%2FCryptoportfolio%2FTrader.git;a=commitdiff_plain;h=643767f141505c5e62dbaa402ac84a7b0c5511f2 Add debug mode parameter rather than global flag --- diff --git a/portfolio.py b/portfolio.py index acb61b2..946a96a 100644 --- a/portfolio.py +++ b/portfolio.py @@ -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: