• This repository has been archived on 01/Feb/2024
  • Stars
    star
    1,054
  • Rank 42,058 (Top 0.9 %)
  • Language
    Go
  • License
    Other
  • Created over 5 years ago
  • Updated 6 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Kelp is a free and open-source trading bot for the Stellar DEX and 100+ centralized exchanges

Kelp

Kelp logo

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 and for centralized exchanges such as Binance, Kraken, CoinbasePro, etc.

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 Stellar Videos on Coinbase Earn, or this video about the Stellar DEX created by Lumenauts, or read more about it on the Stellar Website.

Be Smart and Go Slow

Important Disclaimer: Be Smart and Go Slow. Whenever you trade on Stellar, you are trading with volatile assets, in volatile markets, and you risk losing money. Kelp is an experimental software that contains bugs. 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.

Your use of Kelp is governed by the Apache 2.0 open-source license. Please note that SDF’s interactions with you are governed by the SDF Terms of Service and Privacy Policy.

Kelp GUI screenshot

Table of Contents

Getting Started

How To Get Kelp

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 Kelp Binary

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

GUI

Here is a list of binaries for the most recent release v1.0.0-rc2 (v1.12.0):

Platform Architecture Binary File Name
MacOS (Darwin) 64-bit kelp-v1.12.0-darwin-amd64.tar
Windows 64-bit kelp-v1.12.0-windows-amd64.tar
Linux 64-bit kelp-v1.12.0-linux-amd64.tar

CLI

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

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

After you untar the downloaded file, change to the generated directory (kelp-v1.12.0) 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.12.0
./kelp

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

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

Run With Docker

This docker image (nikhilsaraf/kelp:latest) points to the latest pre-compiled version of the kelp binary v1.12.0, which can be run like this:

docker run nikhilsaraf/kelp:latest version docker run nikhilsaraf/kelp:latest trade -c sample_trader.cfg -s buysell -f sample_buysell.cfg --sim docker run nikhilsaraf/kelp:latest exchanges docker run nikhilsaraf/kelp:latest strategies

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 v1.13 or later
    1. Set environment variable export GOPROXY=https://goproxy.io,https://proxy.golang.org,https://goproxy.cn
  2. Install Yarn and NodeJs (Node v12.3.1 via nvm) to build the Kelp GUI
  3. Clone the kelp repository git clone [email protected]:stellar/kelp.git
  4. Install the astilectron-bundler binary
    • go install github.com/asticode/go-astilectron-bundler/astilectron-bundler
  5. Build the binaries using the provided build script (the go install command will produce a faulty binary):
    • ./scripts/build.sh (this must be invoked from root directory i.e. kelp)
  6. Confirm one new binary file exists with version information.
    • ./bin/kelp version
  7. Set up CCXT to use an expanded set of priceFeeds and orderbooks (see the Using CCXT section for details)
    • sudo docker run -p 3000:3000 -d franzsee/ccxt-rest:v0.0.4

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, sell_twap, buysell, balanced, pendulum, 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. Kelp also uses Amplitude for metric tracking. 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 kelp help 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.

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.

CCXT-rest can be run in any one of the following ways.

Download CCXT Binary

We have compiled the ccxt-rest v0.0.4 server as a binary for all x86 platforms (linux, darwin, windows). This is the version that Kelp currently uses.

You can find these pre-compiled binaries of the CCXT-rest server in the releases tab here.

Run CCXT using Docker

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.

Using Postgres

Postgres v12.1 or later must be installed for Kelp to automatically write trades to a sql database along with updating the trader config file.

Using Auth0

A auth0 account is required. To use it, uncomment [AUTH0] section in Sample GUI config file and enter your auth0 crendentials in required fields. Note: AUTH0 is only applicable for Kelp GUI or Kaas Mode. Intructions of how to configure your auth0 account can be found here

Examples

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

Walkthrough Guides

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.

The following reference config files are in the examples folder:

Winning Educational Content from StellarBattle

SDF sponsored a Kelp StellarBattle in August/September 2020, here were the winning results (announcement):

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.

click to expand Components section

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
  • sell_twap (source):

    • What: creates sell offers based on a reference price spread over the day for a given daily sale amount
    • Why: To sell tokens consistently using the time-weighted-average-price (TWAP) metric
    • Who: An issuer could use SellTwap to distribute tokens from an ICO pre-sale in a consistent manner
  • 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
  • balanced (source):

    • What: dynamically prices two tokens based on their relative demand (like AMMs). 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. This strategy does not allow you to configure the order size but can run out of assets. This is a mean-reversion strategy.
    • Why: To let the market surface the true price for one token in terms of another.
    • Who: Market makers and traders for tokens that have a neutral view on the market
  • pendulum (source):

    • What: dynamically prices two tokens based on their relative demand (like AMMs). 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. This strategy allows you to configure the order size but runs the risk of running out of one of the two assets. This is a mean-reversion strategy.
    • Why: To let the market surface the true price for one token in terms of another.
    • Who: Market makers and traders for tokens that have a neutral view on the market
  • 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.
  • 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.

Refer to this Pull Request to see an example template of a new trading strategy.

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:

  • crypto: 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
  • function: uses a pre-defined function to combine the above price feed types into a single feed. We currently support only two types
    • max - max(exchange/ccxt-binance/XLM/USDT/mid,exchange/ccxt-coinbasepro/XLM/USD/mid)
    • invert - invert(exchange/ccxt-binance/XLM/USDT/mid)

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 ("sdex") (source): The Stellar Decentralized Exchange
  • kraken ("kraken") (source): Kraken - recommended to use ccxt-kraken instead
  • kraken (via CCXT) ("ccxt-kraken") (source): Kraken via CCXT - full two-way integration (tested)
  • binance (via CCXT) ("ccxt-binance") (source): Binance via CCXT - full two-way integration (tested)
  • coinbasepro (via CCXT) ("ccxt-coinbasepro") (source): Coinbase Pro via CCXT - full two-way integration (tested)
  • poloniex (via CCXT) ("ccxt-poloniex") (source): Poloniex via CCXT - only tested on priceFeeds and one-way mirroring
  • bittrex (via CCXT) ("ccxt-bittrex") (source): Bittrex via CCXT - only tested on priceFeeds and onw-way mirroring

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.

Community

click to expand Community section

Contributing

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

Changelog

See the Changelog.

Code of Conduct

See the Code of Conduct.

Project Improvements

Public Assets

click to expand Public Assets section

TEST1 and TEST2 issued by the GCL4KBYTRA3QYI4JTN4FWVYVYNI67W2M6XMDUB2V6ZLWFASIYHWEJPHU account are test assets used to test Kelp on the production Stellar Network. These assets have no value and are marked as auth_required with the intent to close them off from the rest of the Stellar ecosystem. No trustlines will be accepted against these assets. As part of our testing process, you may observe a market and trades between these two tokens. It is not intended for any of these assets to represent any meaningful volume on the Stellar Network.

More Repositories

1

stellar-core

Reference implementation for the peer-to-peer agent that manages the Stellar network.
C
3,082
star
2

go

Stellar's public monorepo of go code
Go
1,261
star
3

soroban-example-dapp

End-to-End Example Soroban Dapp
Rust
663
star
4

js-stellar-sdk

Main Stellar client library for the JavaScript language.
JavaScript
595
star
5

stellar-protocol

Developer discussion about possible changes to the protocol.
RPC
488
star
6

slingshot

A new blockchain architecture under active development, with a strong focus on scalability, privacy and safety
Rust
400
star
7

stellar-client

INACTIVE. Browser based client for stellard. This repository is inactive. It points to the stellard network, which is being replaced by stellar-core. Please refer to the replacement repository, interstellar-client, which points to the stellar-core network.
JavaScript
306
star
8

dashboard

JavaScript
212
star
9

quickstart

Home of the stellar/quickstart docker image for development and testing
Shell
174
star
10

java-stellar-sdk

Java
173
star
11

awesome-stellar

πŸ‘¨β€πŸš€ A curated list of Stellar applications, blog posts, educational resources, tools, and more.
158
star
12

js-stellar-base

The lowest-level stellar helper library. It consists of classes to read, write, hash, and sign Stellar xdr
JavaScript
101
star
13

stellar-wallet

Holds encrypted data. Used by stellar-client to store the user's key in a secure way.
JavaScript
101
star
14

django-polaris

An extendable Django app for building modular Stellar services
Python
93
star
15

rs-soroban-sdk

Rust SDK for Soroban contracts.
Rust
80
star
16

laboratory

JavaScript
76
star
17

new-docs

JavaScript
68
star
18

freighter

Stellar chrome extension
TypeScript
65
star
19

js-stellar-wallets

A library to make it easier to write wallets that interact with Stellar
TypeScript
60
star
20

rs-soroban-env

Rust environment for Soroban contracts.
Rust
50
star
21

stellar-demo-wallet

Provides a front-end interface to test SEP interoperability. Website at https://demo-wallet.stellar.org/
TypeScript
50
star
22

soroban-docs

Documentation for Soroban
MDX
48
star
23

packages

SDF - Packages
Shell
46
star
24

soroban-cli

CLI for Soroban contracts.
Rust
46
star
25

os-projects

42
star
26

paper-wallet

HTML
42
star
27

sorobanathon

Sorobanathon: First Light
42
star
28

starbridge

Software that facilitates bridge builders who are connecting the Stellar network to other blockchains.
Go
39
star
29

starlight

Layer 2 payment channel protocol for the Stellar network.
Go
38
star
30

soroban-examples

Example Soroban Contracts
Rust
37
star
31

account-viewer-v2

A simple tool to view an account on the Stellar network and make transactions from it.
TypeScript
37
star
32

java-stellar-anchor-sdk

Java SDK for the Stellar network anchor development.
Kotlin
34
star
33

developers

Stellar developer portal site generator.
JavaScript
33
star
34

stellar-etl-airflow

Airflow DAGs for the Stellar ETL project
Python
31
star
35

stellar-docs

Documentation for Stellar
MDX
30
star
36

stellar-etl

Stellar ETL will enable real-time analytics on the Stellar network
Go
28
star
37

stellar-disbursement-platform-backend

Stellar Disbursement Platform Backend
Go
24
star
38

js-soroban-client

Main Soroban client library for the Javascript language
TypeScript
24
star
39

js-xdr

Read/write XDR encoded data structures (RFC 4506)
JavaScript
23
star
40

xdrgen

A code generator for XDR
Rust
21
star
41

docs-wallet

SCSS
17
star
42

rs-stellar-xdr

Rust lib for Stellar XDR.
Rust
17
star
43

stellar-turrets

Reference implementation of the Stellar Turrets protocol
JavaScript
15
star
44

stellar-xdr

Staging area for future version of Stellar XDR.
RPC
15
star
45

hack-stellar

TypeScript
13
star
46

stellar-disbursement-platform-frontend

Stellar Disbursement Platform Frontend
TypeScript
12
star
47

stellar-anchor-tests

A library and CLI tool for testing Stellar anchors.
TypeScript
12
star
48

stories

JavaScript
12
star
49

.github

11
star
50

moneygram-access-wallet-mvp

An MVP wallet integrated with MoneyGram Access
Python
11
star
51

stellar-tutorials

This repository holds tools and tutorials to help developers build on Stellar.
JavaScript
10
star
52

hackathon-get-started

πŸ’» All the resources you'll need to begin your Stellar project.
10
star
53

typescript-wallet-sdk

Typescript Wallet SDK to build Stellar wallets
TypeScript
9
star
54

integration-tests

JavaScript
9
star
55

bower-js-stellar-sdk

JavaScript
9
star
56

react-starter

Stellar's starter kit for React projects.
TypeScript
9
star
57

scp-proofs

SCP proofs and models
Python
8
star
58

stellar-design-system

Components for Stellar’s design system
TypeScript
8
star
59

supercluster

Stellar-core integration test automation tool
F#
8
star
60

stellar-core-prometheus-exporter

Stellar Core Prometheus Exporter
Python
7
star
61

product-conventions

A layout of all conventions to be used by all Stellar frontend products
JavaScript
7
star
62

fca00c-asteroids

Learn Soroban and compete for a top spot on the leaderboard in Fast, Cheap & Out of Control
Rust
6
star
63

scaffold-soroban

Soroban example dapps
JavaScript
6
star
64

sorobounty-spectacular

Sorobounty Spectacular
5
star
65

sep24-reference-ui

TypeScript
5
star
66

regulated-assets-poc

JavaScript
5
star
67

django-polaris-circle

A reusable Django app for Circle USDC custody support in django-polaris deployments
Python
5
star
68

core-node-admin-panel

TypeScript
5
star
69

recoverysigner-firebase-auth

A simple demo frontend web app for performing Firebase phone auth for use with recoverysigner.
TypeScript
5
star
70

soroflare

The Soroban environment and vm running on a Cloudflare Worker. (a simplified version of the backend running fca00c.com)
Rust
5
star
71

soroban-react-payment

Soroban example dapps
TypeScript
5
star
72

anchor-ux-guidelines

5
star
73

sorobounties

The Soroban content bounty program
5
star
74

recoverysigner-demo-client

A limited feature demo client for a SEP-30 Recoverysigner server.
JavaScript
4
star
75

solar-stellarorg

Stellar.org's Solar CSS framework theme
CSS
4
star
76

stellar-turrets-docs

Docs repo for the Stellar Turrets protocol
4
star
77

anchor-transfer-utils

Utilities for anchors and wallets implementing SEP6 transfer protocol
TypeScript
4
star
78

stellar-upgrade-web

JavaScript
4
star
79

stellar-upgrade

Go
4
star
80

convert-stellar-address

JavaScript
4
star
81

soroban-name-service

Soroban name service
Rust
4
star
82

soroban-react-atomic-swap

A react demo dapp for making an atomic swap on Soroban
TypeScript
4
star
83

soroban-rpc

RPC server for Soroban contracts.
Go
4
star
84

kotlin-wallet-sdk

Kotlin Wallet SDK to build Stellar wallets
Kotlin
4
star
85

soroban-quest

Soroban Quest is a gamified educational course where you’ll learn Soroban and earn rewards!
Rust
4
star
86

js-stellar-elements

Styled basic components for Stellar projects
JavaScript
3
star
87

crate-git-revision

Embed git revision into crates built and published.
Rust
3
star
88

solar-stellarorg-pages

CSS
3
star
89

golistcmp

A tool for comparing the output of 'go list -m -json all' executions.
Go
3
star
90

basic-payment-app

An example payments application demonstrating integrations of various features and SEPs in a user-facing product.
Svelte
3
star
91

soroban-dapps-challenge

Dapps for the Soroban Dapps Challenge
3
star
92

stellar-dbt-public

Public DBT instance to aid in data transformation for analytics purposes
3
star
93

amm-reference-ui

A reference codebase to serve as a proof of concept for an AMM UI
TypeScript
3
star
94

helm-charts

Helm charts for deploying SDF maintained software
Smarty
3
star
95

stellar-account-prometheus-exporter

Stellar Account Prometheus Exporter - Monitor Stellar Network Accounts
Python
3
star
96

dts-xdr

A library for generating TypeScript declarations (.d.ts) for js-xdr auto-generated files.
JavaScript
3
star
97

actions

GitHub Actions for Stellar repositories.
TypeScript
2
star
98

anchor-transfer-server-validator-ui

JavaScript
2
star
99

project-viewer

Navigating projects on Stellar
Go
2
star
100

soroban-react-mint-token

An example dapp for minting tokens on Soroban
TypeScript
2
star