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

allow setting custom URL for CCXT-rest server #167

Merged
merged 1 commit into from
May 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
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