-
Notifications
You must be signed in to change notification settings - Fork 210
Fix: Dynamic Precision Fetching from Binance API #4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
…d values Problem: - Binance API was rejecting orders with error -1111: 'Precision is over the maximum defined for this asset' - Hardcoded precision maps became outdated and didn't match actual API requirements Changes: - Add getPrecisions() method to fetch stepSize and tickSize from Binance API - Update formatQuantity() to use cached symbol info with dynamic precision calculation - Update formatPrice() to use PRICE_FILTER tickSize from API - Pre-load symbol info in placeOrder() before formatting to ensure cache is populated - Add debug logging for quantity formatting Benefits: - Eliminates precision errors by using actual API specifications - Automatically adapts to any symbol without code changes - More maintainable - no need to update hardcoded values - Improved error handling with fallback defaults
|
不错...我之前也试过有些情况出错, 不过为了快速验证功能, 就先硬编码了. 我现在jest那里配置覆盖率要达80 coverageThreshold: { 你可以先跑一次npm run test:coverage 看看, 如果不达标, 最好补一下单元测试 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses the Binance API error -1111: Precision is over the maximum defined for this asset by replacing hardcoded precision mappings with dynamic precision fetching from the Binance API. The solution retrieves stepSize and tickSize from exchange info filters and automatically calculates the required decimal places for quantities and prices.
Key Changes:
- Added
getPrecisions()method to fetch precision dynamically from LOT_SIZE and PRICE_FILTER - Introduced
formatQuantityAsync()for async precision formatting - Updated
formatQuantity()andformatPrice()to use cached symbol info - Modified
placeOrder()to preload symbol information before order submission
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
-----------------------------|---------|----------|---------|---------|----------------------------------------------------------
@terryso 修复并增加了对应的单元测试,现在覆盖率已达标 |

问题描述
Binance API 在发送订单时返回错误
-1111: Precision is over the maximum defined for this asset,导致交易失败。根因:代码使用了硬编码的精度映射表,这些值可能过期或不准确。
解决方案
stepSize(数量精度)和tickSize(价格精度)主要改动
优势
测试状态