forked from Haehnchen/crypto-trading-bot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnoop.js
128 lines (110 loc) · 3.88 KB
/
noop.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
'use strict';
const SD = require('technicalindicators').SD
const TA = require('../../../utils/technical_analysis')
let SignalResult = require('../dict/signal_result')
module.exports = class {
getName() {
return 'noop'
}
buildIndicator(indicatorBuilder, options) {
indicatorBuilder.add('bb', 'bb', '15m')
indicatorBuilder.add('rsi', 'rsi', '15m')
indicatorBuilder.add('mfi', 'mfi', '15m')
indicatorBuilder.add('volume_profile', 'volume_profile', '15m')
indicatorBuilder.add('zigzag', 'zigzag', '15m')
indicatorBuilder.add('pivot_points_high_low', 'pivot_points_high_low', '15m', {
'left': 14,
'right': 14,
})
indicatorBuilder.add('sma200', 'sma', '15m', {
'length': 200,
})
indicatorBuilder.add('sma50', 'sma', '15m', {
'length': 50,
})
indicatorBuilder.add('foreign_candle', 'candles', options['foreign_pair_period'] || '15m', {
'exchange': options['foreign_pair_exchange'] || 'binance',
'symbol': options['foreign_pair_symbol'] || 'BTCUSDT',
})
}
async period(indicatorPeriod, options) {
let currentValues = indicatorPeriod.getLatestIndicators()
let bollinger = indicatorPeriod.getIndicator('bb')
if (bollinger && currentValues.bb) {
let standardDeviation = SD.calculate({
period : 150,
values : bollinger.slice(-200).map(b => b.width),
})
currentValues.bb.sd = standardDeviation.slice(-1)[0]
}
let currentBB = indicatorPeriod.getLatestIndicator('bb')
if (currentBB && currentValues.bb) {
currentValues.bb.percent = TA.getBollingerBandPercent(indicatorPeriod.getPrice(), currentBB.upper, currentBB.lower)
}
let intl = new Intl.NumberFormat('en-US', { minimumSignificantDigits: 3, maximumSignificantDigits: 4})
let currentValue = currentValues['volume_profile'];
currentValues['ranges'] = currentValue
.sort((a, b) => b.totalVolume - a.totalVolume)
.slice(0, 3)
.map(v => intl.format(v.rangeStart) + '-' + intl.format(v.rangeEnd) + ' ' + intl.format(v.totalVolume))
.join(', ')
return SignalResult.createEmptySignal(currentValues)
}
getBacktestColumns() {
return [
{
'label': 'BollDev',
'value': 'bb.width',
'type': 'cross',
'cross': 'bb.sd',
},
{
'label': 'BollPct',
'value': 'bb.percent',
'type': 'oscillator',
'range': [1, 0],
},
{
'label': 'rsi',
'value': 'rsi',
'type': 'oscillator',
},
{
'label': 'mfi',
'value': 'mfi',
'type': 'oscillator',
},
{
'label': 'SMA 50/200',
'value': 'sma50',
'type': 'cross',
'cross': 'sma200',
},
{
'label': 'Pivot Points',
'value': 'pivot_points_high_low',
},
{
'label': 'Foreign',
'value': 'foreign_candle.close',
},
{
'label': 'Top Volume Ranges',
'value': 'ranges',
},
{
'label': 'zigzag',
'value': row => row.zigzag && row.zigzag.turningPoint === true ? 'warning' : undefined,
'type': 'icon',
},
]
}
getOptions() {
return {
'period': '15m',
'foreign_pair_exchange': 'binance',
'foreign_pair_symbol': 'BTCUSDT',
'foreign_pair_period': '15m',
}
}
}