Skip to content

Commit fe2d6bf

Browse files
author
Carlos Rodriguez
committed
move exchange conf to main conf, re-organize conf
1 parent 43cbfe6 commit fe2d6bf

File tree

6 files changed

+40
-56
lines changed

6 files changed

+40
-56
lines changed

boot.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,16 @@ module.exports = function (cb) {
3131
})
3232
}
3333

34-
var u = 'mongodb://' + c.mongo_host + ':' + c.mongo_port + '/' + c.mongo_db
34+
var u = 'mongodb://' + c.mongo.host + ':' + c.mongo.port + '/' + c.mongo.db
3535
require('mongodb').MongoClient.connect(u, function (err, db) {
3636
if (err) {
3737
zenbot.set('zenbot:db.mongo', null)
3838
console.error('warning: mongodb not accessible. some features (such as backfilling/simulation) may be disabled.')
3939
return withMongo()
4040
}
4141
zenbot.set('zenbot:db.mongo', db)
42-
if (c.mongo_username) {
43-
db.authenticate(c.mongo_username, c.mongo_password, function (err, result) {
42+
if (c.mongo.username) {
43+
db.authenticate(c.mongo.username, c.mongo.password, function (err, result) {
4444
if (err) {
4545
zenbot.set('zenbot:db.mongo', null)
4646
console.error('warning: mongodb auth failed. some features (such as backfilling/simulation) may be disabled.')

conf-sample.js

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,33 @@
11
var c = module.exports = {}
22

3-
// COMMONLY TWEAKED VARIABLES:
3+
// mongo configuration
4+
c.mongo = {}
5+
c.mongo.host = 'localhost'
6+
c.mongo.port = 27017
7+
c.mongo.db = 'zenbot4'
8+
c.mongo.username = null
9+
c.mongo.password = null
410

511
// default selector. only used if omitting [selector] argument from a command.
612
c.selector = 'gdax.BTC-USD'
713
// name of default trade strategy
814
c.strategy = 'trend_ema'
15+
16+
// Exchange API keys:
17+
18+
// to enable GDAX trading, enter your API credentials:
19+
c.gdax = {}
20+
c.gdax.key = 'YOUR-API-KEY'
21+
c.gdax.b64secret = 'YOUR-BASE64-SECRET'
22+
c.gdax.passphrase = 'YOUR-PASSPHRASE'
23+
24+
// to enable Poloniex trading, enter your API credentials:
25+
c.poloniex = {}
26+
c.poloniex.key = 'YOUR-API-KEY'
27+
c.poloniex.secret = 'YOUR-SECRET'
28+
29+
// Optional stop-order triggers:
30+
931
// sell if price drops below this % of bought price (0 to disable)
1032
c.sell_stop_pct = 0
1133
// buy if price surges above this % of sold price (0 to disable)
@@ -14,8 +36,9 @@ c.buy_stop_pct = 0
1436
c.profit_stop_enable_pct = 0
1537
// maintain a trailing stop this % below the high-water mark of profit
1638
c.profit_stop_pct = 1
17-
// avoid selling at a loss below this pct
18-
c.max_sell_loss_pct = 25
39+
40+
// Order execution rules:
41+
1942
// avoid trading at a slippage above this pct
2043
c.max_slippage_pct = 5
2144
// buy with this % of currency balance
@@ -24,15 +47,19 @@ c.buy_pct = 99
2447
c.sell_pct = 99
2548
// ms to adjust non-filled order after
2649
c.order_adjust_time = 30000
50+
// avoid selling at a loss below this pct
51+
c.max_sell_loss_pct = 25
52+
// ms to poll order status
53+
c.order_poll_time = 5000
54+
// ms to wait for settlement (after an order cancel)
55+
c.wait_for_settlement = 5000
56+
// ms to wait for settlement (after a funds on hold error)
57+
c.wait_more_for_settlement = 60000
58+
// % to mark up or down price for orders
59+
c.markup_pct = 0
2760

28-
// LESS-COMMONLY TWEAKED VARAIBLES:
61+
// Misc options:
2962

30-
// mongo configuration
31-
c.mongo_host = 'localhost'
32-
c.mongo_port = 27017
33-
c.mongo_db = 'zenbot4'
34-
c.mongo_username = null
35-
c.mongo_password = null
3663
// default # days for backfill and sim commands
3764
c.days = 90
3865
// ms to poll new trades at
@@ -41,17 +68,9 @@ c.poll_trades = 30000
4168
c.currency_capital = 1000
4269
// amount of asset to start simulations with
4370
c.asset_capital = 0
44-
// ms to poll order status
45-
c.order_poll_time = 5000
4671
// for sim, reverse time at the end of the graph, normalizing buy/hold to 0
4772
c.symmetrical = false
4873
// number of periods to calculate RSI at
4974
c.rsi_periods = 14
50-
// ms to wait for settlement (after an order cancel)
51-
c.wait_for_settlement = 5000
52-
// ms to wait for settlement (after a funds on hold error)
53-
c.wait_more_for_settlement = 60000
5475
// period to record balances for stats
5576
c.balance_snapshot_period = '15m'
56-
// % to mark up or down price for orders
57-
c.markup_pct = 0

extensions/gdax/conf-sample.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

extensions/gdax/exchange.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,6 @@ var Gdax = require('gdax')
33

44
module.exports = function container (get, set, clear) {
55
var c = get('conf')
6-
var defs = require('./conf-sample')
7-
try {
8-
c.gdax = require('./conf')
9-
}
10-
catch (e) {
11-
c.gdax = {}
12-
}
13-
Object.keys(defs).forEach(function (k) {
14-
if (typeof c.gdax[k] === 'undefined') {
15-
c.gdax[k] = defs[k]
16-
}
17-
})
186

197
var public_client, authed_client
208

extensions/poloniex/conf-sample.js

Lines changed: 0 additions & 5 deletions
This file was deleted.

extensions/poloniex/exchange.js

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,6 @@ var Poloniex = require('poloniex.js')
66

77
module.exports = function container (get, set, clear) {
88
var c = get('conf')
9-
var defs = require('./conf-sample')
10-
try {
11-
c.poloniex = require('./conf')
12-
}
13-
catch (e) {
14-
c.poloniex = {}
15-
}
16-
Object.keys(defs).forEach(function (k) {
17-
if (typeof c.poloniex[k] === 'undefined') {
18-
c.poloniex[k] = defs[k]
19-
}
20-
})
219

2210
var public_client, authed_client
2311

0 commit comments

Comments
 (0)