diff options
Diffstat (limited to 'portfolio.py')
-rw-r--r-- | portfolio.py | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/portfolio.py b/portfolio.py index 1fe56b5..3257bcf 100644 --- a/portfolio.py +++ b/portfolio.py | |||
@@ -467,12 +467,13 @@ class Trade: | |||
467 | print("\t", order, sep="") | 467 | print("\t", order, sep="") |
468 | 468 | ||
469 | class Order: | 469 | class Order: |
470 | def __init__(self, action, amount, rate, base_currency, market): | 470 | def __init__(self, action, amount, rate, base_currency, market, account="exchange"): |
471 | self.action = action | 471 | self.action = action |
472 | self.amount = amount | 472 | self.amount = amount |
473 | self.rate = rate | 473 | self.rate = rate |
474 | self.base_currency = base_currency | 474 | self.base_currency = base_currency |
475 | self.market = market | 475 | self.market = market |
476 | self.account = account | ||
476 | self.result = None | 477 | self.result = None |
477 | self.status = "pending" | 478 | self.status = "pending" |
478 | 479 | ||
@@ -498,16 +499,16 @@ class Order: | |||
498 | amount = self.amount.value | 499 | amount = self.amount.value |
499 | 500 | ||
500 | if debug: | 501 | if debug: |
501 | print("market.create_order('{}', 'limit', '{}', {}, price={})".format( | 502 | print("market.create_order('{}', 'limit', '{}', {}, price={}, account={})".format( |
502 | symbol, self.action, amount, self.rate)) | 503 | symbol, self.action, amount, self.rate, self.account)) |
503 | else: | 504 | else: |
504 | try: | 505 | try: |
505 | self.result = self.market.create_order(symbol, 'limit', self.action, amount, price=self.rate) | 506 | self.result = self.market.create_order(symbol, 'limit', self.action, amount, price=self.rate, account=self.account) |
506 | self.status = "open" | 507 | self.status = "open" |
507 | except Exception as e: | 508 | except Exception as e: |
508 | self.status = "error" | 509 | self.status = "error" |
509 | print("error when running market.create_order('{}', 'limit', '{}', {}, price={})".format( | 510 | print("error when running market.create_order('{}', 'limit', '{}', {}, price={}, account={})".format( |
510 | symbol, self.action, amount, self.rate)) | 511 | symbol, self.action, amount, self.rate, self.account)) |
511 | self.error_message = str("{}: {}".format(e.__class__.__name__, e)) | 512 | self.error_message = str("{}: {}".format(e.__class__.__name__, e)) |
512 | print(self.error_message) | 513 | print(self.error_message) |
513 | 514 | ||