From 5e6f5849892a0bbf3fa2dc6328bf6e1d423b03e5 Mon Sep 17 00:00:00 2001 From: Fabian Schuh <Fabian@chainsquad.com> Date: Thu, 29 Jun 2017 19:01:20 +0200 Subject: [PATCH] [expiration] allow order expiration to be defined from storage --- Makefile | 2 +- bitshares/market.py | 9 ++++++--- bitshares/storage.py | 1 + 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 8db8399a..1d5d0ccd 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ clean-build: rm -fr build/ rm -fr dist/ rm -fr *.egg-info - rm -fr __pycache__/ .eggs/ .cache/ + rm -fr __pycache__/ .eggs/ .cache/ .tox/ clean-pyc: find . -name '*.pyc' -exec rm -f {} + diff --git a/bitshares/market.py b/bitshares/market.py index c13d107e..fa95ad16 100644 --- a/bitshares/market.py +++ b/bitshares/market.py @@ -356,7 +356,7 @@ class Market(dict): self, price, amount, - expiration=7 * 24 * 60 * 60, + expiration=None, killfill=False, account=None, returnOrderId=False @@ -395,6 +395,8 @@ class Market(dict): * This means that you actually place a sell order for 1000 BTS in order to obtain **at least** 10 USD * If an order on the market exists that sells USD for cheaper, you will end up with more than 10 USD """ + if not expiration: + expiration = self.bitshares.config["order-expiration"] if not account: if "default_account" in self.bitshares.config: account = self.bitshares.config["default_account"] @@ -453,7 +455,7 @@ class Market(dict): self, price, amount, - expiration=7 * 24 * 60 * 60, + expiration=None, killfill=False, account=None, returnOrderId=False @@ -480,6 +482,8 @@ class Market(dict): market. I.e. in the BTC/BTS market, prices are BTS per BTC. That way you can multiply prices with `1.05` to get a +5%. """ + if not expiration: + expiration = self.bitshares.config["order-expiration"] if not account: if "default_account" in self.bitshares.config: account = self.bitshares.config["default_account"] @@ -531,7 +535,6 @@ class Market(dict): tx["orderid"] = tx["operation_results"][0][1] self.bitshares.blocking = prevblocking - def cancel(self, orderNumber, account=None): """ Cancels an order you have placed in a given market. Requires only the "orderNumber". An order number takes the form diff --git a/bitshares/storage.py b/bitshares/storage.py index b7b752ac..eb346237 100644 --- a/bitshares/storage.py +++ b/bitshares/storage.py @@ -221,6 +221,7 @@ class Configuration(DataDir): "node": "wss://node.bitshares.eu", "rpcpassword": "", "rpcuser": "", + "order-expiration": 7 * 24 * 60 * 60, } def __init__(self): -- GitLab