🔧 fix(executor.py): Refactor import statements and update method arguments for better readability and consistency
This patch introduces several significant changes to the martin_binance trading bot, primarily focused on enhancing its trading capabilities, improving stability, and refining its internal logic.
Here's a breakdown of the key business logic changes:
- Introduction of Trade Control (
TRADE_CONTROL): A new feature, "Trade Control," has been implemented. This system, controlled byTRADE_CONTROL = True, aims to delay the start of trading cycles during periods of negative market trends. This is achieved by analyzing directional index (DI) data usingpymannkendallandAPScheduler, introducing a more cautious approach to entering trades. - Enhanced Scheduling with
APScheduler: Theschedulelibrary has been replaced withAPSchedulerfor managing recurring tasks. This provides more robust and flexible scheduling capabilities, including cron-like job scheduling, which is now used for events likeevent_update_tpandevent_export_operational_status. - Improved Balance Tracking: New functionality has been added to track the
started_balance_detail(base, quote, and rate) at the beginning of a trading cycle. This allows for better monitoring of balance changes and profitability over time, with a newget_started_balance_diffmethod to report these differences. - Asynchronous Operations: Several core methods have been converted to
async, includingevent_get_external_command,event_report,event_processing,event_update_tp,event_grid_only_release,restore_strategy_state,start,collect_assets,grid_handler,convert_tp,reverse_after_grid_ending,cancel_grid,grid_update,after_filled_tp,place_profit_order,transfer_to,on_new_ticker,on_balance_update_ex,on_new_funds,on_order_update_ex,on_place_order_success,on_place_order_error,on_cancel_order_success,on_cancel_order_error_string, andon_funds_update_handler. This transition to asynchronous programming is crucial for handling concurrent operations efficiently, especially in a high-frequency trading environment. - Refined Order Management: The logic for handling order cancellations and updates has been refined, with more specific error handling and clearer state management for various order types (grid, TP, etc.). The
cancel_ordermethod is now asynchronous and handles bulk cancellations more robustly. - Data Persistence and Initialization: Changes in
db_utils.pyindicate potential improvements in how data is managed and initialized in the SQLite database, including aDELETE FROM t_ordersoperation, possibly for clearing stale order data. - Dependency Updates: Several dependencies have been updated, including
exchanges-wrapperto2.1.47, and new ones likeapschedulerandpymannkendallhave been added. These updates likely bring performance improvements, bug fixes, and new functionalities to the underlying libraries. - Backtesting Enhancements: Minor adjustments were made to the backtesting modules (
OoTSP.py,VCoSEL.py), including a change in the default number of trials for optimization and a correction in the server run command. - Parameter Additions: New parameters have been introduced related to the "Trade Control" feature, such as
TRADE_CONTROL,TC_ADX_DATA_LIMIT,TC_ADX_PERIOD,TC_DI_DIFF, andTC_K, allowing for fine-tuning of this new trading logic.
In summary, this patch represents a significant evolution of the martin_binance bot, moving towards a more intelligent, robust, and asynchronous trading system with enhanced risk management capabilities through the new "Trade Control" feature and improved scheduling.
🔧 chore(pyproject.toml): update requires-python to require Python 3.12 for compatibility.
🐳 chore(Dockerfile): switch base image to Python 3.12 and update paths accordingly.
🔧 fix(dependencies): update exchanges-wrapper, numpy, optuna, orjson, pandas, prometheus-client, psutil, pyarrow, scikit-learn, and scipy versions in pyproject.toml and requirements.txt for compatibility.
📦 fix(dependencies): update package versions in pyproject.toml and requirements.txt for compatibility
🔧 fix(logging): improve logger configuration in martin_binance/lib.py and martin_binance/strategy_base.py
✨ feat(executor): add malloc_trim method for memory management optimization in martin_binance/executor.py
🐛 fix(client): enhance logging setup in martin_binance/client.py for better traceability
🔧 fix(versions): update exchanges-wrapper to version 2.1.42 in pyproject.toml and requirements.txt
📦 fix(dependencies): upgrade ujson to version 5.11.0 in pyproject.toml and requirements.txt
📖 docs(changelog): update date for version 3.0.36 in CHANGELOG.md
🔧 fix(strategy_base): adjust reset_backtest_vars logic for better initialization in martin_binance/strategy_base.py
🔧 fix(executor): add delta to initial_first and initial_second in martin_binance/executor.py
🔧 fix(client): update version to 3.0.36 in martin_binance/client.py
🚀 feat(lib): enhance task naming in tasks_manage for better traceability
🔧 fix(strategy_base): improve asset management by clearing lists instead of reinitializing
🐛 fix(strategy_base): correctly handle task cancellation in wss_init
🔄 refactor(executor): streamline grid orders logic based on reverse hold status
✨ feat(client): add restart_session method for session management
🛠️ fix(exch_srv): ensure client removal logic uses ID instead of name
🧹 refactor(web_sockets): safeguard websocket closure with existence check
- Change:
- Added
self.grid_only_restart = 0in the constructor ofExecutorinexecutor.pyand incollect_assets(). - Modified
event_grid_only_release()to useself.get_time() > self.grid_only_restartfor timing checks. - Introduced
active_orderscondition ingrid_update()to prevent unnecessary restarts.
- Added
- Rationale:
- Prevents premature or incorrect grid restarts by ensuring the restart delay (
GRID_ONLY_DELAY) is respected. - Ensures the grid is only restarted when all funds are used and no active orders exist, avoiding rapid or redundant cycles.
- Resets the restart timer to 0 after initiating a restart, preventing repeated triggers.
- Prevents premature or incorrect grid restarts by ensuring the restart delay (
- Change:
- Replaced
()withtuplein method return types (e.g.,get_free_assets(),calculate_profit_amounts()).
- Replaced
- Rationale:
- Enhances code clarity and IDE support by explicitly stating that these methods return tuples of
Decimalvalues. - Aligns with Python 3.10+ type hinting standards (e.g.,
tuple[Decimal, Decimal]).
- Enhances code clarity and IDE support by explicitly stating that these methods return tuples of
- Change:
- Replaced
window.attached_panewithwindow.active_paneinrelaunch.py.
- Replaced
- Rationale:
- Adapts to potential deprecations or changes in the terminal control library (e.g.,
tmuxorscreenbindings). - Ensures commands are sent to the correct active terminal pane for session relaunch.
- Adapts to potential deprecations or changes in the terminal control library (e.g.,
- Change:
- Added
gc.collect(generation=2)logging incollect_assets().
- Added
- Rationale:
- Monitors memory usage and garbage collection efficiency, aiding in performance debugging.
- Helps identify potential memory leaks or excessive object creation.
- Change:
- Updated
__version__to3.0.36band3.0.36in__init__.pyandrelaunch.py. - Extended
__copyright__year to2021-2025.
- Updated
- Rationale:
- Standard practice for version control and legal compliance.
- Reflects ongoing maintenance and new features/fixes in the release.
- Stability:
- Grid restarts now occur only after the required delay and under correct conditions, reducing the risk of infinite loops or redundant trades.
- Maintainability:
- Improved type hints and clearer method signatures make the codebase easier to navigate and extend.
- Performance:
- Garbage collection logging provides insights into memory management, enabling proactive optimization.
- Compatibility:
- Updated API calls ensure compatibility with newer versions of dependencies (e.g., terminal control libraries).
✨ feat(executor.py): update buy/sell order placement logic to use best_price 🛠️ fix(executor.py): adjust restore state message from "replace" to "create" 🛠️ fix(executor.py): add cancel_order_id and tp_hold reset on error handling
🛠️ fix(client.py): remove redundant else in register_client method
🛠️ fix(strategy_base.py): adjust indentation and structure in fetch_order method
🛠️ fix(exchange_simulator.py): update return type and error handling in methods
Version Updates:
- The version number has been updated to
3.0.33in all relevant files (__init__.py,client.py,strategy.py, etc.).
Error Handling:
- Removed redundant error handling for
asyncio.CancelledError. This exception is generally not needed because it indicates the task was cancelled, and further action is typically unnecessary.
Asynchronous File Operations:
- Replaced synchronous file operations with asynchronous ones using
aiofilesin several places to improve performance:- Reading and writing JSON files.
- Writing CSV files.
Input Handling:
- Converted blocking input calls into non-blocking ones using
asyncio.to_threadto prevent the event loop from being blocked during user interaction.
Exception Logging:
- Added more descriptive logging for exceptions, such as when failing to get a command from the Telegram proxy or encountering other issues that might affect the operation of the bot.
Code Refactoring:
- Improved code readability and maintainability by removing unnecessary comments and restructuring some sections of the code.
CSV Writing:
- Updated CSV writing logic to use
AsyncWriterfromaiofilesfor asynchronous writing, ensuring that file operations do not block the event loop.
🔧 fix(executor): adjust conditions for currency deposits with GRID_ONLY logic
🔧 fix(executor): correct handling of delta in conditional for initial_first and initial_second updates
✨ feat(executor): refactor grid_update method and simplify TP order handling logic for clarity and efficiency.
🔧 fix(executor): ensure grid orders placement when no open grid orders exist.
✨ refactor(lib.py): simplify convert_from_minute using intervals for improved readability and maintainability
🔧 fix(executor.py): change type check to isinstance for self.start_collect in event_exec_command
🔧 fix(executor.py): streamline condition checks in on_new_ticker for better clarity and performance
🔧 chore(dependencies): update exchanges-wrapper to version 2.1.37 in pyproject.toml and requirements.txt
🔧 fix(strategy): simplify create_order_handler method in strategy_base.py
🔧 chore(dependencies): bump exchanges-wrapper version to 2.1.36 in pyproject.toml and requirements.txt
🔧 refactor(lib): update function return types to dict and list in martin_binance/lib.py
🔧 refactor(strategy_base): update function return types to list in martin_binance/strategy_base.py
🔒 fix(tlg_client, tlg_proxy): set minimum SSL/TLS version to 1.2 for enhanced security
🔧 chore(init): bump version to 3.0.26 in __init__.py
🔧 fix(pyproject.toml, requirements.txt): update exchanges-wrapper version to 2.1.35 for compatibility
📝 docs(README.md): update configuration instructions for exchanges-wrapper to version 3.0.25
🔄 chore(README.md): change HUOBI to HTX and OKEX to OKX in referral links
✨ UPDATE: Bump dependencies and version.
restore_strategy_state: Logical error when processing orders that were sent before shutdown and no response was receivedon_balance_update_ex: doubling the adjustment of the initial balance with a positive replenishment in the opposite coin
- Added
trade_idto debug output - Bump requirements
grafana.jsontemplate- Some minor improvements
- Bump requirements
- Some minor improvements
Bybit: checking for the minimum/maximum Buy/Sell orders price is excluded- Bump requirements
- Some minor improvements
on_balance_update_ex: calculating initial balance for opposite coin in Reverse cycle
funds_rate_exporter.py: optimized current price queries oncoinmarketcap- Functions for placing and canceling orders have been optimized
- Bump requirements
- Change dependency model for exchanges-wrapper
- Up requirements for exchanges-wrapper>=2.1.26
- Restored reverse_price value if it is omitted
GRID_ONLYmode: incorrect check of minimum trading volume- Erroneous correction of the opposite coin when withdrawing in a reverse cycle is excluded
- Restarting a session in case of network failures when sharing a client between pairs
- Interaction with the Telegram service, consolidation of messages and distribution of commands through a centralized proxy service, default use tlg_proxy service disabled
funds_rate_exporter.py: add export data to IPv6 interface
- Bump requirements
- Moving control and updating MAX_QUEUE_SIZE for on_*_update loops to server side
- Unnecessary restart when updating assets
- Add parameter
SAVE_ASSET, to selectively suppress this feature
- Up requirements for exchanges-wrapper==2.1.20
- Add
betterprototo requirements
pyproject.toml
- deepsource found style issue
- Sometimes get error from backtesting on Exit #81
- (3.0.13b4) Handling missed asset update events of GRID_ONLY and USE_ALL_FUND modes
- Up requirements for exchanges-wrapper==2.1.18
- Dependency
- Some minor improvement
- Calculating
self.reverse_pricebefore immediately starting Reverse cycle also. It can be used later inon_balance_update_ex on_balance_update_ex: initial balance update logic
on_balance_update_ex: excessive recalculation of income when withdrawing funds
- Processing account replenishment in all states with increasing turnover
- Dependency
- Updated
APY profit ratingGrafana report, used data from selected time range for APY calculation - Processing account replenishment in all states with increasing turnover
- Version compatibility
- Continue interrupted grid update cycle after restart
- Dependency
Docker: server-client deployment functionality restored (exchanges-wrapperandmartin-binance), also for Windows
RATE_LIMITERinitial settings changed- Up requirements for exchanges-wrapper==2.1.12
- Unattended cancelling keepalive tasks
- The total income includes withdrawn funds
- Up requirements for exchanges-wrapper==2.1.11
- Refine handling backtest process
- Up requirements for exchanges-wrapper==2.1.10
- Import from
paramsmodule - Some issues
Mismatch between signature and use of an overridden method
- Creating and manage asynchronous tasks
- Up requirements for exchanges-wrapper==2.1.9
- 'Backtesting': some minor improvements
- Remove cross-version updates
- Refine templates handling
Backtesting: extract trial parameters into/home/ubuntu/.MartinBinance/trial_params.json, detail here.Backtesting: add logging importance parameters rating for each optimisation cycle- Up requirements for exchanges-wrapper==2.1.8
Backtesting: updating the balances at slippageclass PrivateTrade:convert trade_id to int()Backtest control: orjson.JSONDecodeError: unexpected character: line 1 column 1 (char 0)
- Up requirements for exchanges-wrapper==2.1.7
- Some minor improvement
- Project architecture
- 🚀 Cyclic Backtesting workflow with update base trade parameters
- 🚀
Backtesting: handling of partially filling events - 🚀 Migrate
gRPCfrom grpcio to grpclib + python-betterproto - Logging improvement
Analytics: Refine unload and processing assets data- Refactoring processing periodically events based on schedule
- New strategy mode: Keeping level of first asset
- Up requirements for exchanges-wrapper==2.1.6
- Refactoring processing periodically events
- Up requirements for exchanges-wrapper==2.1.5
🚀 Backtesting: handling of partially filling events
- Up requirements for exchanges-wrapper==2.1.3
- Cyclic Backtesting workflow
- Up requirements for exchanges-wrapper==2.1.2
Analytics: Refine unload and processing assets data
- Up requirements for exchanges-wrapper==2.1.0
cancel_order_call(): incorrect using asyncio.wait_for()
- logging improvement
- fee settings and handling
- Replaced checking price when calculating TP vs updating price based on order book if error occurred
- Don't unload assets on
testaccounts for avoid overload limitedcoinmarketcapAPI - Startup sequence optimization
- Up requirements for exchanges-wrapper==2.0.1
- Added price check when calculating TP in relation to the average filling price of the last grid order. Relevant for extreme volatility, was noticed on the test network.
- Refine grid orders control
Backtesting: save session collected date tosession_root/raw_bak.zip
- Up requirements for exchanges-wrapper==2.0.0
- Refined logging
- logging for Simulate mode
- 🚀 Migrate
gRPCfrom grpcio to grpclib + python-betterproto - Binance: handling
EXPIRED_IN_MATCH WSS: check and restart
on_balance_update_ex(): don't update direct initial asset values in Reverse cycle- Partially filled TP in Hold reverse cycle
- Project architecture
- ModuleNotFoundError: No module named 'optimizer' #73
- Do not send orders if it was getting 'FAILED_PRECONDITION' response
- Do not start Telegram control process for Simulate mode or if bot id is not setting
- Do not start DB control process for Simulate mode
- Changed initialization sequence during recovery from saved state
on_new_funds()
- Refine initialization backtesting
- Up requirements for exchanges-wrapper==1.4.15
calc_profit_order(): rounding fortarget_amount_firstrestore_strategy_state(): Tlg control thread
- Some minor updates
- Up requirements for exchanges-wrapper==1.4.14
- Running
*_utils.pymodules as daemon
- Create limit order error handler
- Start simulate mode from saved state
check_min_amount()restore_strategy_state()- Fix issue with csv empty lines on windows (#71)
🚀 Complete cyclic optimization of strategy parameters based on optuna framework
For reference see Parameters optimization
cancel_order_call: added timeout handler- Utilised partially filled TP amount during grid update
create_limit_order: Supress call strategy handler forgrpc.StatusCode.FAILED_PRECONDITIONexception, fire tlg message only. As a result, there are no attempts to re-place the order with incorrect condition.
on_order_update_handler: refine
- Up requirements for exchanges-wrapper==1.4.12
- Some minor updates
- Event updates arrived before the saved state was restored
check_min_amount():self.tp_amount
- Up requirements for exchanges-wrapper==1.4.11
check_min_amount(): refine check min trade amount for SELL cycle- Up requirements for exchanges-wrapper==1.4.10
- Up requirements for exchanges-wrapper==1.4.9
- 'relaunch.py': improved
- Up requirements for exchanges-wrapper==1.4.9b5 (test grpc 1.60.1)
- Up requirements for exchanges-wrapper==1.4.8
- An order that was
PARTIALLY FILLEDat the time of creation was counted asFILLED
- margin_wrapper.buffered_funds(): some minor improvements
- executor.get_free_assets(): for "free" mode the volume of the utilized deposit is taken into account when not TP
- rollback saving/restore trades history, but used for it specified file in
/last_state/X_AAABBB.csv - executor: remove parameters
SAVE_TRADE_HISTORYandSAVED_STATE, already use for saving/restore trade events - comprehensive improvement of the internal accounting and recovery system
- Up requirements for exchanges-wrapper==1.4.7
- Dependency: Up requirements for Python>=3.9
- Per 10 mins update trade rules for pair
- If new trade rules prevent the grid from placing orders, then the grid will be forced to be re-set
- Add parameter
SELF_OPTIMIZATION = True# Cyclic self-optimization of parameters, together withMODE == 'TC'
SAVE_TRADE_HISTORY = Falseset default- calculation
over pricefor Reverse cycle : checking result on true positive, correction it if needed - For backtesting change format saved data from Pickle to Feather #64
- Change format to Apache Parquet
- Restrictions on the size of RAM have been removed due to write/read buffering
- Use orjson for de/serialize stream data
- replacing
jsonwithujsonto improve performance
- Up requirements for exchanges-wrapper==1.4.4
- Up requirements for exchanges-wrapper==1.4.3 fixed #42
- Refining restoration of grid orders after their execution during the grid shift process
- Up requirements for exchanges-wrapper==1.4.2
- Some minor changes
funds_rate_exporter.py: average CPU load present as percent value at 1 minute periodsolve(),calc_grid(): use scipy.optimize.minimize for calculation Reverse cycle over price- optimize CPU loads at last_state_update()
- convert_tp(): clear start_hold state and initialize restore grid orders
- Up requirements for exchanges-wrapper==1.4.1
- Backtesting, Simulation mode
- solve(): The limit of attempts has been increased
- calc_over_price(): The range of changes in the number of orders has been expanded
- Version tags
- "Groggy" state after start canceling grid before update it
- Improved calc_over_price()
- Exception buffered_orders: 'NoneType' object is not subscriptable #68
- Fix issue detected by SonarCloud
- Order price must be higher than the minimum price #67
- Up requirements for exchanges-wrapper==1.4.0
- Some minor improvements
- Handling of partially filled TP when Reverse hold
- Part filled TP and part filled grid orders, unnecessary adjustment sum_amount_
- Refine cli_X_AAABBB.py
- Remove db support to module
- Remove Telegram support to module
- README.md updated
- Clear from margin code fragments compatibility
- decimal.Decimal calculation for all modules was implemented
- Up requirements for exchanges-wrapper==1.4.0rc6
- Bybit exchange V5 API support implemented. Supported account type is Unified Trading Account, for main and sub-accounts. Spot Trading only.
- Lost compatibility with margin.de terminal. Scripts developed for use with the terminal can be run as executable modules, but not the other way around.
- The logic and implementation of monitoring exceptional situations when placing and deleting orders has been updated.
- Improved gRPC outage exception handling
- Up requirements
- calc_profit_order(): rounding issue when correction tp amount on step_size
- Up requirements for exchanges-wrapper==1.3.7.post4
- Fix: Refine exception handling when deleting a grid of orders, one of which is partially filled
- Up requirements for exchanges-wrapper==1.3.7.post3
- Sonarcloud issues
- Up requirements for exchanges-wrapper==1.3.7.post2
- Save trading (filling orders) and transfer asset history into a file
~/.MartinBinance/log/X_AAABBB.csv
headers:
"TRADE","transaction_time","side","order_id","client_order_id","trade_id","order_quantity","order_price","cumulative_filled_quantity","quote_asset_transacted","last_executed
"TRANSFER","event_time","asset","balance_delta"
data:
"TRADE","1695745010026","SELL","9850221","4815001","1716764","0.00539700","26193.86000000","0.00539700","141.36826242","0.00539700","26193.86000000"
"TRANSFER","1695745010027","LTC","-0.001"
- Limit for grid updates, updated when:
- For Original cycle: the amount of free deposit not involved in the turnover more than 35%
- For Reverse cycle: the amount of free deposit not involved in the turnover more than 65%
- Due to a rounding error, the order status was incorrectly fetched if it was partially completed
- Up requirements for exchanges-wrapper==1.3.7.post1
- To boost trade in case of low market volatility: TP order is updated once every 15 minutes, and in Reverse cycle grid update once an hour
- Fix: Error getting internal id while re-placing grid order
- Update: On-the-fly update assets with withdrawal and deposit operations also for Reverse cycle
- Fix: Incorrect calculated depo volume for grid update, not include held grid orders volume
- Up requirements for exchanges-wrapper to 1.3.7
- Restored MS_ORDERS, convert from list to dict (inter-version compatibility), clear
relaunch.py: update deprecation method forlibtmux==0.22.1
- Up requirements for exchanges-wrapper to 1.3.6b7
- Up requirements for exchanges-wrapper to 1.3.6b6
- Up other requirements
- Some minor improvements
- Starting with version
martin-binance 1.3.4, compatibility withmarginwill be lost, since some new parts of the code are no longer supported by implementedPython 3.7. I'm focused onPython 3.10. I won't rid the code of numerous compatibility elements yet, so if the margin team will update its version, everything should work.
-
Processing of the situation when at bulk cancel of the grid orders and one or more of orders are FILLED.
- cancel loop is interrupted
- orders with received CANCELED status are restored
- status is requested for unconfirmed orders and processing is performed: recovery if status is CANCELED,
- normal processing in case of filling in
-
Processing of the situation when after partially filled TP one or some or all grids are filled
-
executor.get_free_assets(mode='free'): incorrect balance for opposite asset (always 0), as a result - a negative value of free funds -
margin_wrapper.restore_state_before_backtesting(): tmp upgrade issue - convert cls.orders to dict
OoTSP.py: add interactive option Get parameters for specific trial
- Backtesting: 100% repeatability of test and initial sessions at the same parameters is achieved. Ticker history includes fulfillment events that may not be in the original stream. I.e. the order was executed at price P, and there was no such price in the stream at a given time period. This led to a divergence of the test session against the original (reference).
README.md: some design correction- Remove parameter
ex.EXTRA_CHECK_ORDER_STATEand the corresponding function - Up requirements for grpcio to 1.56.0
- Up requirements for exchanges-wrapper to 1.3.4
- Send alarm (to db) if exist unreleased grid orders or hold TP
- Up requirements for exchanges-wrapper to 1.3.3
- fetch_order(): fixed status for archived order (remove it from StrategyBase.orders)
- get_free_assets() added 'available' mode for initial funds check
- Incorrect internal accounting of active orders
- Changed StrategyBase.orders from list to dict
- Some improvements in save/restore
- buffered_orders() was try fetch orders and generate event on stopped strategy, full refactoring restore from saved state
- remove all_trades and all_orders class variables from StrategyBase as redundant
- Up requirements for exchanges-wrapper to 1.3.2
- funds_rate_exporter: optimized response rate to free balance change
- client session id changed from uuid to shortuuid
- optuna: add visualization contour_plot and slice_plot
- BACKTEST "S" mode: Restore an TP from a saved state, was missing
- BACKTEST "S" mode: add progress bar
- BACKTEST "S" mode: supress logging
- Up requirements for exchanges-wrapper to 1.3.1
- Refactoring the deployment process
get_free_assets(mode='free', backtest=True)return incorrect value for backtest Reverse cycle
- Sometimes Tmux terminal after reboot not restore work path to
/exch_srv.pyFor working case: in relaunch.py was changed './exch_srv.py' to 'exch_srv.py' and path~/.local/lib/python3.10/site-packages/exchanges_wrappermust be added to system PATH
For Ubuntu at end of ~/.bashrc add the string
export PATH=$PATH:~/.local/lib/python3.10/site-packages/exchanges_wrapper
and refresh bash source ~/.bashrc
- Change ast.literal_eval() to eval() for trusted source
- Ability to start backtesting from saved state, including in Reverse mode
- Monitoring memory usage including swap
- up requirements for exchanges-wrapper to 1.3.0-2
- Some minor improvements
- Backtesting capabilities
- Based on optuna framework search for optimal trading parameters
- Visual comparison of the results of the initial and trial trading sessions
- Doc migrate from readme to wiki
- correct funding check in start()
- #59
- Sync record/play
- Add SAVE_DS = True # Save session result snapshot (ticker, orders) for compare
- up requirements for exchanges-wrapper to 1.3.0-1
- refactoring class StrategyBase
-
- backtest_data_control()
- deepsource issues
- Bitfinex: rename test pair from AAABBB to TESTBTCTESTUSDT, update template
- protobuf format for CreateLimitOrder() method. Not compatible with earlier versions
- for some situation (shift grid, cancel grid after filled TP and so on) changed cancel order method from "one by one" to bulk mode
- collect_assets() incorrect convert small decimal.Decimal values to str
- For STANDALONE mode refactoring call environment for place_limit_order(), avoid unnecessary Decimal -> float conversions
- Add error handling for atr()
- Some minor improvements
- Use ATR (Average True Range with 14 period x 15 min) indicator when calculate first grid order volume
- Grafana template: Consolidated asset valuation - Assets by place: group by exchange name instead of account name
- Halved the amount of buffer data to save memory (KLINES_LIM, ALL_TRADES_LIST_LIMIT, TRADES_LIST_LIMIT)
- #58 A failed optimization of martin_binance/margin_wrapper.buffered_orders() was in version 1.2.16
- Correct ending GRID ONLY cycle if USE_ALL_FUND = False
- Refactoring set_profit() for precision calculate TP order price
- Parameter PROFIT_K excluded
- README.md
- Binance: REST API update for endpoint: GET /api/v3/exchangeInfo was changed MIN_NOTIONAL filter
- up requirements for exchanges-wrapper to 1.2.10-6
- Handling missed order event after restore from current state
- Exception [<class 'decimal.DivisionByZero'>] if PROFIT_MAX is not setting
- Some minor improvements
- up requirements for exchanges-wrapper to 1.2.10-5
- Bitfinex: was changed balance update order #56
- Refactoring and updated auto-convert possibilities Grid only mode
- up requirements for exchanges-wrapper to 1.2.10-4
- Periodically checking WSS status for active trade by client side. This correctly stops the server-side service in the event of an abnormal client shutdown and guarantees the service for an active trading session.
- Fixed #53
- Transfer free assets to main account, resolve #54
- Some minor improvements
- up requirements for exchanges-wrapper to 1.2.9-2
- Restart option for Telegram remote control from last saved state
- Some minor improvements
- up requirements for exchanges-wrapper to 1.2.9-1
- Optimized numerical solution of grid parameters in Reverse cycle to avoid rare cases of calculation failure
- search for a solution with the specified or maximum possible accuracy
- effectively finding possible accuracy, as a result, reducing the number of iterations by about 4 times
- forced displacement of the starting point during looping allows to find a solution with possible accuracy, if it exists under given conditions
- Config templates
- Removing FTX smell
- Add cumulative Free assets chart into Grafana template
- up requirements for exchanges-wrapper to 1.2.9
- Add connection to Binance US (binance.us)
- up requirements for exchanges-wrapper to 1.2.8
- fix #43, import error in margin mode under Windows
- fix #42
- up requirements for exchanges-wrapper to 1.2.7-7
- fix #39, fix #40, fix #41
- grid_handler: No grid orders after part filled TP, fixed additional order params and part code refactoring
- up requirements for exchanges-wrapper to 1.2.7-6
- Some minor improvements
- OKX: adding delay in place_limit_order() for avoid exceeding the rate limit (60 orders / 2s)
- Some minor improvements
- up requirements for exchanges-wrapper to 1.2.7-5
- up requirements for exchanges-wrapper to 1.2.7-4
- saving the state for partially executed orders as float() instead of Decimal() causes an error when restarting from the saved state if the last snapshot contains partial execution data.
- save/restore internal order_id
- up requirements for exchanges-wrapper to 1.2.7-3
- internal numbering for orders
- Processing of partial order execution events is linked to a specific order number. Previously, events were processed sequentially, which led to an error when the order of receiving events was violated.
- Dependency to exchanges-wrapper 1.2.7-1
- #36
- #37
- After restart from saved state incorrect value for first_run may cause incorrect data to be saved for the start deposit. Because of this, the control of initial balances may not work correctly.
- Calculate parameters for grid. Adding price limitation based on PERCENT_PRICE filter. Without such limit, the task of finding grid parameters for a given volume has several solutions, including in the area of negative price values. This is an unlikely event that could have been within the Reverse buy cycle and high volatility
- Changed logic for place order error handling. Before - save to hold uncompleted order and wait event from exchange. Now - resend order after timeout.
- Refactoring place_grid() and calc_grid()
- Before start of cycle and in periodically report are showed free assets' data, what volume of coins does not participate in the turnover
19/10 22:26:23 Start
Start process for .db save
Start process for Telegram
Number of unreachable objects collected by GC: 16
19/10 22:26:23 Initial first: 1.009025, second: 9829.04880062
19/10 22:26:23 Free: First: 1.009025, second: 9629.04880062
19/10 22:26:24 Start Buy cycle with 200.0 USDT depo
- #7 Allow to withdraw and deposit on active strategy with autocorrection initial balance and depo. See manual for detail
- Refusal to use PROFIT_REVERSE parameter. Valid for Reverse cycle. For a small deposit, the cycle income can be equal to the minimum order size step. If you divide it into parts to increase the deposit and make a profit, as a result of rounding the deposit amount does not increase, which negatively affects the ability of the strategy to complete the reverse cycle. Instead, all cycle profits are allocated either to increase the deposit (for an odd cycle number) or to accumulate profits (for an even cycle number)
- Huobi exchange implemented
- Dependency exchanges-wrapper==1.2.6
- For analytic export replace Bitfinex mapping from "IOTA to MIOTA" to "IOT to MIOTA"
- Migration transition solution cleared for saved_state from 1.2.6 - > 1.2.7
- lgtm [py/unused-import]
- get_min_buy_amount()
- For analytic export replace IOTA to MIOTA for Bitfinex
- dependency exchanges-wrapper up to 1.2.5-3
- Powered by Docker deploy
- #26 #29 - add preliminary calculation of grid parameters
25/09 16:33:07 set_trade_conditions: buy_side: False, depo: 0.050000, base_price: 18950.35, reverse_target_amount: 0, amount_min: 0.000528, step_size: 0.000001, delta_min: 0.01
25/09 16:33:07 set_trade_conditions: depo: 0.050000, order_q: 48, amount_first_grid: 0.000528, amount_2: 0.0005808, q_max: 24, coarse overprice: 1.210355
25/09 16:33:07 For Sell cycle will be set 24 orders for 1.2104% over priceBefore start, you can correct value depo and other trade parameters
- #30 Incorrect conversion to comparable currency at initial check of deposit volume
- For analytic export replace IOT to IOTA for Bitfinex
- If it is not possible to calculate the price overlap for the cycle reverse, its value set to coarse estimate * 2 instead of the OVER_PRICE
- In saved state added StrategyBase.trades. This is for correct restore if order was filled partially
README.md - renewed installation chapter
- Disconnecting the gRPC server is now safe, auto reconnect with full recovery of the current session
- Incorrect settings for max grid orders count at grid update (Filter failure: MIN_NOTIONAL)
- requirements.txt exchanges-wrapper>=1.2.4-5
- up to Python 3.10.6
- 1.2.5-3 update on_place_order_error_string() to avoid the cyclical sending of an order rejected by the exchange
- Update readme - limit for several pair with intersecting coin
- if not FEE_IN_PAIR and Reverse: underreporting of income as a result of excess fee accrual
- calculate round quote pattern
- optimize place grid method
- implemented first grid order volume calculating for effective FTX trading
- Incorrect calculation TP parameters for TP sell, price < 1, (fee + profit) amount < step_size
- Protect against OS failures when saving a state file
- No help it Telegram bot For Telegram bot set up command menu and online help
- Dependencies
- Refactoring calculate TP
- Refactoring calculate over price
- Add \n on each input request
- Handling HTTP 429 error for coinmarketcap
- Restore strategy from saved state after restart - get and handling missed event before the state was loaded
- Max retries exceeded with url: * for Telegram requests.post()
- After restart save previous last state file into .bak
- Bitfinex exchange for STANDALONE mode added
- Control for first and last grid orders volume added
- For
ex.STATUS_DELAY = 5 # Minute between sending Tlg message about current status, 0 - disableparameter add ability to turn off
- Correct rounding for base and quote assets on different exchanges
- Refactoring method for calculate over price in Reverse cycle
- Up https://pro.coinmarketcap.com API call to v2
If you update from lower versions please change reference in
martin_binance/ms_cfg.toml on next:
`# CoinMarketCap`
`url = "https://pro-api.coinmarketcap.com/v2/tools/price-conversion"`
- ATTENTION: in the required package
exchanges-wrapperwas changed format config fileexchanges_wrapper/exch_srv_cfg.tomlfrom 1.2.0 version. Before update, save old file and transfer configuration data into new. - Finished implemented Decimal calculation for orders processing
- Change data type for
REVERSE_TARGET_AMOUNTparameter incli_XX_AAABBB.py, update it before restart - Renewed Grafana template
- FTX exchange for STANDALONE mode added
- updating grid if market conditions change
- Grafana template
- code refactoring
- control and structure update for funds_rate.db for future updates
- alerting for mismatch of number of orders to strategy status
- updated balance value for direct cycle for analytics
- refined calculation of order parameters for grid, taking into account rounding of price and volume value and correction of parameters of the last order
- Binance API for /api/v3/exchangeInfo
- refactoring funds_rate_exporter.py
- readme.md, add 'For developer' chapter
- handler for cancel order - part filled - correct cancel non-filled part
- release hold grid after check, not place grid
- remove extra messages about receiving the command through the Telegram
- incorrect balance in USD for assets in trading pair (for analytics)
- set min profit for TP also when calculate it before reverse
- Grafana dashboard template, some improvement
- some cycle parameters for export into analytic
- STANDALONE mode (Binance) get asset balances from Funding wallet for analytics
- Set min profit for TP when executing only the penultimate order of the grid
- Modified and tested for macOS
- Readme.md
- Cycle end alert and manual action waiting
- Set min profit for TP when executing the penultimate order of the grid
- TypeError: unsupported operand type(s) for -: 'float' and 'NoneType' At: /executor.py(615):
- margin Windows full functional
- refactoring service process threading
- Added direct access to Binance SPOT API
- Migrate to Decimal() calculation for necessary precision
- Added stop-loss checkpoint for possible bug
- Split logic and initial trading setup
- Added buy/sell asset with grid options
- Full code refactoring
- Readme.md
- Auto calculate round float multiplier
- Added fee processing for second currency only, like as KRAKEN
- For analytic subsystem added consolidated asset valuation
- Additional check for Error when place and cancel order
- Recovery state logic implemented
- For ADAPTIVE_TRADE_CONDITION adaptive calculate grid orders quantity
- Message 'Waiting ending cycle for manual action' instead of 'Stop...'
- Code refactoring
- Place grid orders by part block for first ORDER_Q count and one by one for next
- Readme.md
- Send Telegram messages periodically that bot still alive
- Added adaptive profit calculate based on Bollinger band
- Added config for prometheus_client
- Added 'no loss' over price calculate for Reverse cycle grid
- Added Average Directional Index analysis to optimize Reverse solution
- Difference k for top and bottom BB line
- Readme.md
- Calculate price of grid orders by logarithmic scale
- Added cycle result data for save into t_funds
- Readme.md
- Refactoring and optimise calculate and place take profit order
- Optimise saving funds and cycle data to .db
- Check if the take profit order execute by market and process it
- Optimize send Telegram message and save to .db function
- Create public edition
- Fix funds call error
- Commented service functions
- Added setup info into docstring
- External control from Telegram bot
