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

Commit

Permalink
allow setting custom URL for CCXT-rest server (#167), closes #131
Browse files Browse the repository at this point in the history
  • Loading branch information
nikhilsaraf authored May 6, 2019
1 parent 5416d78 commit 3c9af0c
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 1 deletion.
9 changes: 9 additions & 0 deletions cmd/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/stellar/kelp/support/monitoring"
"github.com/stellar/kelp/support/networking"
"github.com/stellar/kelp/support/prefs"
"github.com/stellar/kelp/support/sdk"
"github.com/stellar/kelp/support/utils"
"github.com/stellar/kelp/trader"
)
Expand Down Expand Up @@ -423,6 +424,14 @@ func runTradeCmd(options inputs) {
}
}

if botConfig.CcxtRestURL != nil {
e := sdk.SetBaseURL(*botConfig.CcxtRestURL)
if e != nil {
logger.Fatal(l, fmt.Errorf("unable to set CCXT-rest URL to '%s': %s", *botConfig.CcxtRestURL, e))
}
}
l.Infof("using CCXT-rest URL: %s\n", sdk.GetBaseURL())

ieif := plugins.MakeIEIF(botConfig.IsTradingSdex())
network := utils.ParseNetwork(botConfig.HorizonURL)
exchangeShim, sdex := makeExchangeShimSdex(
Expand Down
3 changes: 3 additions & 0 deletions examples/configs/trader/sample_trader.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ FILL_TRACKER_DELETE_CYCLES_THRESHOLD=0
# the url for your horizon instance. If this url contains the string "test" then the bot assumes it is using the test network.
HORIZON_URL="https://horizon-testnet.stellar.org"

# the URL to use for your CCXT-rest instance. Defaults to http://localhost:3000 if unset
#CCXT_REST_URL="http://localhost:3000"

# specify parameters for how we compute the operation fee from the /fee_stats endpoint
[FEE]
# trigger when "ledger_capacity_usage" in /fee_stats is >= this value
Expand Down
16 changes: 15 additions & 1 deletion support/sdk/ccxt.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,21 @@ import (
)

// ccxtBaseURL should not have suffix of '/'
const ccxtBaseURL = "http://localhost:3000"
var ccxtBaseURL = "http://localhost:3000"

// SetBaseURL allows setting the base URL for ccxt
func SetBaseURL(baseURL string) error {
if strings.HasSuffix(baseURL, "/") {
return fmt.Errorf("invalid format for baseURL, should not end with trailing '/': %s", baseURL)
}
ccxtBaseURL = baseURL
return nil
}

// GetBaseURL returns the base URL for ccxt
func GetBaseURL() string {
return ccxtBaseURL
}

// Ccxt Rest SDK (https://github.com/franz-see/ccxt-rest, https://github.com/ccxt/ccxt/)
type Ccxt struct {
Expand Down
1 change: 1 addition & 0 deletions trader/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ type BotConfig struct {
FillTrackerSleepMillis uint32 `valid:"-" toml:"FILL_TRACKER_SLEEP_MILLIS"`
FillTrackerDeleteCyclesThreshold int64 `valid:"-" toml:"FILL_TRACKER_DELETE_CYCLES_THRESHOLD"`
HorizonURL string `valid:"-" toml:"HORIZON_URL"`
CcxtRestURL *string `valid:"-" toml:"CCXT_REST_URL"`
Fee *FeeConfig `valid:"-" toml:"FEE"`
CentralizedPricePrecisionOverride *int8 `valid:"-" toml:"CENTRALIZED_PRICE_PRECISION_OVERRIDE"`
CentralizedVolumePrecisionOverride *int8 `valid:"-" toml:"CENTRALIZED_VOLUME_PRECISION_OVERRIDE"`
Expand Down

0 comments on commit 3c9af0c

Please sign in to comment.