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

Kelp should fetch Kraken markets automatically from API #106

Closed
skirsch opened this issue Feb 18, 2019 · 3 comments
Closed

Kelp should fetch Kraken markets automatically from API #106

skirsch opened this issue Feb 18, 2019 · 3 comments
Labels
bug Something isn't working
Projects
Milestone

Comments

@skirsch
Copy link

skirsch commented Feb 18, 2019

// see a sample bug report here: #1

Describe the bug

// A succinct description of the buggy behavior.
// This section includes what the bot is doing and why you think it is incorrect.

The bot crashes when trying to get price of ETH and XRP from kraken

Expected behavior

// A succinct description of what you expected to happen.

I think the correct behavior in this situation is for the bot not to crash

Frequency

// How often does this happen?
// Unpredictable = it's hard to predict when it will happen
// Sometimes = it happens every now and then but there's no pattern to it
// Always = it always happens consistently at the same point

The frequency is: always

Steps To Reproduce

// A concise description of the steps to reproduce the buggy behavior along with screenshots wherever applicable:

Here are the steps to reproduce the issue (see attachments in section below):

  1. Set up your configuration file with these parameters: ...
  2. Start the bot using this command: ...
    ...

Possible Solution

// Optional, suggest a fix.

This bug can be fixed by ...

Your Environment

// Run kelp version to get the version and build information and paste it here
// version: v1.0.0-rc1
// git hash: 1bcc4e9
// build date: 20180813T013016Z
// GOOS: linux
// GOARCH: amd64
2019/02/18 15:39:31 Starting Kelp Trader: master:v1.3.0 [e19784f]
2019/02/18 15:39:31 will run unbounded iterations
2019/02/18 15:39:31 configs:
2019/02/18 15:39:31 SOURCE_SECRET_SEED: [secret key to account GDOKOU3V2GTPDKR23HRLKKAVMSGVXIJVX6ZR2RSTW4WU7JSVZUG5SPP2]
2019/02/18 15:39:31 TRADING_SECRET_SEED: [secret key to account GBL33TLIFJG2D7KZYMJY5H5NMZE2DHQNZSPNJMTWE76V7N6CTYGPW7DC]
2019/02/18 15:39:31 ASSET_CODE_A: USD
2019/02/18 15:39:31 ISSUER_A: GDSRCV5VTM3U7Y3L6DFRP3PEGBNQMGOWSRTGSBWX6Z3H6C7JHRI4XFJP
2019/02/18 15:39:31 ASSET_CODE_B: ETH
2019/02/18 15:39:31 ISSUER_B: GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5
2019/02/18 15:39:31 TICK_INTERVAL_SECONDS: 180
2019/02/18 15:39:31 MAX_TICK_DELAY_MILLIS: 60000
2019/02/18 15:39:31 DELETE_CYCLES_THRESHOLD: 4
2019/02/18 15:39:31 FILL_TRACKER_SLEEP_MILLIS: 0
2019/02/18 15:39:31 HORIZON_URL: https://horizon.stellar.org
2019/02/18 15:39:31 ALERT_TYPE:
2019/02/18 15:39:31 ALERT_API_KEY:
2019/02/18 15:39:31 MONITORING_PORT: 0
2019/02/18 15:39:31 MONITORING_TLS_CERT:
2019/02/18 15:39:31 MONITORING_TLS_KEY:
2019/02/18 15:39:31 GOOGLE_CLIENT_ID:
2019/02/18 15:39:31 GOOGLE_CLIENT_SECRET:
2019/02/18 15:39:31 ACCEPTABLE_GOOGLE_EMAILS:
2019/02/18 15:39:31 Trading USD:GDSRCV5VTM3U7Y3L6DFRP3PEGBNQMGOWSRTGSBWX6Z3H6C7JHRI4XFJP for ETH:GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5
2019/02/18 15:39:31 Using network passphrase: Public Global Stellar Network ; September 2015
2019/02/18 15:39:31 Making strategy: buysell
2019/02/18 15:39:31 configs:
2019/02/18 15:39:31 PRICE_TOLERANCE: 0.001
2019/02/18 15:39:31 AMOUNT_TOLERANCE: 0.05
2019/02/18 15:39:31 RATE_OFFSET_PERCENT: 0
2019/02/18 15:39:31 RATE_OFFSET: 0
2019/02/18 15:39:31 RATE_OFFSET_PERCENT_FIRST: true
2019/02/18 15:39:31 AMOUNT_OF_A_BASE: 1
2019/02/18 15:39:31 DATA_TYPE_A: fixed
2019/02/18 15:39:31 DATA_FEED_A_URL: 1.0
2019/02/18 15:39:31 DATA_TYPE_B: exchange
2019/02/18 15:39:31 DATA_FEED_B_URL: kraken/XETH/ZUSD
2019/02/18 15:39:31 LEVELS: [{SPREAD:0.0005 AMOUNT:4} {SPREAD:0.005 AMOUNT:70} {SPREAD:0.01 AMOUNT:125} {SPREAD:0.02 AMOUNT:250}]
2019/02/18 15:39:31 validating trustlines...
2019/02/18 15:39:31 trustlines valid
2019/02/18 15:39:31 Starting the trader bot...
2019/02/18 15:39:31 ----------------------------------------------------------------------------------------------------
2019/02/18 15:39:31 (base) assetA=USD:GDSRCV5VTM3U7Y3L6DFRP3PEGBNQMGOWSRTGSBWX6Z3H6C7JHRI4XFJP, maxA=51126.6174401, trustA=922337203685.4775391
2019/02/18 15:39:31 (quote) assetB=ETH:GBVOL67TMUQBGL4TZYNMY3ZQ5WGQYFPFD5VJRWXR72VA33VFNL225PL5, maxB=310.7684154, trustB=922337203685.4775391
2019/02/18 15:39:34 liabilities after resetting
2019/02/18 15:39:34 asset=base , balance=51126.6174401, trust=922337203685.4775391, minAccountBal=51.1266174, buyingLiabilities=20944.0001331, sellingLiabilities=21443.9997539
2019/02/18 15:39:34 asset=quote , balance=310.7684154, trust=922337203685.4775391, minAccountBal=0.3107684, buyingLiabilities=0.0000000, sellingLiabilities=0.0000000
2019/02/18 15:39:35 asset=native, balance=398351.8089198, trust=math.MaxFloat64, minAccountBal=77.0000000, buyingLiabilities=119134.7785240, sellingLiabilities=106543.6739943
2019/02/18 15:39:35 returning kraken API key at index 0
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7a415b]

goroutine 1 [running]:
github.com/interstellar/kelp/plugins.(*krakenExchange).GetTickerPrice(0xc4200737c0, 0xc4202450c0, 0x1, 0x1, 0xe0, 0xaf, 0x0)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/plugins/krakenExchange.go:301 +0x32b
github.com/interstellar/kelp/plugins.(*exchangeFeed).GetPrice(0xc42027c090, 0xc4202e6cc0, 0x7b42b4, 0x954f08)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/plugins/exchangeFeed.go:32 +0x67
github.com/interstellar/kelp/api.(*FeedPair).GetCenterPrice(0xc4202450e0, 0x426ad7f29abcaf48, 0xc42034d400, 0x9fc53e81)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/api/priceFeed.go:18 +0x48
github.com/interstellar/kelp/plugins.(*staticSpreadLevelProvider).GetLevels(0xc420073810, 0x40736c4b6df24be2, 0x40e8f6d3c211bd98, 0xc42034d920, 0x866a00, 0xc42034d928, 0x866a00, 0xc42034d930)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/plugins/staticSpreadLevelProvider.go:60 +0x44
github.com/interstellar/kelp/plugins.(*sellSideStrategy).PreUpdate(0xc42001d600, 0x40736c4b6df24be2, 0x40e8f6d3c211bd98, 0x426ad7f29abcaf48, 0x426ad7f29abcaf48, 0xc420023100, 0x38)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/plugins/sellSideStrategy.go:146 +0x1a2
github.com/interstellar/kelp/plugins.(*composeStrategy).PreUpdate(0xc42027c0c0, 0x40e8f6d3c211bd98, 0x40736c4b6df24be2, 0x426ad7f29abcaf48, 0x426ad7f29abcaf48, 0xc420023040, 0x38)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/plugins/composeStrategy.go:52 +0x74
github.com/interstellar/kelp/trader.(*Trader).update(0xc4202e77a8)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/trader/trader.go:162 +0x2bb
github.com/interstellar/kelp/trader.(*Trader).Start(0xc4202e77a8)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/trader/trader.go:89 +0x258
github.com/interstellar/kelp/cmd.init.4.func2(0xc013a0, 0xc420061860, 0x0, 0x6)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/cmd/trade.go:249 +0x11b2
github.com/interstellar/kelp/vendor/github.com/spf13/cobra.(*Command).execute(0xc013a0, 0xc420061800, 0x6, 0x6, 0xc013a0, 0xc420061800)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/vendor/github.com/spf13/cobra/command.go:702 +0x2c6
github.com/interstellar/kelp/vendor/github.com/spf13/cobra.(*Command).ExecuteC(0xc00d40, 0x403dfc, 0xc42006a058, 0x0)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/vendor/github.com/spf13/cobra/command.go:783 +0x2e4
github.com/interstellar/kelp/vendor/github.com/spf13/cobra.(*Command).Execute(0xc00d40, 0x0, 0x814d10)
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/vendor/github.com/spf13/cobra/command.go:736 +0x2b
main.main()
/Users/nikhilsaraf/dev/go/src/github.com/interstellar/kelp/main.go:10 +0x2d

Context

// A succinct description of how has this bug has affected you or prevented you from accomplishing what you wanted.

I am unable to ... because of this bug.

Attachments

// Attach any relevant configuration files, logs, tx hashes, etc. here.

@skirsch skirsch added the bug Something isn't working label Feb 18, 2019
@nikhilsaraf
Copy link
Contributor

This error is happening because the trading pair is not registered with kelp's krakenExchange integration. You'll need to update this map to enable it as a quick fix: plugins/krakenExchange.go#krakenPrecisionMatrix

I'm going to either find an alternative solution to fetch these markets using Kraken's API (similar to the fix for our ccxt integration), or add support for kraken using the existing CCXT integration.

@nikhilsaraf nikhilsaraf added this to Triage in Kelp via automation Feb 26, 2019
@nikhilsaraf nikhilsaraf moved this from Triage to TODO This Sprint in Kelp Feb 26, 2019
@nikhilsaraf nikhilsaraf moved this from TODO This Sprint to In progress in Kelp Feb 26, 2019
@nikhilsaraf nikhilsaraf changed the title Kelp crashes on ETH and XRP pricing retrieval from Kraken Kelp should fetch Kraken markets automatically from API Feb 26, 2019
@nikhilsaraf
Copy link
Contributor

@skirsch @paul-token you can now use kraken as a price feed directly by using "ccxt-kraken" as your exchange feed (commit)

@nikhilsaraf
Copy link
Contributor

The native Kraken API supports fetching precision data via their API: https://support.kraken.com/hc/en-us/articles/360001389366-Price-and-volume-decimal-precision

However, the native Kraken API does not support fetching the minVolume for each market: https://support.kraken.com/hc/en-us/articles/205893708-What-is-the-minimum-order-size-volume-

minVolume data is hard-coded in the kraken go client, so we're likely better off leaving both precision and minVolume data as a hardcoded map in Kelp for now (krakenPrecisionMatrix) since we combine them into an OrderConstraints object.


If you want to use a price feed from Kraken with a wider variety of markets then consider using the CCXT integration of Kraken: ccxt-kraken for the exchange name in your strategy config.

closing this issue; if there are any requests to add values to plugins/krakenExchange.go#krakenPrecisionMatrix then either submit that as a new issue or preferably directly as a PR.

Kelp automation moved this from In progress to Done Feb 27, 2019
@nikhilsaraf nikhilsaraf moved this from Done to Done (earlier sprints) in Kelp Feb 27, 2019
@nikhilsaraf nikhilsaraf added this to the v1.5.0 milestone Mar 1, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
Kelp
  
Done (earlier sprints)
Development

No branches or pull requests

2 participants