aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-22 01:03:38 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2018-01-22 01:03:38 +0100
commit643767f141505c5e62dbaa402ac84a7b0c5511f2 (patch)
tree0c51f5614878964f22c3513a2ed81cf967f780eb
parenta9950fd073198f3c9dc938fd731d97c9821a3845 (diff)
downloadTrader-643767f141505c5e62dbaa402ac84a7b0c5511f2.tar.gz
Trader-643767f141505c5e62dbaa402ac84a7b0c5511f2.tar.zst
Trader-643767f141505c5e62dbaa402ac84a7b0c5511f2.zip
Add debug mode parameter rather than global flag
-rw-r--r--portfolio.py7
1 files changed, 2 insertions, 5 deletions
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
4# Put your poloniex api key in market.py 4# Put your poloniex api key in market.py
5from market import market 5from market import market
6 6
7debug = False
8
9class Portfolio: 7class Portfolio:
10 URL = "https://cryptoportfolio.io/wp-content/uploads/portfolio/json/cryptoportfolio.json" 8 URL = "https://cryptoportfolio.io/wp-content/uploads/portfolio/json/cryptoportfolio.json"
11 liquidities = {} 9 liquidities = {}
@@ -408,7 +406,6 @@ class Trade:
408 self.action) 406 self.action)
409 407
410class Order: 408class Order:
411 DEBUG = debug
412 409
413 def __init__(self, action, amount, rate, base_currency, market): 410 def __init__(self, action, amount, rate, base_currency, market):
414 self.action = action 411 self.action = action
@@ -436,11 +433,11 @@ class Order:
436 def finished(self): 433 def finished(self):
437 return self.status == "closed" or self.status == "canceled" 434 return self.status == "closed" or self.status == "canceled"
438 435
439 def run(self): 436 def run(self, debug=False):
440 symbol = "{}/{}".format(self.amount.currency, self.base_currency) 437 symbol = "{}/{}".format(self.amount.currency, self.base_currency)
441 amount = self.amount.value 438 amount = self.amount.value
442 439
443 if self.DEBUG: 440 if debug:
444 print("market.create_order('{}', 'limit', '{}', {}, price={})".format( 441 print("market.create_order('{}', 'limit', '{}', {}, price={})".format(
445 symbol, self.action, amount, self.rate)) 442 symbol, self.action, amount, self.rate))
446 else: 443 else: