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

Commit

Permalink
Updated trendline "AP markup mode", profitable neural. Examples.... (#…
Browse files Browse the repository at this point in the history
…988)

* Delete strategy.js

* Add files via upload

* Update strategy.js

* Update exchange.js

* Delete conf-sample.js

* Add files via upload

* Delete strategy.js

* Add files via upload

* Update strategy.js

* Add files via upload

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update README.md

* Update conf-sample.js

* for 30s period

* for 30s period & arbitrage coins multi instance

* Update README.md

* Update README.md

* Update README.md

* Delete strategy.js

* Add files via upload

* Delete conf-sample.js

* Add files via upload

* Add files via upload

* Update README.md

* Add files via upload

* Update README.md

* Add files via upload

* Update conf-sample.js

* Delete Capture.PNG

* Delete Capture2.PNG

* Rename README.md to extensions/strategies/neural/README.md

* Moved for trend-line update

* Add files via upload

* Create README.md

* Update README.md

* Add files via upload

* Create README.md

* Update and rename conf-sample.js to extensions/strategies/neural/conf-example.js

* Create conf-sample.js
  • Loading branch information
darthyvader authored and DeviaVir committed Dec 27, 2017
1 parent 70e7bbc commit f88e669
Show file tree
Hide file tree
Showing 8 changed files with 369 additions and 36 deletions.
5 changes: 1 addition & 4 deletions extensions/exchanges/poloniex/exchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,9 @@ module.exports = function container (get, set, clear) {
}

function retry (method, args) {
if (method !== 'getTrades') {
console.error(('\nPoloniex API is down! unable to call ' + method + ', retrying in 10s').red)
}
setTimeout(function () {
exchange[method].apply(exchange, args)
}, 10000)
}, 1)
}

var orders = {}
Expand Down
Binary file added extensions/strategies/neural/Capture.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
56 changes: 56 additions & 0 deletions extensions/strategies/neural/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

## Reading the console output

![console](Capture.PNG)

From left to right ( for trendline not pictured above, which is neural ):

- Timestamp in local time (grey, blue when showing "live" stats)
- Asset price in currency (yellow)
- Percent change of price since last period (red/green)
- Volume in asset since last period (grey)
- [RSI](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi) ANSI graph (red/green)
- strategy inormation, in order:
```
- col1: current last trade price
- col2: The old trade last trade price averaged with the prediction.
- If the predicted price and average of last trade price exceeds the current last trade price, then buy.. Like a neural-trendline.
```
- Current signal or action, including `buy`, `sell`, `buying`, `selling`, `bought`, `sold` and `last_trade_worth` (percent change in the trend direction since last buy/sell)
- Account balance (asset)
- Account balance (currency)
- Profit or loss percent (can be reset with `--reset_profit`)
- Gain or loss vs. buy/hold strategy

The signaling for this strategy example:

```
learn();
var item = tlp.reverse();
s.prediction = predict(item)
s.mean = s.lookback[0].close
s.meanp = math.mean(s.prediction, oldmean)
oldmean = s.prediction
}
// NORMAL onPeriod STUFF here
global.meanp = s.meanp
global.mean = s.mean
//something strange is going on here
global.sig0 = global.meanp < global.mean
if (
global.sig0 === false
)
{
s.signal = 'sell'
}
else if
(
global.sig0 === true
)
{
s.signal = 'buy'
}
cb()
}
},
```
222 changes: 222 additions & 0 deletions extensions/strategies/neural/conf-example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,222 @@
var c = module.exports = {}

/// This conf is for NEURAL strategy as a profitable sim example, use --period=1m

// mongo configuration
c.mongo = {}
c.mongo.host = process.env.MONGODB_PORT_27017_TCP_ADDR || 'localhost'
c.mongo.port = 27017
c.mongo.db = 'zenbot4'
c.mongo.username = null
c.mongo.password = null
// when using mongodb replication, i.e. when running a mongodb cluster, you can define your replication set here; when you are not using replication (most of the users), just set it to `null` (default).
c.mongo.replicaSet = null

// default selector. only used if omitting [selector] argument from a command.
c.selector = 'poloniex.BCH-BTC'
// name of default trade strategy
c.strategy = 'neural'

// Exchange API keys:

// to enable GDAX trading, enter your API credentials:
c.gdax = {}
c.gdax.key = 'XXX'
c.gdax.b64secret = 'XXX'
c.gdax.passphrase = 'XXX'

// to enable Poloniex trading, enter your API credentials:
c.poloniex = {}
c.poloniex.key = 'KEY'
c.poloniex.secret = 'SECRET'
// please note: poloniex does not support market orders via the API

// to enable Kraken trading, enter your API credentials:
c.kraken = {}
c.kraken.key = 'YOUR-API-KEY'
c.kraken.secret = 'YOUR-SECRET'
// Please read API TOS on https://www.kraken.com/u/settings/api
c.kraken.tosagree = 'disagree'

// to enable Binance trading, enter your API credentials:
c.binance = {}
c.binance.key = 'YOUR-API-KEY'
c.binance.secret = 'YOUR-SECRET'

// to enable Bittrex trading, enter your API credentials:
c.bittrex = {}
c.bittrex.key = 'YOUR-API-KEY'
c.bittrex.secret = 'YOUR-SECRET'
// make sure to give your API key access to only: "Trade Limit" and "Read Info",
// please note that this might change in the future.
// please note that bittrex API is limited, you cannot use backfills or sims (paper/live trading only)

// to enable Bitfinex trading, enter your API credentials:
c.bitfinex = {}
c.bitfinex.key = 'YOUR-API-KEY'
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 Bitstamp trading, enter your API credentials:
c.bitstamp = {}
c.bitstamp.key = 'YOUR-API-KEY'
c.bitstamp.secret = 'YOUR-SECRET'
// A client ID is required on Bitstamp
c.bitstamp.client_id = 'YOUR-CLIENT-ID'

// to enable CEX.IO trading, enter your API credentials:
c.cexio = {}
c.cexio.username = 'YOUR-CLIENT-ID'
c.cexio.key = 'YOUR-API-KEY'
c.cexio.secret = 'YOUR-SECRET'

// to enable QuadrigaCX tranding, enter your API credentials:
c.quadriga = {}
c.quadriga.key = 'YOUR-API-KEY'
// this is the manual secret key entered by editing the API access
// and NOT the md5 hash you see in the summary
c.quadriga.secret = 'YOUR-SECRET'
// replace with the client id used at login, as a string, not number
c.quadriga.client_id = 'YOUR-CLIENT-ID'

// to enable WEX.NZ trading, enter your API credentials:
// Note: WexNZ only supports backfilling the last ~1/4 day ATM.
c.wexnz = {}
c.wexnz.key = 'YOUR-API-KEY'
c.wexnz.secret = 'YOUR-SECRET'

// to enable Gemini trading, enter your API credentials:
c.gemini = {}
c.gemini.key = 'YOUR-API-KEY'
c.gemini.secret = 'YOUR-SECRET'
// set to false to trade on the live platform API
c.gemini.sandbox = true

// to enable hitBTC trading, enter your API credentials:
c.hitbtc = {}
c.hitbtc.key = 'YOUR-API-KEY'
c.hitbtc.secret = 'YOUR-SECRET'

// to enable therock trading, enter your API credentials:
c.therock = {}
c.therock.key = 'YOUR-API-KEY'
c.therock.secret = 'YOUR-SECRET'

// Optional stop-order triggers:

// sell if price drops below this % of bought price (0 to disable)
c.sell_stop_pct = 0
// buy if price surges above this % of sold price (0 to disable)
c.buy_stop_pct = 0
// enable trailing sell stop when reaching this % profit (0 to disable)
c.profit_stop_enable_pct = 0
// maintain a trailing stop this % below the high-water mark of profit
c.profit_stop_pct = 1

// Order execution rules:

// avoid trading at a slippage above this pct
c.max_slippage_pct = 5
// buy with this % of currency balance (WARNING : sim won't work properly if you set this value to 100)
c.buy_pct = 100
// sell with this % of asset balance (WARNING : sim won't work properly if you set this value to 100)
c.sell_pct = 100
// ms to adjust non-filled order after
c.order_adjust_time = 15000
// 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 = 15000
// ms to wait for settlement (after an order cancel)
c.wait_for_settlement = 5000
// % to mark down buy price for orders
c.markdown_buy_pct = 0.5
// % to mark up sell prie for orders
c.markup_sell_pct = 0.5
// 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:

// default # days for backfill and sim commands
c.days = 14
// ms to poll new trades at
c.poll_trades = 15000
// amount of currency to start simulations with
c.currency_capital = 1
// amount of asset to start simulations with
c.asset_capital = 0
// for sim, reverse time at the end of the graph, normalizing buy/hold to 0
c.symmetrical = false
// number of periods to calculate RSI at
c.rsi_periods = 14
// period to record balances for stats
c.balance_snapshot_period = '15m'
// avg. amount of slippage to apply to sim trades
c.avg_slippage_pct = 0.045
// time to leave an order open, default to 1 day (this feature is not supported on all exchanges, currently: GDAX)
c.cancel_after = 'day'

// Notifiers:
c.notifiers = {}

// xmpp config
c.notifiers.xmpp = {}
c.notifiers.xmpp.on = false // false xmpp disabled; true xmpp enabled (credentials should be correct)
c.notifiers.xmpp.jid = 'trader@domain.com'
c.notifiers.xmpp.password = 'Password'
c.notifiers.xmpp.host = 'domain.com'
c.notifiers.xmpp.port = 5222
c.notifiers.xmpp.to = 'MeMyselfAndI@domain.com'
// end xmpp configs

// pushbullets configs
c.notifiers.pushbullet = {}
c.notifiers.pushbullet.on = false // false pushbullets disabled; true pushbullets enabled (key should be correct)
c.notifiers.pushbullet.key = 'YOUR-API-KEY'
c.notifiers.pushbullet.deviceID = 'YOUR-DEVICE-ID'
// end pushbullets configs

// ifttt configs
c.notifiers.ifttt = {}
c.notifiers.ifttt.on = false // false ifttt disabled; true ifttt enabled (key should be correct)
c.notifiers.ifttt.makerKey = 'YOUR-API-KEY'
c.notifiers.ifttt.eventName = 'zenbot'
// end ifttt configs

// slack config
c.notifiers.slack = {}
c.notifiers.slack.on = false
c.notifiers.slack.webhook_url = ''
// end slack config

// discord configs
c.notifiers.discord = {}
c.notifiers.discord.on = false // false discord disabled; true discord enabled (key should be correct)
c.notifiers.discord.id = 'YOUR-WEBHOOK-ID'
c.notifiers.discord.token = 'YOUR-WEBHOOK-TOKEN'
// end discord configs

// prowl configs
c.notifiers.prowl = {}
c.notifiers.prowl.on = false // false prowl disabled; true prowl enabled (key should be correct)
c.notifiers.prowl.key = 'YOUR-API-KEY'
// end prowl configs

// textbelt configs
c.notifiers.textbelt = {}
c.notifiers.textbelt.on = false // false textbelt disabled; true textbelt enabled (key should be correct)
c.notifiers.textbelt.phone = '3121234567'
c.notifiers.textbelt.key = 'textbelt'
// end textbelt configs

// output
c.output = {}

// REST API
c.output.api = {}
c.output.api.on = true
c.output.api.port = 0 // 0 = random port
17 changes: 8 additions & 9 deletions extensions/strategies/neural/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ module.exports = function container (get, set, clear) {
this.option('periodLength', 'period length - make sure to lower your poll trades time to lower than this value. Same as --period', String, '1m')
this.option('activation_1_type', "Neuron Activation Type: sigmoid, tanh, relu", String, 'sigmoid')
this.option('neurons_1', "Neurons in layer 1 Shoot for atleast 100", Number, 1)
this.option('depth', "Rows of data to predict ahead for matches/learning", Number, 5)
this.option('depth', "Rows of data to predict ahead for matches/learning", Number, 1)
this.option('selector', "Selector", String, 'Gdax.BTC-USD')
this.option('min_periods', "Periods to calculate learn from", Number, 300)
this.option('min_predict', "Periods to predict next number from", Number, 100)
this.option('min_periods', "Periods to calculate learn from", Number, 1000)
this.option('min_predict', "Periods to predict next number from", Number, 1)
this.option('momentum', "momentum of prediction", Number, 0.9)
this.option('decay', "decay of prediction, use teeny tiny increments", Number, 0)
this.option('decay', "decay of prediction, use teeny tiny increments", Number, 0.1)
this.option('threads', "Number of processing threads you'd like to run (best for sim)", Number, 1)
this.option('learns', "Number of times to 'learn' the neural network with past data", Number, 10)
this.option('markup_pct', "Defaulting a markup percent", Number, 0.05)
this.option('learns', "Number of times to 'learn' the neural network with past data", Number, 2)
},
calculate: function (s) {
calculated = null
Expand Down Expand Up @@ -81,7 +80,7 @@ module.exports = function container (get, set, clear) {
learn();
var item = tlp.reverse();
s.prediction = predict(item)
s.mean = math.mean(s.lookback[0].close, s.lookback[1].close, s.lookback[2].close)
s.mean = s.lookback[0].close
s.meanp = math.mean(s.prediction, oldmean)
oldmean = s.prediction
}
Expand All @@ -108,9 +107,9 @@ module.exports = function container (get, set, clear) {
},
onReport: function (s) {
cols = []
cols.push(z(8, n(global.mean).format('00000.000'), ' ')[global.meanp > global.mean ? 'green' : 'red'])
cols.push(z(8, n(global.mean).format('0.000000000'), ' ')[global.meanp > global.mean ? 'green' : 'red'])
cols.push(' ')
cols.push(z(8, n(global.meanp).format('00000.000'), ' ')[global.meanp > global.mean ? 'green' : 'red'])
cols.push(z(8, n(global.meanp).format('0.000000000'), ' ')[global.meanp > global.mean ? 'green' : 'red'])
return cols
},
}
Expand Down
Binary file added extensions/strategies/trendline/Capture.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
29 changes: 29 additions & 0 deletions extensions/strategies/trendline/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

## Reading the console output

![console](Capture.PNG)

From left to right ( for trendline not pictured above, which is neural ):

- Timestamp in local time (grey, blue when showing "live" stats)
- Asset price in currency (yellow)
- Percent change of price since last period (red/green)
- Volume in asset since last period (grey)
- [RSI](http://stockcharts.com/school/doku.php?id=chart_school:technical_indicators:relative_strength_index_rsi) ANSI graph (red/green)
- strategy inormation, in order:
```
- col1: trendline 10000/1000 trades
- col2: trendline 1000/100 trades
- col3:stdev of 10000 trades
- col4: stdev of 1000 trades
- col5: 10000trades mean
- col6: 1000 trades mean
- col7: the mean of the 10000 & 1000 trades and stdev calculated into 100* the stdev percentage of the mean of the long and short trades (in short the active-markup based on a multiplier to create a percentage of standard deviation.)
- If the four cols on the right are green, that means its a currently increasing trend) when both on the left are green both trends are increasing)
```
- Current signal or action, including `buy`, `sell`, `buying`, `selling`, `bought`, `sold` and `last_trade_worth` (percent change in the trend direction since last buy/sell)
- Account balance (asset)
- Account balance (currency)
- Profit or loss percent (can be reset with `--reset_profit`)
- Gain or loss vs. buy/hold strategy

Loading

0 comments on commit f88e669

Please sign in to comment.