kelp

command module
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 18, 2019 License: Apache-2.0 Imports: 2 Imported by: 0

README

Kelp

GitHub last commit Github All Releases license

Godoc Go Report Card Build Status Contributors

Kelp is a free and open-source trading bot for the Stellar universal marketplace.

Kelp includes several configurable trading strategies and exchange integrations. You can define your own parameters or use the sample configurations to quickly get up and running with a trading bot in a matter of minutes. The modular design allows you to easily create new trading strategies, exchange integrations, and assets to give you full control over the bot.

Kelp is built to:

  • Make spreads and make markets
  • Create liquidity and facilitate price-discovery for ICOs
  • Price and trade custom stablecoins
  • Mimic orderbooks from other exchanges

To learn more about the Stellar protocol check out this video created by Lumenauts. You can also search Stellar's Q&A.

Sign up for the new announcements distribution list and user mailing list

Table of Contents

Getting Started

To get started with Kelp, either download the pre-compiled binary for your platform from the Github Releases Page or compile Kelp from source.

There is one binary associated with this project: kelp. Once the binary is downloaded, run the bot by following the instructions in Running Kelp.

Download Binary

You can find the pre-compiled binary for your platform from the Github Releases Page.

Here is a list of binaries for the most recent release v1.7.1:

Platform Architecture Binary File Name
MacOS (Darwin) 64-bit kelp-v1.7.1-darwin-amd64.tar
Windows 64-bit kelp-v1.7.1-windows-amd64.tar
Linux 64-bit kelp-v1.7.1-linux-amd64.tar
Linux 64-bit arm kelp-v1.7.1-linux-arm64.tar
Linux 32-bit arm5 kelp-v1.7.1-linux-arm5.tar
Linux 32-bit arm6 kelp-v1.7.1-linux-arm6.tar
Linux 32-bit arm7 kelp-v1.7.1-linux-arm7.tar

After you untar the downloaded file, change to the generated directory (kelp-v1.7.1) and invoke the kelp binary.

Here's an example to get you started (replace filename with the name of the file that you download):

tar xvf filename
cd kelp-v1.7.1
./kelp

To run the bot in simulation mode, try this command:

./kelp trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim

Compile from Source

Note for Windows Users: You should use a Bash Shell to follow the steps below. This will give you a UNIX environment in which to run your commands and will enable the ./scripts/build.sh bash script to work correctly.

To compile Kelp from source:

  1. Download and setup Golang.
  2. Install Glide for dependency management
    • curl https://glide.sh/get | sh
  3. Clone the repo into $GOPATH/src/github.com/stellar/kelp:
    • git clone git@github.com:stellar/kelp.git
  4. Change to the kelp directory and install the dependencies:
    • glide install
  5. Build the binaries using the provided build script (the go install command will produce a faulty binary):
    • ./scripts/build.sh
  6. Confirm one new binary file:
    • ./bin/kelp
  7. Set up CCXT to use an expanded set of priceFeeds and orderbooks (see the Using CCXT section for details)

Running Kelp

Kelp places orders on the Stellar marketplace based on the selected strategy. Configuration files specify the Stellar account and strategy details.

These are the following commands available from the kelp binary:

  • trade: Trades with a specific strategy against the Stellar universal marketplace
  • exchanges: Lists the available exchange integrations along with capabilities
  • strategies: Lists the available strategies along with details
  • version: Version and build information
  • help: Help about any command

The trade command has three required parameters which are:

  • botConf: full path to the .cfg file with the account details, sample file here.
  • strategy: the strategy you want to run (sell, buysell, balanced, mirror, delete).
  • stratConf: full path to the .cfg file specific to your chosen strategy, sample files here.

Kelp sets the X-App-Name and X-App-Version headers on requests made to Horizon. These headers help us track overall Kelp usage, so that we can learn about general usage patterns and adapt Kelp to be more useful in the future. These can be turned off using the --no-headers flag. See kelp trade --help for more information.

Here's an example of how to start the trading bot with the buysell strategy:

kelp trade --botConf ./path/trader.cfg --strategy buysell --stratConf ./path/buysell.cfg

If you are ever stuck, just run the kelp binary directly to bring up the help section or type kelp help [command] for help with a specific command.

Using CCXT

You can use the CCXT library via the CCXT REST API Wrapper to fetch prices and orderbooks from a larger number of exchanges.

You will need to run the CCXT REST server on localhost:3000 so Kelp can connect to it. In order to run CCXT you should install docker (linux: sudo apt install -y docker.io) and run the CCXT-REST docker image configured to port 3000 (linux: sudo docker run -p 3000:3000 -d franzsee/ccxt-rest:v0.0.4). You can find more details on the CCXT_REST github page. The CCXT-REST server must be running on port 3000 before you start up the Kelp bot.

You can list the exchanges (./kelp exchanges) to get the full list of supported exchanges via CCXT.

Note: this integration is still experimental and is also incomplete. Please use at your own risk.

Be Smart and Go Slow

Whenever you trade on Stellar, you are trading with volatile assets, in volatile markets, and you risk losing money. Use Kelp at your own risk. There is no guarantee you'll make a profit from using our bots or strategies. In fact, if you set bad parameters or market conditions change, Kelp might help you lose money very fast. So be smart and go slow.

Components

Kelp includes an assortment of strategies, price feeds, and plugins you can use to customize your bot. Kelp also enables you to create your own trading strategies.

Strategies

Strategies are at the core of Kelp. Without them it's just lazy, capable of nothing, thinking of nothing, doing nothing, like our friend scooter here. The strategies give your bot purpose. Each approaches the market in a different way and is designed to achieve a particular goal.

The following strategies are available out of the box with Kelp:

  • sell (source):

    • What: creates sell offers based on a reference price with a pre-specified liquidity depth
    • Why: To sell tokens at a fixed price or at a price that changes based on an external reference price
    • Who: An issuer could use Sell to distribute tokens from an ICO pre-sale
    • Complexity: Beginner
  • buysell (source):

    • What: creates buy and sell offers based on a specific reference price and a pre-specified liquidity depth while maintaining a spread.
    • Why: To make the market for tokens based on a fixed or external reference price.
    • Who: Anyone who wants to create liquidity for a stablecoin or fiat token
    • Complexity: Beginner
  • balanced (source):

    • What: dynamically prices two tokens based on their relative demand. For example, if more traders buy token A from the bot (the traders are therefore selling token B), the bot will automatically raise the price for token A and drop the price for token B.
    • Why: To let the market surface the true price for one token in terms of another.
    • Who: Market makers and traders for tokens that trade only on Stellar
    • Complexity: Intermediate
  • mirror (source):

    • What: mirrors an orderbook from another exchange by placing the same orders on Stellar after including a spread.
    • Why: To hedge your position on another exchange whenever a trade is executed to reduce inventory risk while keeping a spread
    • Who: Anyone who wants to reduce inventory risk and also has the capacity to take on a higher operational overhead in maintaining the bot system.
    • Complexity: Advanced
  • delete (source):

    • What: deletes your offers from both sides of the specified orderbook. Note: does not need a strategy-specific config file.
    • Why: To kill the offers placed by the bot. This is not a trading strategy but is used for operational purposes only.
    • Who: Anyone managing the operations of the bot who wants to stop all activity by the bot.
    • Complexity: Beginner

Price Feeds

Price Feeds fetch the price of an asset from an external source. The following price feeds are available out of the box with Kelp:

  • coinmarketcap: fetches the price of tokens from CoinMarketCap
  • fiat: fetches the price of a fiat currency from the CurrencyLayer API
  • exchange: fetches the price from an exchange you specify, such as Kraken or Poloniex. You can also use the CCXT integration to fetch prices from a wider range of exchanges (see the Using CCXT section for details)
  • fixed: sets the price to a constant

Configuration Files

Each strategy you implement needs a configuration file. The format of the configuration file is specific to the selected strategy. You can use these files to customize parameters for your chosen strategy.

For more details, check out the examples section of the readme.

Exchanges

Exchange integrations provide data to trading strategies and allow you to hedge your positions on different exchanges. The following exchange integrations are available out of the box with Kelp:

  • sdex (source): The Stellar Decentralized Exchange
  • kraken (source): Kraken
  • binance ("ccxt-binance") (source): Binance via CCXT - only supports priceFeeds and mirroring (buysell, sell, and mirror strategy)
  • poloniex ("ccxt-poloniex") (source): Poloniex via CCXT - only supports priceFeeds and mirroring (buysell, sell, and mirror strategy)
  • bittrex ("ccxt-bittrex") (source): Bittrex via CCXT - only supports priceFeeds and mirroring (buysell, sell, and mirror strategy)

Plugins

Kelp can easily be extended because of its modular plugin based architecture. You can create new flavors of the following components: Strategies, PriceFeeds, and Exchanges.

These interfaces make it easy to create plugins:

  • Strategy (source) - API for a strategy
  • PriceFeed (source) - API for price of an asset
  • Exchange (source) - API for crypto exchanges

Directory Structure

The folders are organized to make it easy to find code and streamline development flow. Each folder is its own package without any sub-packages.

github.com/stellar/kelp
├── api/            # API interfaces live here (strategy, exchange, price feeds, etc.)
├── cmd/            # Cobra commands (trade, exchanges, strategies, etc.)
├── examples/       # Sample config files and walkthroughs
├── model/          # Low-level structs (dates, orderbook, etc.)
├── plugins/        # Implementations of API interfaces (sell strategy, kraken, etc.)
├── support/        # Helper functions and utils
├── trader/         # Trader bot logic; uses other top-level packages like api, plugins, etc.
├── glide.yaml      # Glide dependencies
├── main.go         # main function for our kelp binary
└── ...

Accounting

You can use Stellar-Downloader to download trade and payment data from your Stellar account as a CSV file.

Examples

It's easier to learn with examples! Take a look at the walkthrough guides and sample configuration files below.

Walkthrough Guides

Configuration Files

Reference config files are in the examples folder. Specifically, the following sample configuration files are included:

Changelog

See the Changelog.

Community

Contributing

See the Contribution Guide and then please sign the Contributor License Agreement.

Communication

Code of Conduct

See the Code of Conduct.

Project Improvements

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
accounting
pnl
Computes the current balance valued in XLM for the given accounts Makes some assumptions (only works for balanced bot accounts): 1.
Computes the current balance valued in XLM for the given accounts Makes some assumptions (only works for balanced bot accounts): 1.
gui
support
sdk

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL