Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @TVChartUI = flight.component ->
- @onReady = (callback) ->
- console.log 'onReady'
- setTimeout (->
- console.log 'TV ready function'
- callback
- exchanges: []
- symbols_types: []
- supports_marks: false
- supports_timescale_marks: false
- supports_time: true
- futures_regex: false
- has_daily: false
- has_weekly: false
- supported_resolutions: ['1', '5', '15', '30', '60', '120', '240', '360', '720', '1D', '3D', '1W']
- seconds_multipliers: ['1', '5', '15', '30', '60', '120', '240', '360', '720']
- ), 0
- @getBars = (symbolInfo, resolution, from, to, onHistoryCallback, onErrorCallback, firstDataRequest) ->
- console.log 'getBars @ ' + resolution
- if firstDataRequest
- if resolution == '1D'
- resolution = 60 * 24
- if resolution == '3D'
- resolution = 60 * 24 * 3
- if resolution == '1W'
- resolution = 60 * 24 * 7
- @getBarsFrom = from
- @getBarsTo = to
- @getBarsFirstDataRequest = firstDataRequest
- @getBarsCallback = onHistoryCallback
- return @component.trigger(document, 'switch::range_switch', x: resolution)
- return
- @searchSymbols = (userInput, exchange, symbolType, onResultReadyCallback) ->
- console.log 'searchSymbols'
- onResultReadyCallback []
- @resolveSymbol = (symbolName, onSymbolResolvedCallback, onResolveErrorCallback) ->
- setTimeout (->
- console.log 'resolveSymbol: ' + symbolName
- onSymbolResolvedCallback
- name: symbolName
- ticker: symbolName
- timezone: 'America/New_York'
- minmov: 1
- pricescale: 100000000
- session: '24x7'
- data_status: 'streaming'
- currency_code: symbolName
- has_intraday: true
- has_daily: true
- has_weekly: false
- supported_resolutions: [
- '1'
- '5'
- '15'
- '30'
- '60'
- '120'
- '240'
- '360'
- '720'
- '1D'
- '3D'
- '1W'
- ]
- ), 0
- @subscribeBars = (symbolInfo, resolution, onRealtimeCallback, subscriberUID, onResetCacheNeededCallback) ->
- console.log 'subscribeBars'
- @unsubscribeBars = (unsubscribeBars) ->
- console.log 'unsubscribeBars'
- @getMarks = (symbolInfo, startDate, endDate, onDataCallback, resolution) ->
- console.log 'getMarks'
- @getTimescaleMarks = (symbolInfo, startDate, endDate, onDataCallback, resolution) ->
- console.log 'getTimescaleMarks'
- @getServerTime = (callback) ->
- console.log 'getServerTime'
- @TVChartUIComponent = flight.component ->
- @mask = ->
- @$node.find('.mask').show()
- @unmask = ->
- @$node.find('.mask').hide()
- @request = ->
- @mask()
- @init = (event, data) ->
- if @firstBarTime == 0 and data.candlestick.length > 0
- @firstBarTime = data.candlestick[0][0]
- candles = []
- ref = data.candlestick
- for i of ref
- d = ref[i]
- t = d[0]
- st = t / 1000
- if st < window.tvchartui.getBarsFrom
- continue
- if st > window.tvchartui.getBarsTo and !window.tvchartui.getBarsFirstDataRequest
- continue
- candles[candles.length] =
- time: t
- open: d[1]
- high: d[2]
- low: d[3]
- close: d[4]
- console.log JSON.stringify(candles)
- if candles.length > 0
- window.tvchartui.getBarsCallback candles
- else
- window.tvchartui.getBarsCallback candles, noData: true
- @updateByTrades = (event, data) ->
- console.log event
- console.log JSON.stringify(data)
- @after 'initialize', ->
- @on document, 'trade::populate', @updateByTrades
- @on document, 'market::candlestick::request', @request
- @on document, 'market::candlestick::response', @init
- @on document, 'market::candlestick::trades', @updateByTrades
- @firstBarTime = 0
- window.tvchartui = new TVChartUI
- window.tvchartui.component = this
- tvinit()
- @trigger 'market::candlestick::created'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement