From ecba11139e357567c46f7ba2a0cf8dbd98266fe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Fri, 26 Jan 2018 00:10:03 +0100 Subject: Add first steps for margin trading --- portfolio.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'portfolio.py') diff --git a/portfolio.py b/portfolio.py index 1fe56b5..3257bcf 100644 --- a/portfolio.py +++ b/portfolio.py @@ -467,12 +467,13 @@ class Trade: print("\t", order, sep="") class Order: - def __init__(self, action, amount, rate, base_currency, market): + def __init__(self, action, amount, rate, base_currency, market, account="exchange"): self.action = action self.amount = amount self.rate = rate self.base_currency = base_currency self.market = market + self.account = account self.result = None self.status = "pending" @@ -498,16 +499,16 @@ class Order: amount = self.amount.value if debug: - print("market.create_order('{}', 'limit', '{}', {}, price={})".format( - symbol, self.action, amount, self.rate)) + print("market.create_order('{}', 'limit', '{}', {}, price={}, account={})".format( + symbol, self.action, amount, self.rate, self.account)) else: try: - self.result = self.market.create_order(symbol, 'limit', self.action, amount, price=self.rate) + self.result = self.market.create_order(symbol, 'limit', self.action, amount, price=self.rate, account=self.account) self.status = "open" except Exception as e: self.status = "error" - print("error when running market.create_order('{}', 'limit', '{}', {}, price={})".format( - symbol, self.action, amount, self.rate)) + print("error when running market.create_order('{}', 'limit', '{}', {}, price={}, account={})".format( + symbol, self.action, amount, self.rate, self.account)) self.error_message = str("{}: {}".format(e.__class__.__name__, e)) print(self.error_message) -- cgit v1.2.3