From a6cb0b48f148b2c4e6c399755f58df3a8ca14d58 Mon Sep 17 00:00:00 2001 From: DogsTailFarmer Date: Sat, 30 Sep 2023 19:00:04 +0300 Subject: [PATCH] 1.3.7 --- CHANGELOG.md | 4 +++ martin_binance/__init__.py | 2 +- martin_binance/executor.py | 11 ++----- martin_binance/margin_wrapper.py | 49 ++++++++++++++++---------------- pyproject.toml | 4 +-- requirements.txt | 4 +-- 6 files changed, 35 insertions(+), 39 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 025612d..4021d74 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.3.7 - 2023-09-30 +### Update +* Up requirements for exchanges-wrapper==1.3.7.post2 + ## 1.3.7b1 2023-09-26 ### Added for new features * Save trading (filling orders) and transfer asset history into a file `~/.MartinBinance/log/X_AAABBB.csv` diff --git a/martin_binance/__init__.py b/martin_binance/__init__.py index 47d075e..6091540 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.7b2" +__version__ = "1.3.7" __maintainer__ = "Jerry Fedorenko" __contact__ = "https://github.com/DogsTailFarmer" diff --git a/martin_binance/executor.py b/martin_binance/executor.py index 7594b5e..bd58c21 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.6.post1" +__version__ = "1.3.7" __maintainer__ = "Jerry Fedorenko" __contact__ = 'https://github.com/DogsTailFarmer' ################################################################## @@ -3450,7 +3450,7 @@ def on_place_order_error_string(self, place_order_id: int, error: str) -> None: if order: self.message_log(f"Order {place_order_id} placed", tlg=True) self.on_place_order_success(place_order_id, order) - elif 'FAILED_PRECONDITION' not in error: + else: self.message_log(f"Trying place order {place_order_id} one more time", tlg=True) if self.orders_init.exist(place_order_id): _order = self.orders_init.get_by_id(place_order_id) @@ -3466,12 +3466,7 @@ def on_place_order_error_string(self, place_order_id: int, error: str) -> None: elif place_order_id == self.tp_wait_id: self.tp_wait_id = None self.tp_error = True - else: - self.message_log(f"Order {place_order_id} can't be placed. Check it manually", LogLevel.ERROR, tlg=True) - if self.orders_init.exist(place_order_id): - self.orders_init.remove(place_order_id) - elif place_order_id == self.tp_wait_id: - self.tp_wait_id = None + def on_cancel_order_success(self, order_id: int, canceled_order: Order, cancel_all=False) -> None: # noqa if order_id == self.cancel_grid_order_id: diff --git a/martin_binance/margin_wrapper.py b/martin_binance/margin_wrapper.py index 74388eb..12b2c80 100755 --- a/martin_binance/margin_wrapper.py +++ b/martin_binance/margin_wrapper.py @@ -4,7 +4,7 @@ __author__ = "Jerry Fedorenko" __copyright__ = "Copyright © 2021 Jerry Fedorenko aka VM" __license__ = "MIT" -__version__ = "1.3.7b2" +__version__ = "1.3.7" __maintainer__ = "Jerry Fedorenko" __contact__ = "https://github.com/DogsTailFarmer" @@ -21,9 +21,8 @@ import pandas as pd import shutil import psutil -import aiofiles +import csv -from aiocsv import AsyncWriter from colorama import init as color_init from decimal import Decimal, ROUND_FLOOR from pathlib import Path @@ -549,6 +548,8 @@ def place_limit_order(self, buy: bool, amount: Decimal, price: Decimal) -> int: color=ms.Style.B_YELLOW) loop.create_task(place_limit_order_timeout(cls.order_id)) loop.create_task(create_limit_order(cls.order_id, buy, any2str(amount), any2str(price))) + if cls.exchange == 'huobi': + time.sleep(0.02) return cls.order_id def get_buffered_completed_trades(self, _get_all_trades: bool = False) -> List[PrivateTrade]: @@ -621,28 +622,28 @@ def transfer_to_master(symbol: str, amount: str): async def save_to_csv() -> None: cls = StrategyBase file_name = Path(ms.LOG_PATH, f"{ms.ID_EXCHANGE}_{ms.SYMBOL}.csv") - async with aiofiles.open(file_name, mode="a", encoding="utf-8", newline="") as afp: - writer = AsyncWriter(afp, dialect="unix") - await writer.writerow(["TRADE", - "transaction_time", - "side", - "order_id", - "client_order_id", - "trade_id", - "order_quantity", - "order_price", - "cumulative_filled_quantity", - "quote_asset_transacted", - "last_executed_quantity", - "last_executed_price", - ]) - await writer.writerow(['TRANSFER', - "event_time", - "asset", - "balance_delta", - ]) + with open(file_name, mode="a", buffering=1) as fp: + writer = csv.writer(fp) + writer.writerow(["TRADE", + "transaction_time", + "side", + "order_id", + "client_order_id", + "trade_id", + "order_quantity", + "order_price", + "cumulative_filled_quantity", + "quote_asset_transacted", + "last_executed_quantity", + "last_executed_price", + ]) + writer.writerow(['TRANSFER', + "event_time", + "asset", + "balance_delta", + ]) while cls.strategy: - await writer.writerow(await save_trade_queue.get()) + writer.writerow(await save_trade_queue.get()) save_trade_queue.task_done() diff --git a/pyproject.toml b/pyproject.toml index 2bcfde0..4ce6860 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,7 +17,7 @@ dynamic = ["version", "description"] requires-python = ">=3.8" dependencies = [ - "exchanges-wrapper==1.3.7.post1", + "exchanges-wrapper==1.3.7.post2", "margin-strategy-sdk==0.0.11", "jsonpickle==3.0.2", "psutil==5.9.5", @@ -33,8 +33,6 @@ dependencies = [ "inquirer==3.1.3", "scikit-learn~=1.3.1", "tqdm==4.66.1", - "aiofiles~=23.2.1", - "aiocsv~=1.2.4", ] [tool.flit.module] diff --git a/requirements.txt b/requirements.txt index 0e57e1f..9e4caed 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -exchanges-wrapper==1.3.7.post1 +exchanges-wrapper==1.3.7.post2 margin-strategy-sdk==0.0.11 jsonpickle==3.0.2 psutil==5.9.5 @@ -14,5 +14,3 @@ future==0.18.3 inquirer==3.1.3 scikit-learn~=1.3.1 tqdm==4.66.1 -aiofiles~=23.2.1 -aiocsv~=1.2.4 \ No newline at end of file