-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1627 from c9s/kbearXD/grid/fee-processing
FEATURE: [grid2] use feeProcessing field to make sure the trading fee…
- Loading branch information
Showing
5 changed files
with
46 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package retry | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"github.com/c9s/bbgo/pkg/types" | ||
) | ||
|
||
func QueryTradesUntilSuccessful( | ||
ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, q *types.TradeQueryOptions, | ||
) (trades []types.Trade, err error) { | ||
var op = func() (err2 error) { | ||
trades, err2 = ex.QueryTrades(ctx, symbol, q) | ||
for _, trade := range trades { | ||
if trade.FeeProcessing { | ||
return fmt.Errorf("trade fee of #%d (order #%d) is still processing", trade.ID, trade.OrderID) | ||
} | ||
} | ||
return err2 | ||
} | ||
|
||
err = GeneralBackoff(ctx, op) | ||
return trades, err | ||
} | ||
|
||
func QueryTradesUntilSuccessfulLite( | ||
ctx context.Context, ex types.ExchangeTradeHistoryService, symbol string, q *types.TradeQueryOptions, | ||
) (trades []types.Trade, err error) { | ||
var op = func() (err2 error) { | ||
trades, err2 = ex.QueryTrades(ctx, symbol, q) | ||
for _, trade := range trades { | ||
if trade.FeeProcessing { | ||
return fmt.Errorf("trade fee of #%d (order #%d) is still processing", trade.ID, trade.OrderID) | ||
} | ||
} | ||
return err2 | ||
} | ||
|
||
err = GeneralLiteBackoff(ctx, op) | ||
return trades, err | ||
} |
This file contains 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
This file contains 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
This file contains 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