feat(bitget): support preset TP/SL in single API call#1370
Open
Fumeng24 wants to merge 1 commit intoNoFxAiOS:devfrom
Open
feat(bitget): support preset TP/SL in single API call#1370Fumeng24 wants to merge 1 commit intoNoFxAiOS:devfrom
Fumeng24 wants to merge 1 commit intoNoFxAiOS:devfrom
Conversation
- Add OpenLongWithTPSL/OpenShortWithTPSL methods to Bitget trader - Use presetStopLossPrice and presetStopSurplusPrice parameters - Add FormatPrice method for correct price precision - Auto-detect and use optimized method in auto_trader.go - Fallback to legacy 3-call method for other exchanges - Add trader_test.go for testing Bitget orders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📝 Description
实现 Bitget 交易所的预设止损止盈功能,通过在下单 API 中使用
presetStopLossPrice和presetStopSurplusPrice参数,将原来的 3 次 API 调用优化为单次调用,提高订单设置的可靠性和执行效率。🎯 Type of Change
🔗 Related Issues
📋 Changes Made
OpenLongWithTPSL()和OpenShortWithTPSL()方法,支持在单次 API 调用中设置预设止损止盈FormatPrice()方法处理价格精度(Bitget 要求价格为合约精度的倍数,如 BTC 需要 0.1 的倍数)openLongInternal()和openShortInternal()内部方法,支持可选的 TP/SL 参数executeOpenLongWithRecord()和executeOpenShortWithRecord()中使用类型断言检测 trader 是否支持新的 TPSL 方法TestOpenLongWithTPSL、TestGetBalance、TestGetPositions测试用例🧪 Testing
测试详情:
OpenLongWithTPSL方法FormatPrice方法)✅ Checklist
Code Quality
Documentation
Git
devbranch📚 Additional Notes
技术实现细节
单次 API 调用:使用 Bitget API V2 的
/api/v2/mix/order/place-order端点,在请求体中添加presetStopLossPrice和presetStopSurplusPrice参数价格精度处理:Bitget 对价格精度有严格要求(错误码 45115),通过
FormatPrice()方法根据合约的PricePlace字段格式化价格向后兼容:通过 Go 的类型断言模式,只有 Bitget trader 使用新方法,其他交易所继续使用原有的 3 次调用方式
By submitting this PR, I confirm:
🌟 Thank you for your contribution!