From 3ec2e514deed4721acdfc963a15a15173fc361d2 Mon Sep 17 00:00:00 2001 From: DogsTailFarmer Date: Mon, 9 Oct 2023 14:47:47 +0300 Subject: [PATCH] 1.3.7.post3 --- CHANGELOG.md | 7 +++++++ martin_binance/__init__.py | 2 +- martin_binance/executor.py | 9 ++++----- pyproject.toml | 2 +- requirements.txt | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b0deb2..d274a4d 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +## 1.3.7.post3 - 2023-10-09 +### Fix +* calc_profit_order(): rounding issue when correction tp amount on step_size + +### Update +* Up requirements for exchanges-wrapper==1.3.7.post4 + ## 1.3.7.post2 - 2023-10-05 ### Fix * Fix: Refine exception handling when deleting a grid of orders, one of which is partially filled diff --git a/martin_binance/__init__.py b/martin_binance/__init__.py index ebbdcb5..b66b1e1 100755 --- a/martin_binance/__init__.py +++ b/martin_binance/__init__.py @@ -6,7 +6,7 @@ __author__ = "Jerry Fedorenko" __copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM" __license__ = "MIT" -__version__ = "1.3.7.post2" +__version__ = "1.3.7.post3" __maintainer__ = "Jerry Fedorenko" __contact__ = "https://github.com/DogsTailFarmer" diff --git a/martin_binance/executor.py b/martin_binance/executor.py index 2372d93..ca23005 100755 --- a/martin_binance/executor.py +++ b/martin_binance/executor.py @@ -4,7 +4,7 @@ __author__ = "Jerry Fedorenko" __copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM" __license__ = "MIT" -__version__ = "1.3.7.post2" +__version__ = "1.3.7.post3" __maintainer__ = "Jerry Fedorenko" __contact__ = 'https://github.com/DogsTailFarmer' ################################################################## @@ -1911,8 +1911,7 @@ def round_truncate(self, _x: Decimal, base: bool = None, fee=False, _rounding=RO round_pattern = "1.01234567" else: round_pattern = self.round_base if base else self.round_quote - xr = _x.quantize(Decimal(round_pattern), rounding=_rounding) - return xr + return _x.quantize(Decimal(round_pattern), rounding=_rounding) def round_fee(self, fee, amount, base): return self.round_truncate(fee * amount / 100, base=base, fee=True, _rounding=ROUND_CEILING) @@ -2422,9 +2421,9 @@ def calc_profit_order(self, buy_side: bool, by_market: bool = False) -> Dict[str self.tp_amount = self.sum_amount_first profit = self.set_profit(self.sum_amount_second, by_market) target_amount_first = self.sum_amount_first + profit * self.sum_amount_first / 100 - target_amount_first = self.round_truncate(target_amount_first, base=True, _rounding=ROUND_FLOOR) if target_amount_first - self.tp_amount < step_size_f: target_amount_first = self.tp_amount + step_size_f + target_amount_first = self.round_truncate(target_amount_first, base=True, _rounding=ROUND_FLOOR) amount = target = target_amount_first # Calculate depo amount in second amount_s = self.round_truncate(self.sum_amount_second, base=False, _rounding=ROUND_FLOOR) @@ -2435,9 +2434,9 @@ def calc_profit_order(self, buy_side: bool, by_market: bool = False) -> Dict[str self.tp_amount = self.sum_amount_second profit = self.set_profit(self.sum_amount_first, by_market) target_amount_second = self.sum_amount_second + profit * self.sum_amount_second / 100 - target_amount_second = self.round_truncate(target_amount_second, base=False, _rounding=ROUND_CEILING) if target_amount_second - self.tp_amount < step_size_s: target_amount_second = self.tp_amount + step_size_s + target_amount_second = self.round_truncate(target_amount_second, base=False, _rounding=ROUND_CEILING) # Calculate depo amount in first amount = self.round_truncate(self.sum_amount_first, base=True, _rounding=ROUND_FLOOR) price = f2d(tcm.round_price(float(target_amount_second / amount), RoundingType.CEIL)) diff --git a/pyproject.toml b/pyproject.toml index c673530..16de459 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dynamic = ["version", "description"] requires-python = ">=3.8" dependencies = [ - "exchanges-wrapper==1.3.7.post3", + "exchanges-wrapper==1.3.7.post4", "margin-strategy-sdk==0.0.11", "jsonpickle==3.0.2", "psutil==5.9.5", diff --git a/requirements.txt b/requirements.txt index 2232c5a..8147870 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -exchanges-wrapper==1.3.7.post3 +exchanges-wrapper==1.3.7.post4 margin-strategy-sdk==0.0.11 jsonpickle==3.0.2 psutil==5.9.5