Skip to content

Commit

Permalink
Catch up to root master (#3)
Browse files Browse the repository at this point in the history
* cap3: 1 - implement liabilities for XLM

* cap3: 2 - integrate liabilities into willOversell and willOverbuy methods

* cap3: 3 - remove fractionalReserveMultiplier cli arg

* cap3: 4 - offers in the same tx will contribute to liabilities, incorporate into cachedLiabilities

* cap3: 5 - handle case of setting incrementalBuy for native asset

* cap3: 6 - refactored willOversell and willOverbuy to extract common offer logic

* cap3: 7 - added support for checking XLM fee and min reserves

* cap3: 8 - update ordering of operations in strategies (sellSideStrategy, mirrorStrategy) when not all offers can be placed — always place inside orders first

* cap3: 9 - native fee inclusion checks source/trader account usage

* cap3: 10 - delete offer if nothing was created and we were planning to modify an existing offer

* cap3: 11 - prepend deleteOps so we "free" up our liabilities capacity to place the new/modified offers

* cap3: 12 - better error propagation from sdex.createModifySellOffer

* cap3: 13 - extracted liability updates after placing/modifying offers to callers in sellSideStrategy and mirrorStrategy

* cap3: 14 - prepend deleteOps for mirror strategy too

* cap3: 15 - log liabilities in trader.go after resetting and after updating ops

* cap3: 16 - add liabilities in mirror strat

* cap3: 17 - added support for partial offers in sellSideStrategy, refactored updateSellLevel

* cap3: 18 - updated comment when resetting cached liabilities

* cap3: 19 - add current offer amounts to liabilities when not modifying an offer

* cap3: 20 - add a caching layer for asset balances to reduce requests

* cap3: 21 - cleaner logging of asset balance and trust amounts

* cap3: 22 - let new capacity constraint system handle max limits for sellSideStrategy

* cap3: 23 - reset caches before pruning and updating operations

* cap3: 24 - update CHANGELOG

* new release: v1.0.0-rc2

* expand assets allowed to use with the Kraken exchange, fixes stellar-deprecated#13

* new release: v1.0.0-rc3

* remove default rate offset percent from sample strategy config files

* Print strat (stellar-deprecated#15)

* Update trade.go

* Update trade.go

* Update trade.go

* enable Travis CI, closes stellar-deprecated#17 (stellar-deprecated#18)

* enable Travis CI

* go_import_path

* travis: ./bin/kelp version

* doc clarify full path needed for configs (stellar-deprecated#16)
  • Loading branch information
Reidmcc authored Oct 2, 2018
1 parent 4506fb2 commit d1fb1a2
Show file tree
Hide file tree
Showing 14 changed files with 790 additions and 212 deletions.
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
21 changes: 11 additions & 10 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
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
3 changes: 0 additions & 3 deletions cmd/trade.go
Original file line number Diff line number Diff line change
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 Down Expand Up @@ -87,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
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

0 comments on commit d1fb1a2

Please sign in to comment.