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

Commit 9062d7d

Browse files
committed
add "daily" param in the volume filter string to allow future improvments with the same interface
1 parent d65d2d6 commit 9062d7d

2 files changed

Lines changed: 11 additions & 8 deletions

File tree

examples/configs/trader/sample_trader.cfg

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ HORIZON_URL="https://horizon-testnet.stellar.org"
103103
# # - "ignore" indicates that the volume filter should not modify the values of any offer and the offer which will cause
104104
# # the capacity limit to be exceeded should be dropped or ignored. This will result in a less than or equal amount
105105
# # of the asset to be sold for the given day.
106-
# "volume/sell/base/3500.0/exact",
106+
# "volume/daily/sell/base/3500.0/exact",
107107
#
108108
# # limit the amount of the base asset that is sold every day, denominated in units of the quote asset (needs POSTGRES_DB)
109109
# # The fifth param can be either "exact" or "ignore" ("exact" is recommended):
@@ -113,7 +113,7 @@ HORIZON_URL="https://horizon-testnet.stellar.org"
113113
# # - "ignore" indicates that the volume filter should not modify the values of any offer and the offer which will cause
114114
# # the capacity limit to be exceeded should be dropped or ignored. This will result in a less than or equal amount
115115
# # of the asset to be sold for the given day.
116-
# "volume/sell/quote/1000.0/ignore",
116+
# "volume/daily/sell/quote/1000.0/ignore",
117117
#
118118
# # limit offers based on a minimim price requirement
119119
# "price/min/0.04",

plugins/filterFactory.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,25 +44,28 @@ func (f *FilterFactory) MakeFilter(configInput string) (SubmitFilter, error) {
4444

4545
func filterVolume(f *FilterFactory, configInput string) (SubmitFilter, error) {
4646
parts := strings.Split(configInput, "/")
47-
if len(parts) != 5 {
48-
return nil, fmt.Errorf("invalid input (%s), needs 5 parts separated by the delimiter (/)", configInput)
47+
if len(parts) != 6 {
48+
return nil, fmt.Errorf("invalid input (%s), needs 6 parts separated by the delimiter (/)", configInput)
4949
}
5050

51-
mode, e := parseVolumeFilterMode(parts[4])
51+
mode, e := parseVolumeFilterMode(parts[5])
5252
if e != nil {
5353
return nil, fmt.Errorf("could not parse volume filter mode from input (%s): %s", configInput, e)
5454
}
5555
config := &VolumeFilterConfig{mode: mode}
5656
if parts[1] != "sell" {
5757
return nil, fmt.Errorf("invalid input (%s), the second part needs to be \"sell\"", configInput)
5858
}
59-
limit, e := strconv.ParseFloat(parts[3], 64)
59+
if parts[2] != "daily" {
60+
return nil, fmt.Errorf("invalid input (%s), the third part needs to be \"daily\"", configInput)
61+
}
62+
limit, e := strconv.ParseFloat(parts[4], 64)
6063
if e != nil {
6164
return nil, fmt.Errorf("could not parse the fourth part as a float value from config value (%s): %s", configInput, e)
6265
}
63-
if parts[2] == "base" {
66+
if parts[3] == "base" {
6467
config.SellBaseAssetCapInBaseUnits = &limit
65-
} else if parts[2] == "quote" {
68+
} else if parts[3] == "quote" {
6669
config.SellBaseAssetCapInQuoteUnits = &limit
6770
} else {
6871
return nil, fmt.Errorf("invalid input (%s), the third part needs to be \"base\" or \"quote\"", configInput)

0 commit comments

Comments
 (0)