From 4be693d0256ef8f0a9399405032cc15f91a8e547 Mon Sep 17 00:00:00 2001 From: Nikhil Saraf <1028334+nikhilsaraf@users.noreply.github.com> Date: Sun, 25 Oct 2020 22:28:22 +0530 Subject: [PATCH] network speedup: check markets cache for existing symbols in ccxt.go#symbolExists(), closes #559 (#560) * 1 - check markets cache for existing symbols in ccxt.go#symbolExists() * 2 - update circle ci config to use another secret key for trader file to avoid contention * 3 - fix sed command circle ci --- .circleci/config.yml | 14 ++++++++++++++ support/sdk/ccxt.go | 5 +++++ 2 files changed, 19 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index f715edd15..fb793000b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -55,6 +55,18 @@ commands: name: Run Kelp tests command: go test --short -ldflags="-X github.com/stellar/kelp/cmd.version=test_compile -X github.com/stellar/kelp/cmd.guiVersion=test_compile -X github.com/stellar/kelp/cmd.gitBranch=test_compile -X github.com/stellar/kelp/cmd.gitHash=test_compile -X github.com/stellar/kelp/cmd.buildDate=test_compile -X github.com/stellar/kelp/cmd.env=dev" ./... + replace_trader_secret: + steps: + - run: + name: Replace Trader Secret + command: sed -i -e 's/SAOQ6IG2WWDEP47WEJNLIU27OBODMEWFDN6PVUR5KHYDOCVCL34J2CUD/SCNWRBLLRCPKKMFTDBU2JN6DWOLJ42FGOQHVF62FMXRQRI7HEERAAO2B/' examples/configs/trader/sample_trader.cfg + + replace_source_secret: + steps: + - run: + name: Replace Source Secret + command: sed -i -e 's/SDDAHRX2JB663N3OLKZIBZPF33ZEKMHARX362S737JEJS2AX3GJZY5LU/SCNWRBLLRCPKKMFTDBU2JN6DWOLJ42FGOQHVF62FMXRQRI7HEERAAO2B/' examples/configs/trader/sample_trader.cfg + test_kelp__integration_delete: steps: - run: @@ -106,6 +118,8 @@ jobs: # don't list sell_twap strategy for now because it requires a db to be enabled in sample_trader.cfg - install_deps - build_kelp + - replace_trader_secret + - replace_source_secret # delete once before we start our set of tests, don't delete in between tests because of rate limit issues - test_kelp__integration_delete - test_kelp__integration_buysell diff --git a/support/sdk/ccxt.go b/support/sdk/ccxt.go index d2f8e2954..b73f23825 100644 --- a/support/sdk/ccxt.go +++ b/support/sdk/ccxt.go @@ -226,6 +226,11 @@ func (c *Ccxt) newInstance(apiKey api.ExchangeAPIKey, params []api.ExchangeParam // symbolExists returns an error if the symbol does not exist func (c *Ccxt) symbolExists(tradingPair string) error { + if _, ok := c.markets[tradingPair]; ok { + log.Printf("found trading pair symbol '%s' in markets map", tradingPair) + return nil + } + // get list of symbols available on exchange url := ccxtBaseURL + pathExchanges + "/" + c.exchangeName + "/" + c.instanceName // decode generic data (see "https://blog.golang.org/json-and-go#TOC_4.")