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

Commit

Permalink
Merge pull request #1 from carlos8f/master
Browse files Browse the repository at this point in the history
Update from original
  • Loading branch information
RanfiCD committed Sep 23, 2017
2 parents a33cac4 + 0b2e953 commit 8c3d357
Show file tree
Hide file tree
Showing 7 changed files with 426 additions and 171 deletions.
9 changes: 6 additions & 3 deletions commands/balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,13 @@ module.exports = function container (get, set, clear) {
if (err) return cb(err)
s.exchange.getQuote(s, function (err, quote) {
if (err) throw err
var bal = moment().format('YYYY-MM-DD HH:mm:ss').grey + ' ' + engine.formatCurrency(quote.ask, true, true, false)
bal += ' ' + (s.product_id + ' Asset: ').grey + balance.asset.white + ' Currency: '.grey + balance.currency.yellow + ' Total: '.grey + n(balance.asset).multiply(quote.ask).add(balance.currency).value().toString().yellow

var bal = moment().format('YYYY-MM-DD HH:mm:ss').grey + ' ' + engine.formatCurrency(quote.ask, true, true, false) + ' ' + (s.product_id).grey + '\n'
bal += moment().format('YYYY-MM-DD HH:mm:ss').grey + ' Asset: '.grey + balance.asset.white + ' Available: '.grey + n(balance.asset).subtract(balance.asset_hold).value().toString().yellow + '\n'
bal += moment().format('YYYY-MM-DD HH:mm:ss').grey + ' Currency: '.grey + balance.currency.white + ' Available: '.grey + n(balance.currency).subtract(balance.currency_hold).value().toString().yellow + '\n'
bal += moment().format('YYYY-MM-DD HH:mm:ss').grey + ' Total: '.grey + n(balance.asset).multiply(quote.ask).add(balance.currency).value().toString().white
console.log(bal)

if (so.calculate_currency) {
s.exchange.getQuote({'product_id': s.asset + '-' + so.calculate_currency}, function (err, asset_quote) {
if (err) throw err
Expand Down
6 changes: 4 additions & 2 deletions conf-sample.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ c.bitfinex.secret = 'YOUR-SECRET'
// May use 'exchange' or 'trading' wallet balances. However margin trading may not work...read the API documentation.
c.bitfinex.wallet = 'exchange'

// to enable Bitfinex trading, enter your API credentials:
// to enable Bitstamp trading, enter your API credentials:
c.bitstamp = {}
c.bitstamp.key = 'YOUR-API-KEY'
c.bitstamp.secret = 'YOUR-SECRET'
Expand Down Expand Up @@ -102,7 +102,7 @@ c.buy_pct = 99
c.sell_pct = 99
// ms to adjust non-filled order after
c.order_adjust_time = 5000
// avoid selling at a loss below this pct
// avoid selling at a loss below this pct set to 0 to ensure selling at a higher price...
c.max_sell_loss_pct = 25
// ms to poll order status
c.order_poll_time = 5000
Expand All @@ -112,6 +112,8 @@ c.wait_for_settlement = 5000
c.markup_pct = 0
// become a market taker (high fees) or a market maker (low fees)
c.order_type = 'maker'
// when supported by the exchange, use post only type orders.
c.post_only = true

// Misc options:

Expand Down
34 changes: 34 additions & 0 deletions docs/raspberrypi.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(I'm running it on a Raspberry Pi 3 with Raspbian Stretch)

**1. Install nodejs.**
http://thisdavej.com/beginners-guide-to-installing-node-js-on-a-raspberry-pi/

**2. Install docker and docker-compose.**
Docker:
https://blog.alexellis.io/getting-started-with-docker-on-raspberry-pi/
Docker-compose instructions at the end of this page:
https://pixelchrome.org/blog/quickstart-guide-how-to-install-docker-a-raspberry-pi/

**3. Install this or another mongodb dockerfile made for the rapsberry pi.**
https://hub.docker.com/r/nonoroazoro/rpi-mongo/

**4.Rename the mongodb dockerfile to "mongo"** so that the conf.js from zenbot works with it.
In my case:
`docker tag nonoroazoro/rpi-mongo:latest mongo:latest`

**5.Run the mongo dockerfile.**
`docker run mongo`
(You can control-c or command-c to close the dialogue after it stays at "waiting for connections on port 27017")
`docker ps`
to make sure mongo is running

**6. Run zenbot.**
`cd zenbot`
`docker-compose build`
`docker-compose up -d`

Commands are the same
`docker run --rm --link zenbot_mongodb_1:mongodb -it zenbot_server ./zenbot.sh [command]`


There ya go
2 changes: 1 addition & 1 deletion docs/strategy_forex_analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The model, along with the HTML simulation results of both _training_ and _test d

## Trading

You can use the trained model for training using the normal `trade` command:
You can use the trained model for trading using the normal `trade` command:

`./zenbot.sh trade bitfinex.ETH-USD --strategy forex_analytics --modelfile models/trained_model_file.json --paper`

Expand Down
8 changes: 4 additions & 4 deletions lib/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ module.exports = function container (get, set, clear) {
}

function pct (ratio) {
return (ratio >= 0 ? '+' : '') + n(ratio).format('0.0%')
return (ratio >= 0 ? '+' : '') + n(ratio).format('0.00%')
}

function initBuffer (trade) {
Expand Down Expand Up @@ -213,7 +213,7 @@ module.exports = function container (get, set, clear) {
}
else {
order.product_id = s.product_id
order.post_only = true
order.post_only = c.post_only
msg('placing ' + type + ' order...')
var order_copy = JSON.parse(JSON.stringify(order))
s.exchange[type](order_copy, function (err, api_order) {
Expand Down Expand Up @@ -664,7 +664,7 @@ module.exports = function container (get, set, clear) {
process.stdout.write(' ' + fc(s.period.close, true, true, true) + ' ' + s.product_id.grey)
if (s.lookback[0]) {
var diff = (s.period.close - s.lookback[0].close) / s.lookback[0].close
process.stdout.write(z(7, pct(diff), ' ')[diff >= 0 ? 'green' : 'red'])
process.stdout.write(z(8, pct(diff), ' ')[diff >= 0 ? 'green' : 'red'])
}
else {
process.stdout.write(z(8, '', ' '))
Expand Down Expand Up @@ -737,7 +737,7 @@ module.exports = function container (get, set, clear) {
process.stdout.write(z(8, pct(profit), ' ')[profit >= 0 ? 'green' : 'red'])
var buy_hold = s.period.close * (orig_capital / orig_price)
var over_buy_hold_pct = (consolidated - buy_hold) / buy_hold
process.stdout.write(z(7, pct(over_buy_hold_pct), ' ')[over_buy_hold_pct >= 0 ? 'green' : 'red'])
process.stdout.write(z(8, pct(over_buy_hold_pct), ' ')[over_buy_hold_pct >= 0 ? 'green' : 'red'])
}
if (!is_progress) {
process.stdout.write('\n')
Expand Down
Loading

0 comments on commit 8c3d357

Please sign in to comment.