Example #1
0
def chart1(pair):
    jq("#echart1").show()
    Objcharts['ob'] = window.echarts.init(document.getElementById("echart1"))
    og = w_mod_graphs.OrderBook1(Objcharts['ob'])
    og.title = pair + " orderbook"
    og.market = pair
    og.orders = Order_pos[pair]
    if Last_Pair in ChartOb:
        ChartData_ob[pair]['datazoom'] = [
            ChartOb[Last_Pair]['start'], ChartOb[Last_Pair]['end']
        ]
    og.load_data(ChartData_ob[pair])
Example #2
0
def chart1(pair):
    jq("#echart1").show()
    Objcharts['chart1'] = window.echarts.init(
        document.getElementById("echart1"))
    og = w_mod_graphs.OrderBook1('orderbook', Objcharts['chart1'], axis_sync)
    og.title = pair + " orderbook"
    og.market = pair
    if pair in Order_pos:
        og.orders = Order_pos[pair]
    if Last_Pair in ChartOb:
        ChartData_ob[pair]['datazoom'] = [
            ChartOb[Last_Pair]['start'], ChartOb[Last_Pair]['end']
        ]
    og.load_data(ChartData_ob[pair])

    def froga(ev):
        print('click')

    document.getElementById("echart1").addEventListener('click', froga)
Example #3
0
def on_tabshown(ev):
	id = int(ev.target.hash.split("-")[1])
	if id == 1:
		jq('#tableExample1').DataTable().search('').draw()
		jq("#echartx").hide()

	market = MarketTab2[id]
	Ws_comm.send({'operation': 'enqueue', 'module': Module_name, 'what': 'get_market_trades', 'market': market,
		'date_from': (datetime.datetime.now() - datetime.timedelta(days=30)).isoformat(),
		'date_to': datetime.datetime.now().isoformat()})

	if market not in ChartData:
		return

	jq("#echartx").show()
	ograph = window.echarts.init(document.getElementById("echartx"))
	og = w_mod_graphs.OrderBook1(ograph)
	og.title = market + " orderbook"
	og.market = market
	og.orders = Order_pos[market]
	og.load_data(ChartData[market])
	jq('#tableExample1').DataTable().search(market).draw()
Example #4
0
def incoming_data(data):
    global Panels, Order_pos
    if 'pong' in data['data']:
        print("pong!------")

    elif 'market_trades' in data['data']:
        market = data['data']['market_trades']['market']
        for p in Panels:
            if Panels[p]['market'] == market and Panels[p][
                    'chart_type'] == "trades":
                jq("#loading_" + p).hide()
                jq("#echart_" + p).show()
                obj = window.echarts.init(
                    document.getElementById("echart_" + p))
                og = w_mod_graphs.MarketTrades1(obj)
                og.market = market
                Panels[p]['echart_obj'] = obj
                Panels[p]['wmgraph_obj'] = og
                Panels[p]['data'] = data['data']
                Panels[p]['next_refresh'] = datetime.datetime.now(
                ) + datetime.timedelta(seconds=random.randint(60, 600))
                og.load_data(Panels[p]['data']['market_trades']['data'])

    elif 'orderbook' in data['data']:
        market = data['data']['orderbook']['market']
        maxv = data['data']['orderbook']['data'][0][3]
        data['data']['orderbook']['data'].insert(0, ['buy', 0, 0, maxv])
        for p in Panels:
            if Panels[p]['market'] == market and Panels[p][
                    'chart_type'] == "depth":
                jq("#loading_" + p).hide()
                jq("#echart_" + p).show()
                obj = window.echarts.init(
                    document.getElementById("echart_" + p))
                og = w_mod_graphs.OrderBook1(obj)
                og.market = market
                if market in Order_pos:
                    og.orders = Order_pos[market]
                Panels[p]['echart_obj'] = obj
                Panels[p]['wmgraph_obj'] = og
                Panels[p]['data'] = data['data']
                Panels[p]['next_refresh'] = datetime.datetime.now(
                ) + datetime.timedelta(seconds=random.randint(60, 600))
                og.load_data(Panels[p]['data']['orderbook']['data'])

    elif 'marketpanels_layout' in data['data']:
        print(data['data']['marketpanels_layout'])
        for panel in data['data']['marketpanels_layout']:
            print(panel)
            if len(panel) < 3:  # compatibility
                new_panel(panel[0], panel[1], "depth")
            else:
                new_panel(panel[0], panel[1], panel[2])

    elif 'open_positions' in data['data']:
        if data['data']['open_positions'] is None:
            return
        dat1 = data['data']['open_positions']
        dat1.sort(key=lambda x: x[0] + x[3] + x[1])
        markets = dict()
        dat = []
        Order_pos = {}
        for d in dat1:
            tmpl1 = "{:,." + str(d[8]) + "f}"
            tmpl2 = "{:,." + str(d[9]) + "f}"
            market = d[1] + "/" + d[3]
            dat.append([
                market, d[0],
                tmpl1.format(d[2]),
                tmpl2.format(d[5]),
                tmpl2.format(d[6]), d[7]
            ])
            if market in markets:
                Order_pos[market].append([d[0], d[5]])
            else:
                Order_pos[market] = [[d[0], d[5]]]