-
-
Notifications
You must be signed in to change notification settings - Fork 276
/
trade.go
42 lines (36 loc) · 1.05 KB
/
trade.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
}