@@ -33,7 +33,7 @@ export default class Bot {
33
33
constructor ( api = null ) {
34
34
this . ticks = [ ]
35
35
this . candles = [ ]
36
- this . candleInterval = 60
36
+ this . currentCandleInterval = 0
37
37
this . running = false
38
38
this . currentToken = ''
39
39
this . balanceStr = ''
@@ -83,9 +83,8 @@ export default class Bot {
83
83
observer . unregisterAll ( 'api.tick' )
84
84
promises . push ( this . subscribeToTickHistory ( ) )
85
85
promises . push ( this . subscribeToCandles ( ) )
86
- } else if ( this . tradeOption . candleInterval !== this . candleInterval ) {
86
+ } else if ( this . tradeOption . candleInterval !== this . currentCandleInterval ) {
87
87
observer . unregisterAll ( 'api.ohlc' )
88
- this . candleInterval = this . tradeOption . candleInterval
89
88
promises . push ( this . subscribeToCandles ( ) )
90
89
}
91
90
}
@@ -124,7 +123,7 @@ export default class Bot {
124
123
if ( ! _ . isEmpty ( this . tradeOption ) ) {
125
124
this . pip = this . symbol . activeSymbols . getSymbols ( ) [ this . tradeOption . symbol . toLowerCase ( ) ] . pip
126
125
const opposites = config . opposites [ this . tradeOption . condition ]
127
- this . candleInterval = this . tradeOption . candleInterval
126
+ this . currentCandleInterval = this . tradeOption . candleInterval
128
127
this . tradeOptions = [ ]
129
128
for ( const key of Object . keys ( opposites ) ) {
130
129
this . tradeOptions . push ( decorateTradeOptions ( this . tradeOption , {
@@ -153,6 +152,7 @@ export default class Bot {
153
152
return new Promise ( ( resolve ) => {
154
153
const apiCandles = ( candles ) => {
155
154
this . observeOhlc ( )
155
+ this . currentCandleInterval = this . tradeOption . candleInterval
156
156
this . candles = candles
157
157
resolve ( )
158
158
}
@@ -164,7 +164,7 @@ export default class Bot {
164
164
this . api . history ( this . tradeOption . symbol , {
165
165
end : 'latest' ,
166
166
count : 600 ,
167
- granularity : this . candleInterval ,
167
+ granularity : this . tradeOption . candleInterval ,
168
168
style : 'candles' ,
169
169
subscribe : 1 ,
170
170
} )
0 commit comments