From acf11d97fb544c4956940e4b2bd724a3936f4cad Mon Sep 17 00:00:00 2001 From: Richard Date: Mon, 23 Jun 2014 23:47:57 -0700 Subject: [PATCH 1/3] config - add missing keys --- config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/config.js b/config.js index 8c56b85a1..91efef54f 100644 --- a/config.js +++ b/config.js @@ -23,6 +23,8 @@ config.debug = true; // for additional logging / debugging config.watch = { enabled: true, exchange: 'cryptsy', // 'MtGox', 'BTCe', 'Bitstamp', 'cexio', 'cryptsy' or 'kraken' + key: '', + secret: '', currency: 'BTC', asset: 'LTC' } @@ -111,7 +113,7 @@ config.custom = { // Enabling this will activate trades for the market being // watched by config.watch config.trader = { - enabled: true, + enabled: false, key: '', secret: '', username: '' // your username, only fill in when using bitstamp or cexio From e08999f2abb3df6ef4f63aca6614549432573d7a Mon Sep 17 00:00:00 2001 From: Richard Date: Tue, 24 Jun 2014 00:31:40 -0700 Subject: [PATCH 2/3] bug fixes - works great for cryptsy now! --- config.js | 1 + core/portfolioManager.js | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/config.js b/config.js index 91efef54f..8286d9775 100644 --- a/config.js +++ b/config.js @@ -114,6 +114,7 @@ config.custom = { // watched by config.watch config.trader = { enabled: false, + tradePercent: 10, key: '', secret: '', username: '' // your username, only fill in when using bitstamp or cexio diff --git a/core/portfolioManager.js b/core/portfolioManager.js index b34aac57f..ba386cdc5 100644 --- a/core/portfolioManager.js +++ b/core/portfolioManager.js @@ -42,6 +42,7 @@ var Manager = function(conf) { }); this.minimalOrder = this.marketConfig.minimalOrder; + this.tradePercent = conf.tradePercent; this.currency = conf.currency; this.asset = conf.asset; } @@ -124,7 +125,9 @@ Manager.prototype.trade = function(what) { this.action = what; var act = function() { - var amount, price; + var amount, price, total_balance; + + total_balance = this.getBalance(this.currency) + this.getBalance(this.asset) * this.ticker.bid; if(what === 'BUY') { @@ -140,6 +143,11 @@ Manager.prototype.trade = function(what) { else price = this.ticker.ask; + if(this.tradePercent) { + log.debug('Trade Percent: adjusting amount', amount, 'by ', this.tradePercent, '%'); + amount = amount * this.tradePercent / 100; + } + this.buy(amount, price); } else if(what === 'SELL') { @@ -155,6 +163,11 @@ Manager.prototype.trade = function(what) { price = false; else price = this.ticker.bid; + + if(this.tradePercent) { + log.debug('Trade Percent: adjusting amount', amount, 'by ', this.tradePercent, '%'); + amount = amount * this.tradePercent / 100; + } this.sell(amount, price); } @@ -197,7 +210,7 @@ Manager.prototype.buy = function(amount, price) { ); } - // if order to small + // if order too small if(amount < minimum) { return log.info( 'Wanted to buy', @@ -232,7 +245,7 @@ Manager.prototype.sell = function(amount, price) { var availabe = this.getBalance(this.asset); // if not suficient funds - if(amount < availabe) { + if(amount > availabe) { return log.info( 'Wanted to buy but insufficient', this.asset, @@ -242,7 +255,7 @@ Manager.prototype.sell = function(amount, price) { ); } - // if order to small + // if order too small if(amount < minimum) { return log.info( 'Wanted to buy', From cd89180b3e65a0c2cd8f7ccfcc015de37bf9e2c2 Mon Sep 17 00:00:00 2001 From: dowjames Date: Tue, 24 Jun 2014 09:14:14 -0700 Subject: [PATCH 3/3] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8d632c35f..7450d9c74 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ Gekko works on the following exchanges: - CEX.io - Kraken - BTC-e -- ~~Cryptsy~~ (In the [pipeline](https://github.com/askmike/gekko/pull/200)) +- Cryptsy ## Installing Gekko @@ -150,4 +150,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE.