Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Added cryptsy and the ability to do trade-percentage in the config file. #200

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
*.vi
*~
*.sass-cache
gekko-conf*


# OS or Editor folders
.DS_Store
Expand Down Expand Up @@ -38,4 +40,5 @@ dwsync.xml
node_modules
candles.csv
cexio.db
cryptsy.db
history
21 changes: 12 additions & 9 deletions config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ config.debug = false; // for additional logging / debugging
// Monitor the live market
config.watch = {
enabled: true,
exchange: 'Bitstamp', // 'MtGox', 'BTCe', 'Bitstamp', 'cexio' or 'kraken'
currency: 'USD',
asset: 'BTC'
exchange: 'cryptsy', // 'MtGox', 'BTCe', 'Bitstamp', 'cexio', 'cryptsy' or 'kraken'
key: '',
secret: '',
currency: 'BTC',
asset: 'DOGE'
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand All @@ -42,12 +44,12 @@ config.tradingAdvisor = {
config.DEMA = {
// EMA weight (α)
// the higher the weight, the more smooth (and delayed) the line
short: 10,
long: 21,
short: 11,
long: 31,
// amount of candles to remember and base initial EMAs on
// the difference between the EMAs (to act as triggers)
sellTreshold: -0.025,
buyTreshold: 0.025
sellTreshold: -0.35,
buyTreshold: 0.25
};

// MACD settings:
Expand Down Expand Up @@ -88,7 +90,8 @@ config.PPO = {
// Enabling this will activate trades for the market being
// watched by config.watch
config.trader = {
enabled: false,
enabled: true,
tradePercent: 10,
key: '',
secret: '',
username: '' // your username, only fill in when using bitstamp or cexio
Expand All @@ -112,7 +115,7 @@ config.profitSimulator = {
// only want report after a sell? set to `false`.
verbose: false,
// how much fee in % does each trade cost?
fee: 0.6,
fee: 0.03,
// how much slippage should Gekko assume per trade?
slippage: 0.05
}
Expand Down
1 change: 1 addition & 0 deletions core/candleManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -793,6 +793,7 @@ Manager.prototype.addEmtpyCandles = function(candles, start, end) {

if(min > max) {
console.log('c', candles, 's', start, 'e', end);
console.log('min', min, 'max', max);
throw 'Weird error 2';
}

Expand Down
29 changes: 21 additions & 8 deletions core/portfolioManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -122,7 +123,9 @@ Manager.prototype.trade = function(what) {
return;

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') {

Expand All @@ -138,6 +141,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') {
Expand All @@ -153,6 +161,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);
}
Expand Down Expand Up @@ -183,7 +196,7 @@ Manager.prototype.buy = function(amount, price) {
var currency = this.getFund(this.currency);
var minimum = this.getMinimum(price);
var availabe = this.getBalance(this.currency) / price;

log.debug('Buying ', amount, 'with ', availabe, 'available, and a minimum of', minimum);
// if not suficient funds
if(amount > availabe) {
return log.info(
Expand All @@ -195,12 +208,12 @@ Manager.prototype.buy = function(amount, price) {
);
}

// if order to small
// if order too small
if(amount < minimum) {
return log.info(
'wanted to buy',
this.asset,
'but the amount is to small',
'but the amount is too small',
'(' + amount + ')',
'at',
this.exchange.name
Expand Down Expand Up @@ -229,9 +242,9 @@ Manager.prototype.sell = function(amount, price) {

var minimum = this.getMinimum(price);
var availabe = this.getBalance(this.asset);

log.debug('Selling ', amount, 'with ', availabe, 'available, and a minimum of', minimum);
// if not suficient funds
if(amount < availabe) {
if(amount > availabe) {
return log.info(
'wanted to buy but insufficient',
this.asset,
Expand All @@ -241,12 +254,12 @@ Manager.prototype.sell = function(amount, price) {
);
}

// if order to small
// if order too small
if(amount < minimum) {
return log.info(
'wanted to buy',
this.currency,
'but the amount is to small',
'but the amount is too small',
'(' + amount + ')',
'at',
this.exchange.name
Expand Down
21 changes: 21 additions & 0 deletions exchanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,27 @@ var exchanges = [
requires: ['key', 'secret', 'username'],
providesHistory: false
},
{
name: 'Cryptsy',
slug: 'cryptsy',
direct: false,
infinityOrder: false,
currencies: ['BTC', 'LTC'],
assets: ['DOGE', 'DVC', 'PPC' ],
markets: [
{
pair: ['BTC', 'DOGE'], market_id: 132, minimalOrder: { amount: 100, unit: 'asset' }
},
{
pair: ['LTC', 'DOGE'], minimalOrder: { amount: 1, unit: 'asset' }
},
{
pair: ['BTC', 'DVC'], minimalOrder: { amount: 100, unit: 'asset' }
}
],
requires: ['key', 'secret'],
providesHistory: false
},
{
name: 'Kraken',
slug: 'kraken',
Expand Down
Loading