Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch up to root master #3

Merged
merged 31 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c9562d6
cap3: 1 - implement liabilities for XLM
nikhilsaraf Sep 13, 2018
89fe7bf
cap3: 2 - integrate liabilities into willOversell and willOverbuy met…
nikhilsaraf Sep 13, 2018
19630f6
cap3: 3 - remove fractionalReserveMultiplier cli arg
nikhilsaraf Sep 13, 2018
54dd024
cap3: 4 - offers in the same tx will contribute to liabilities, incor…
nikhilsaraf Sep 13, 2018
028e8a4
cap3: 5 - handle case of setting incrementalBuy for native asset
nikhilsaraf Sep 13, 2018
62ba916
cap3: 6 - refactored willOversell and willOverbuy to extract common o…
nikhilsaraf Sep 20, 2018
4754e11
cap3: 7 - added support for checking XLM fee and min reserves
nikhilsaraf Sep 21, 2018
cc2ffbf
cap3: 8 - update ordering of operations in strategies (sellSideStrate…
nikhilsaraf Sep 21, 2018
5894e15
cap3: 9 - native fee inclusion checks source/trader account usage
nikhilsaraf Sep 21, 2018
8a58266
cap3: 10 - delete offer if nothing was created and we were planning t…
nikhilsaraf Sep 21, 2018
c443fe4
cap3: 11 - prepend deleteOps so we "free" up our liabilities capacity…
nikhilsaraf Sep 24, 2018
57640be
cap3: 12 - better error propagation from sdex.createModifySellOffer
nikhilsaraf Sep 24, 2018
6f49cf6
cap3: 13 - extracted liability updates after placing/modifying offers…
nikhilsaraf Sep 24, 2018
2425566
cap3: 14 - prepend deleteOps for mirror strategy too
nikhilsaraf Sep 24, 2018
4d5f622
cap3: 15 - log liabilities in trader.go after resetting and after upd…
nikhilsaraf Sep 25, 2018
f64535e
cap3: 16 - add liabilities in mirror strat
nikhilsaraf Sep 25, 2018
8dc16d8
cap3: 17 - added support for partial offers in sellSideStrategy, refa…
nikhilsaraf Sep 28, 2018
351d8bc
cap3: 18 - updated comment when resetting cached liabilities
nikhilsaraf Sep 28, 2018
835f256
cap3: 19 - add current offer amounts to liabilities when not modifyin…
nikhilsaraf Sep 28, 2018
83d77ae
cap3: 20 - add a caching layer for asset balances to reduce requests
nikhilsaraf Sep 28, 2018
e793362
cap3: 21 - cleaner logging of asset balance and trust amounts
nikhilsaraf Sep 28, 2018
d3d7a09
cap3: 22 - let new capacity constraint system handle max limits for s…
nikhilsaraf Sep 28, 2018
68c82f1
cap3: 23 - reset caches before pruning and updating operations
nikhilsaraf Sep 28, 2018
d208c47
cap3: 24 - update CHANGELOG
nikhilsaraf Sep 28, 2018
217534d
new release: v1.0.0-rc2
nikhilsaraf Sep 28, 2018
2767aa4
expand assets allowed to use with the Kraken exchange, fixes #13
nikhilsaraf Sep 29, 2018
c8363e7
new release: v1.0.0-rc3
nikhilsaraf Sep 29, 2018
09ae14c
remove default rate offset percent from sample strategy config files
nikhilsaraf Oct 1, 2018
f19c610
Print strat (#15)
Reidmcc Oct 2, 2018
9c62c80
enable Travis CI, closes #17 (#18)
nikhilsaraf Oct 2, 2018
92324c3
doc clarify full path needed for configs (#16)
Reidmcc Oct 2, 2018
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
17 changes: 17 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
language: go

go_import_path: github.com/lightyeario/kelp

go:
- "1.10.x"
- "1.11"

before_install:
- curl https://glide.sh/get | sh

install:
- glide install

script:
- ./scripts/build.sh
- ./bin/kelp version
25 changes: 21 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,38 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).


## [Unreleased]

### Added
- This CHANGELOG file

### Changed
- Updated dependency `github.com/stellar/go` to latest version `5bbd27814a3ffca9aeffcbd75a09a6164959776a`, run `glide up` to update this dependency

### Deprecated

### Removed

### Fixed
- If `SOURCE_SECRET_SEED` is missing or empty then the bot will not crash now.

### Security

## [v1.0.0-rc3] - 2018-09-29

### Added
- support for all currencies available on Kraken

## [v1.0.0-rc2] - 2018-09-28

### Added
- This CHANGELOG file

### Changed
- Updated dependency `github.com/stellar/go` to latest version `5bbd27814a3ffca9aeffcbd75a09a6164959776a`, run `glide up` to update this dependency

### Fixed
- If `SOURCE_SECRET_SEED` is missing or empty then the bot will not crash now.
- support for [CAP-0003](https://github.com/stellar/stellar-protocol/blob/master/core/cap-0003.md) introduced in stellar-core protocol v10 ([issue #2](https://github.com/lightyeario/kelp/issues/2))


## v1.0.0-rc1 - 2018-08-13

Expand All @@ -31,4 +46,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Configuration file based approach to setting up a bot
- Documentation on existing capabilities

[Unreleased]: https://github.com/lightyeario/kelp/compare/v1.0.0-rc1...HEAD
[Unreleased]: https://github.com/lightyeario/kelp/compare/v1.0.0-rc3...HEAD
[v1.0.0-rc3]: https://github.com/lightyeario/kelp/compare/v1.0.0-rc2...v1.0.0-rc3
[v1.0.0-rc2]: https://github.com/lightyeario/kelp/compare/v1.0.0-rc1...v1.0.0-rc2
27 changes: 14 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
[![Github All Releases](https://img.shields.io/github/downloads/lightyeario/kelp/total.svg?style=for-the-badge)][github-releases]
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=for-the-badge&longCache=true)][license-apache]

[![Build Status](https://travis-ci.com/lightyeario/kelp.svg?branch=master)](https://travis-ci.com/lightyeario/kelp)
[![GitHub issues](https://img.shields.io/github/issues/lightyeario/kelp.svg?style=flat-square&longCache=true)][github-issues]
[![GitHub closed issues](https://img.shields.io/github/issues-closed/lightyeario/kelp.svg?style=flat-square&longCache=true)][github-issues-closed]
[![GitHub pull requests](https://img.shields.io/github/issues-pr/lightyeario/kelp.svg?style=flat-square&longCache=true)][github-pulls]
Expand Down Expand Up @@ -54,24 +55,24 @@ There is **one** binary associated with this project: `kelp`. Once the binary is

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

Here is a list of binaries for the most recent release **v1.0.0-rc1**:
Here is a list of binaries for the most recent release **v1.0.0-rc3**:

| Platform | Architecture | Binary File Name |
| -------------- | ------------ | ---------------- |
| MacOS (Darwin) | 64-bit | [kelp-v1.0.0-rc1-darwin-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-darwin-amd64.tar) |
| Windows | 64-bit | [kelp-v1.0.0-rc1-windows-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-windows-amd64.tar) |
| Linux | 64-bit | [kelp-v1.0.0-rc1-linux-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-linux-amd64.tar) |
| Linux | 64-bit arm | [kelp-v1.0.0-rc1-linux-arm64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-linux-arm64.tar) |
| Linux | 32-bit arm5 | [kelp-v1.0.0-rc1-linux-arm5.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-linux-arm5.tar) |
| Linux | 32-bit arm6 | [kelp-v1.0.0-rc1-linux-arm6.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-linux-arm6.tar) |
| Linux | 32-bit arm7 | [kelp-v1.0.0-rc1-linux-arm7.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc1/kelp-v1.0.0-rc1-linux-arm7.tar) |
| MacOS (Darwin) | 64-bit | [kelp-v1.0.0-rc3-darwin-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-darwin-amd64.tar) |
| Windows | 64-bit | [kelp-v1.0.0-rc3-windows-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-windows-amd64.tar) |
| Linux | 64-bit | [kelp-v1.0.0-rc3-linux-amd64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-linux-amd64.tar) |
| Linux | 64-bit arm | [kelp-v1.0.0-rc3-linux-arm64.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-linux-arm64.tar) |
| Linux | 32-bit arm5 | [kelp-v1.0.0-rc3-linux-arm5.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-linux-arm5.tar) |
| Linux | 32-bit arm6 | [kelp-v1.0.0-rc3-linux-arm6.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-linux-arm6.tar) |
| Linux | 32-bit arm7 | [kelp-v1.0.0-rc3-linux-arm7.tar](https://github.com/lightyeario/kelp/releases/download/v1.0.0-rc3/kelp-v1.0.0-rc3-linux-arm7.tar) |

After you _untar_ the downloaded file, change to the generated directory (`kelp-v1.0.0-rc1`) and invoke the `kelp` binary.
After you _untar_ the downloaded file, change to the generated directory (`kelp-v1.0.0-rc3`) 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.0.0-rc1
cd kelp-v1.0.0-rc3
./kelp

To run the bot in simulation mode, try this command:
Expand Down Expand Up @@ -107,13 +108,13 @@ These are the following commands available from the `kelp` binary:

The `trade` command has three parameters which are:

- **botConf**: _.cfg_ file with the account details, [sample file here](examples/configs/trader/sample_trader.cfg).
- **botConf**: full path to the _.cfg_ file with the account details, [sample file here](examples/configs/trader/sample_trader.cfg).
- **strategy**: the strategy you want to run (_sell_, _buysell_, _balanced_, _mirror_, _delete_).
- **stratConf**: _.cfg_ file specific to your chosen strategy, [sample files here](examples/configs/trader/).
- **stratConf**: full path to the _.cfg_ file specific to your chosen strategy, [sample files here](examples/configs/trader/).

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

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

If you are ever stuck, just invoke the `kelp` binary directly or type `kelp help [command]` for help with a specific command.

Expand Down
1 change: 0 additions & 1 deletion cmd/terminate.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ func init() {
*configFile.TradingAccount,
utils.ParseNetwork(configFile.HORIZON_URL),
-1, // not needed here
-1, // not needed here
false,
)
terminator := terminator.MakeTerminator(client, sdex, *configFile.TradingAccount, configFile.TICK_INTERVAL_SECONDS, configFile.ALLOW_INACTIVE_MINUTES)
Expand Down
10 changes: 5 additions & 5 deletions cmd/trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"github.com/stellar/go/support/config"
)

const tradeExamples = ` kelp trade --botConf trader.cfg --strategy buysell --stratConf buysell.cfg
kelp trade --botConf trader.cfg --strategy buysell --stratConf buysell.cfg --sim`
const tradeExamples = ` kelp trade --botConf ./path/trader.cfg --strategy buysell --stratConf ./path/buysell.cfg
kelp trade --botConf ./path/trader.cfg --strategy buysell --stratConf ./path/buysell.cfg --sim`

var tradeCmd = &cobra.Command{
Use: "trade",
Expand Down Expand Up @@ -43,13 +43,11 @@ func init() {
strategy := tradeCmd.Flags().StringP("strategy", "s", "", "(required) type of strategy to run")
stratConfigPath := tradeCmd.Flags().StringP("stratConf", "f", "", "strategy config file path")
// long-only flags
fractionalReserveMultiplier := tradeCmd.Flags().Int8("fractionalReserveMultiplier", 1, "fractional multiplier for XLM reserves")
operationalBuffer := tradeCmd.Flags().Float64("operationalBuffer", 20, "buffer of native XLM to maintain beyond minimum account balance requirement")
simMode := tradeCmd.Flags().Bool("sim", false, "simulate the bot's actions without placing any trades")

requiredFlag("botConf")
requiredFlag("strategy")
hiddenFlag("fractionalReserveMultiplier")
hiddenFlag("operationalBuffer")
tradeCmd.Flags().SortFlags = false

Expand All @@ -70,6 +68,9 @@ func init() {
}
log.Printf("Trading %s:%s for %s:%s\n", botConfig.ASSET_CODE_A, botConfig.ISSUER_A, botConfig.ASSET_CODE_B, botConfig.ISSUER_B)

//Add current strategy to the log
log.Printf("Current strategy: %s\n", *strategy)

client := &horizon.Client{
URL: botConfig.HORIZON_URL,
HTTP: http.DefaultClient,
Expand All @@ -84,7 +85,6 @@ func init() {
botConfig.SourceAccount(),
botConfig.TradingAccount(),
utils.ParseNetwork(botConfig.HORIZON_URL),
*fractionalReserveMultiplier,
*operationalBuffer,
*simMode,
)
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/trader/sample_buysell.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ AMOUNT_TOLERANCE=0.001
# how much percent to offset your rates by, specified as a decimal (ex: 0.05 = 5%). Can be used in conjunction with RATE_OFFSET below.
# A positive value indicates that your base asset (ASSET_A) has a higher rate than the rate received from your price feed
# A negative value indicates that your base asset (ASSET_A) has a lower rate than the rate received from your price feed
RATE_OFFSET_PERCENT=0.05
RATE_OFFSET_PERCENT=0.0
# how much to offset your rates by, specified in number of units of the quote asset (ASSET_B) as a decimal.
# Can be used in conjunction with RATE_OFFSET_PERCENT above.
# A positive value indicates that your base asset (ASSET_A) has a higher rate than the rate received from your price feed
Expand Down
2 changes: 1 addition & 1 deletion examples/configs/trader/sample_sell.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ AMOUNT_TOLERANCE=0.001
# how much percent to offset your rates by, specified as a decimal (ex: 0.05 = 5%). Can be used in conjunction with RATE_OFFSET below.
# A positive value indicates that your base asset (ASSET_A) has a higher rate than the rate received from your price feed
# A negative value indicates that your base asset (ASSET_A) has a lower rate than the rate received from your price feed
RATE_OFFSET_PERCENT=0.05
RATE_OFFSET_PERCENT=0.0
# how much to offset your rates by, specified in number of units of the quote asset (ASSET_B) as a decimal.
# Can be used in conjunction with RATE_OFFSET_PERCENT above.
# A positive value indicates that your base asset (ASSET_A) has a higher rate than the rate received from your price feed
Expand Down
2 changes: 1 addition & 1 deletion examples/walkthroughs/trader/balanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ The virtual balance combined with the actual balance the bot has in its account
Assuming your botConfig is called `trader.cfg` and your strategy config is called `balanced.cfg`, you can run `kelp` with the following command:

```
kelp trade --botConf trader.cfg --strategy balanced --stratConf balanced.cfg
kelp trade --botConf ./path/trader.cfg --strategy balanced --stratConf ./path/balanced.cfg
```

# Above and Beyond
Expand Down
2 changes: 1 addition & 1 deletion examples/walkthroughs/trader/buysell.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ A level defines a [layer](https://en.wikipedia.org/wiki/Layering_(finance)) that

Assuming your botConfig is called `trader.cfg` and your strategy config is called `buysell.cfg`, you can run `kelp` with the following command:
```
kelp trade --botConf trader.cfg --strategy buysell --stratConf buysell.cfg
kelp trade --botConf ./path/trader.cfg --strategy buysell --stratConf ./path/buysell.cfg
```

# Above and Beyond
Expand Down
2 changes: 1 addition & 1 deletion examples/walkthroughs/trader/sell.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ A level defines a [layer](https://en.wikipedia.org/wiki/Layering_(finance)) that
Assuming your botConfig is called `trader.cfg` and your strategy config is called `sell.cfg`, you can run `kelp` with the following command:

```
kelp trade --botConf trader.cfg --strategy sell --stratConf sell.cfg
kelp trade --botConf ./path/trader.cfg --strategy sell --stratConf ./path/sell.cfg
```

# Above and Beyond
Expand Down
105 changes: 87 additions & 18 deletions model/assets.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,35 @@ type Asset string
// this is the list of assets understood by the bot.
// This string can be converted by the specific exchange adapter as is needed by the exchange's API
const (
XLM Asset = "XLM"
BTC Asset = "BTC"
USD Asset = "USD"
ETH Asset = "ETH"
LTC Asset = "LTC"
REP Asset = "REP"
XLM Asset = "XLM"
BTC Asset = "BTC"
USD Asset = "USD"
ETH Asset = "ETH"
LTC Asset = "LTC"
REP Asset = "REP"
ADA Asset = "ADA"
BCH Asset = "BCH"
DASH Asset = "DASH"
EOS Asset = "EOS"
GNO Asset = "GNO"
FEE Asset = "FEE"
QTUM Asset = "QTUM"
USDT Asset = "USDT"
DAO Asset = "DAO"
ETC Asset = "ETC"
ICN Asset = "ICN"
MLN Asset = "MLN"
NMC Asset = "NMC"
XDG Asset = "XDG"
XMR Asset = "XMR"
XRP Asset = "XRP"
XVN Asset = "XVN"
ZEC Asset = "ZEC"
CAD Asset = "CAD"
EUR Asset = "EUR"
GBP Asset = "GBP"
JPY Asset = "JPY"
KRW Asset = "KRW"
)

// AssetConverter converts to and from the asset type, it is specific to an exchange
Expand Down Expand Up @@ -67,20 +90,66 @@ func (c AssetConverter) MustFromString(s string) Asset {

// Display is a basic converter for display purposes
var Display = makeAssetConverter(map[Asset]string{
XLM: string(XLM),
BTC: string(BTC),
USD: string(USD),
ETH: string(ETH),
LTC: string(LTC),
REP: string(REP),
XLM: string(XLM),
BTC: string(BTC),
USD: string(USD),
ETH: string(ETH),
LTC: string(LTC),
REP: string(REP),
ADA: string(ADA),
BCH: string(BCH),
DASH: string(DASH),
EOS: string(EOS),
GNO: string(GNO),
FEE: string(FEE),
QTUM: string(QTUM),
USDT: string(USDT),
DAO: string(DAO),
ETC: string(ETC),
ICN: string(ICN),
MLN: string(MLN),
NMC: string(NMC),
XDG: string(XDG),
XMR: string(XMR),
XRP: string(XRP),
XVN: string(XVN),
ZEC: string(ZEC),
CAD: string(CAD),
EUR: string(EUR),
GBP: string(GBP),
JPY: string(JPY),
KRW: string(KRW),
})

// KrakenAssetConverter is the asset converter for the Kraken exchange
var KrakenAssetConverter = makeAssetConverter(map[Asset]string{
XLM: "XXLM",
BTC: "XXBT",
USD: "ZUSD",
ETH: "XETH",
LTC: "XLTC",
REP: "XREP",
XLM: "XXLM",
BTC: "XXBT",
USD: "ZUSD",
ETH: "XETH",
LTC: "XLTC",
REP: "XREP",
ADA: "ADA",
BCH: "BCH",
DASH: "DASH",
EOS: "EOS",
GNO: "GNO",
FEE: "KFEE",
QTUM: "QTUM",
USDT: "USDT",
DAO: "XDAO",
ETC: "XETC",
ICN: "XICN",
MLN: "XMLN",
NMC: "XNMC",
XDG: "XXDG",
XMR: "XXMR",
XRP: "XXRP",
XVN: "XXVN",
ZEC: "XZEC",
CAD: "ZCAD",
EUR: "ZEUR",
GBP: "ZGBP",
JPY: "ZJPY",
KRW: "ZKRW",
})
8 changes: 8 additions & 0 deletions model/number.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ func InvertNumber(n *Number) *Number {
return NumberFromFloat(1/n.AsFloat(), n.Precision())
}

// NumberByCappingPrecision returns a number with a precision that is at max the passed in precision
func NumberByCappingPrecision(n *Number, precision int8) *Number {
if n.Precision() > precision {
return NumberFromFloat(n.AsFloat(), precision)
}
return n
}

func round(num float64) int {
return int(num + math.Copysign(0.5, num))
}
Expand Down
Loading