Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Add tests for the volume filter (part of #483) #552

Merged
merged 19 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 6 additions & 20 deletions plugins/volumeFilter.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ func makeFilterVolume(
return nil, fmt.Errorf("could not convert quote asset (%s) from trading pair via the passed in assetDisplayFn: %s", string(tradingPair.Quote), e)
}

dailyVolumeByDateQuery, e := makeDailyVolumeByDateQuery(db, exchangeName, baseAssetString, quoteAssetString, config.optionalAccountIDs, config.additionalMarketIDs)
marketID := MakeMarketID(exchangeName, baseAssetString, quoteAssetString)
marketIDs := utils.Dedupe(append([]string{marketID}, config.additionalMarketIDs...))
dailyVolumeByDateQuery, e := queries.MakeDailyVolumeByDateForMarketIdsAction(db, marketIDs, "sell", config.optionalAccountIDs)
if e != nil {
return nil, fmt.Errorf("could not make daily volume by date Query: %s", e)
return nil, fmt.Errorf("could not make daily volume by date action: %s", e)
debnil marked this conversation as resolved.
Show resolved Hide resolved
}

// TODO DS Validate the config, to have exactly one asset cap defined; a valid mode; non-nil market IDs; and non-nil optional account IDs.
debnil marked this conversation as resolved.
Show resolved Hide resolved

return &volumeFilter{
name: "volumeFilter",
configValue: configValue,
Expand All @@ -89,24 +93,6 @@ func makeFilterVolume(
}, nil
}

func makeDailyVolumeByDateQuery(
db *sql.DB,
exchangeName string,
baseAsset string,
quoteAsset string,
optionalAccountIDs []string,
additionalMarketIDs []string,
) (*queries.DailyVolumeByDate, error) {
marketID := MakeMarketID(exchangeName, baseAsset, quoteAsset)
marketIDs := utils.Dedupe(append([]string{marketID}, additionalMarketIDs...))
dailyVolumeByDateQuery, e := queries.MakeDailyVolumeByDateForMarketIdsAction(db, marketIDs, "sell", optionalAccountIDs)
if e != nil {
return nil, fmt.Errorf("could not make daily volume by date action: %s", e)
}

return dailyVolumeByDateQuery, nil
}

var _ SubmitFilter = &volumeFilter{}

// Validate ensures validity
Expand Down
Loading