@@ -8,12 +8,13 @@ import {
88 STREAMING_TRADE_RECORD ,
99 Time ,
1010 TYPE_FIELD ,
11- Utils
1211} from '..'
1312import { TradePosition , TradePositions , TradeStatus } from '../interface/Interface'
1413import { CHART_RATE_LIMIT_BY_PERIOD , Currency2Pair , Listeners , PositionType , RelevantCurrencies } from '../enum/Enum'
1514import { Socket } from './Socket/Socket'
1615import { Stream } from './Stream/Stream'
16+ import { getObjectChanges } from '../utils/getObjectChanges'
17+ import { formatPosition } from '../utils/formatPosition'
1718
1819export const DefaultHostname = 'ws.xapi.pro'
1920export const DefaultRateLimit = 850
@@ -154,7 +155,7 @@ export class XAPI extends Listener {
154155 data . forEach ( t => {
155156 if ( this . _positions [ t . position ] === undefined || this . _positions [ t . position ] . value !== null ) {
156157 obj [ t . position ] = {
157- value : Utils . formatPosition ( t ) ,
158+ value : formatPosition ( t ) ,
158159 lastUpdated : sent
159160 }
160161 }
@@ -186,27 +187,27 @@ export class XAPI extends Listener {
186187 && t . cmd !== CMD_FIELD . SELL_LIMIT
187188 && t . cmd !== CMD_FIELD . BUY_STOP
188189 && t . cmd !== CMD_FIELD . SELL_STOP ) {
189- this . callListener ( Listeners . xapi_onPendingPosition , [ Utils . formatPosition ( t ) ] )
190+ this . callListener ( Listeners . xapi_onPendingPosition , [ formatPosition ( t ) ] )
190191 } else if ( t . state === 'Deleted' ) {
191192 if ( this . _positions [ t . position ] !== undefined && this . _positions [ t . position ] . value !== null ) {
192193 this . _positions [ t . position ] = { value : null , lastUpdated : time }
193- this . callListener ( Listeners . xapi_onDeletePosition , [ Utils . formatPosition ( t ) ] )
194+ this . callListener ( Listeners . xapi_onDeletePosition , [ formatPosition ( t ) ] )
194195 }
195196 } else if ( this . _positions [ t . position ] === undefined || this . _positions [ t . position ] . value !== null ) {
196197 if ( this . _positions [ t . position ] !== undefined ) {
197198 const { value} = this . _positions [ t . position ]
198199
199200 if ( value ) {
200- const changes = Utils . getObjectChanges ( value , Utils . formatPosition ( t ) )
201+ const changes = getObjectChanges ( value , formatPosition ( t ) )
201202 if ( Object . keys ( changes ) . length > 0 ) {
202- this . callListener ( Listeners . xapi_onChangePosition , [ Utils . formatPosition ( t ) ] )
203+ this . callListener ( Listeners . xapi_onChangePosition , [ formatPosition ( t ) ] )
203204 }
204205 }
205206 } else {
206- this . callListener ( Listeners . xapi_onCreatePosition , [ Utils . formatPosition ( t ) ] )
207+ this . callListener ( Listeners . xapi_onCreatePosition , [ formatPosition ( t ) ] )
207208 }
208209
209- this . _positions [ t . position ] = { value : Utils . formatPosition ( t ) , lastUpdated : time }
210+ this . _positions [ t . position ] = { value : formatPosition ( t ) , lastUpdated : time }
210211 }
211212 } )
212213
0 commit comments