fix: address code review issues for GetOpenOrders

- Add error logging for OKX/Bitget API failures (was silently swallowed)
- Fix Lighter position side logic to handle reduce-only orders
- Change verbose debug logs from Infof to Debugf level
This commit is contained in:
tinkle-community
2026-01-13 13:38:09 +08:00
parent 13189fa3aa
commit aa7aa94275
4 changed files with 31 additions and 9 deletions

View File

@@ -713,10 +713,20 @@ func (t *LighterTraderV2) GetOpenOrders(symbol string) ([]OpenOrder, error) {
orderType = "TAKE_PROFIT_MARKET"
}
// Determine position side based on order direction
// Determine position side based on order direction and reduce-only flag
positionSide := "LONG"
if side == "SELL" {
positionSide = "SHORT"
if order.ReduceOnly {
// For reduce-only orders, position side is opposite to order side
if side == "BUY" {
positionSide = "SHORT" // Buying to close short
} else {
positionSide = "LONG" // Selling to close long
}
} else {
// For opening orders
if side == "SELL" {
positionSide = "SHORT"
}
}
// Parse price and quantity from string fields