mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 00:35:15 +00:00
service: fix margin sync with asset condition
This commit is contained in:
parent
c59c8638be
commit
1ea72099ed
|
@ -34,7 +34,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
|
||||||
|
|
||||||
tasks := []SyncTask{
|
tasks := []SyncTask{
|
||||||
{
|
{
|
||||||
Select: SelectLastMarginLoans(ex.Name(), 100),
|
Select: SelectLastMarginLoans(ex.Name(), asset, 100),
|
||||||
Type: types.MarginLoan{},
|
Type: types.MarginLoan{},
|
||||||
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
||||||
query := &batch.MarginLoanBatchQuery{
|
query := &batch.MarginLoanBatchQuery{
|
||||||
|
@ -51,7 +51,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
|
||||||
LogInsert: true,
|
LogInsert: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Select: SelectLastMarginRepays(ex.Name(), 100),
|
Select: SelectLastMarginRepays(ex.Name(), asset, 100),
|
||||||
Type: types.MarginRepay{},
|
Type: types.MarginRepay{},
|
||||||
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
||||||
query := &batch.MarginRepayBatchQuery{
|
query := &batch.MarginRepayBatchQuery{
|
||||||
|
@ -68,7 +68,7 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
|
||||||
LogInsert: true,
|
LogInsert: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Select: SelectLastMarginInterests(ex.Name(), 100),
|
Select: SelectLastMarginInterests(ex.Name(), asset, 100),
|
||||||
Type: types.MarginInterest{},
|
Type: types.MarginInterest{},
|
||||||
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
BatchQuery: func(ctx context.Context, startTime, endTime time.Time) (interface{}, chan error) {
|
||||||
query := &batch.MarginInterestBatchQuery{
|
query := &batch.MarginInterestBatchQuery{
|
||||||
|
@ -114,26 +114,26 @@ func (s *MarginService) Sync(ctx context.Context, ex types.Exchange, asset strin
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func SelectLastMarginLoans(ex types.ExchangeName, limit uint64) sq.SelectBuilder {
|
func SelectLastMarginLoans(ex types.ExchangeName, asset string, limit uint64) sq.SelectBuilder {
|
||||||
return sq.Select("*").
|
return sq.Select("*").
|
||||||
From("margin_loans").
|
From("margin_loans").
|
||||||
Where(sq.Eq{"exchange": ex}).
|
Where(sq.Eq{"exchange": ex, "asset": asset}).
|
||||||
OrderBy("time DESC").
|
OrderBy("time DESC").
|
||||||
Limit(limit)
|
Limit(limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SelectLastMarginRepays(ex types.ExchangeName, limit uint64) sq.SelectBuilder {
|
func SelectLastMarginRepays(ex types.ExchangeName, asset string, limit uint64) sq.SelectBuilder {
|
||||||
return sq.Select("*").
|
return sq.Select("*").
|
||||||
From("margin_repays").
|
From("margin_repays").
|
||||||
Where(sq.Eq{"exchange": ex}).
|
Where(sq.Eq{"exchange": ex, "asset": asset}).
|
||||||
OrderBy("time DESC").
|
OrderBy("time DESC").
|
||||||
Limit(limit)
|
Limit(limit)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SelectLastMarginInterests(ex types.ExchangeName, limit uint64) sq.SelectBuilder {
|
func SelectLastMarginInterests(ex types.ExchangeName, asset string, limit uint64) sq.SelectBuilder {
|
||||||
return sq.Select("*").
|
return sq.Select("*").
|
||||||
From("margin_interests").
|
From("margin_interests").
|
||||||
Where(sq.Eq{"exchange": ex}).
|
Where(sq.Eq{"exchange": ex, "asset": asset}).
|
||||||
OrderBy("time DESC").
|
OrderBy("time DESC").
|
||||||
Limit(limit)
|
Limit(limit)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user