def chart2(pair): Objcharts['chart2'] = window.echarts.init( document.getElementById("echart2")) og = w_mod_graphs.MarketTrades1('ohlc', Objcharts['chart2'], axis_sync) og.title = pair + " trades" og.market = pair if pair in Order_pos: og.orders = Order_pos[pair] og.load_data(ChartData_trades[pair])
def incoming_data(data): global Panels if 'market_trades' in data['data']: market = data['data']['market_trades']['market'] for p in Panels: if Panels[p]['market'] == market: jq("#echart_" + p).show() obj = window.echarts.init( document.getElementById("echart_" + p)) og = w_mod_graphs.MarketTrades1(obj) og.title = market + " trades" og.market = market og.load_data(data['data']['market_trades']['data']) Panels[p]['echart_obj'] = obj Panels[p]['wmgraph_obj'] = og
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]]]
def incoming_data(data): global Order_pos, Order_id_list # [market, 'sell', "{0:,.5f}".format(q1), "{0:,.8f}".format(q2 / q1), "{0:,.5f}".format(q2), t[1]] if data['module'] != Module_name and data[ 'module'] != 'general': # ignore if nothing to do here return if 'open_positions' in data: if data['open_positions'] is None: return dat1 = [] Order_id_list = {} Order_id_deleted = [] Order_pos = {} #jq('#panel1').addClass('ld-loading') cols = "Market,Operation,Quantity,Price,Total,cancel" dat1.sort(key=lambda x: x[0] + x[3] + x[1]) markets = dict() # populate table dat = [] #[account[0], lo['id'], pair, 'buy', amount_quote, quote, amount_base, base, price, Assets[quote][1],Assets[base][1]]) for d in data['open_positions']: tmpl1 = "{:,." + str(d[9]) + "f}" tmpl2 = "{:,." + str(d[10]) + "f}" # {1.7.12321: 'account'} Order_id_list[d[1]] = d[0] dat.append([ d[2], d[3], tmpl1.format(d[4]), tmpl2.format(d[8]), tmpl2.format(d[6]), d[1] ]) if d[2] in markets: markets[d[2]] += 1 # quantity, price Order_pos[d[2]].append([d[4], d[8]]) else: markets[d[2]] = 1 Order_pos[d[2]] = [[d[4], d[8]]] # create tabs lmkts = list(markets.keys()) lmkts.sort() for t in enumerate(lmkts): create_tab(t[0] + 2, t[1], t[1], markets[t[1]]) # enqueue orderbooks query for l in lmkts[:]: Ws_comm.send({ 'call': 'get_orderbook', 'market': l, 'module': Module_name, 'operation': 'enqueue_bg' }) def cell_buttons(data, type, row, meta): if data not in Order_id_deleted: if wmodgeneral.Data.data['master_unlocked']: return '<a role="button" id="bDelOrder_{0}" class="fa fa-times fa-2x"></a>'.format( data) else: return '<span>not permission</span>' else: return '<span>deleted</span>'.format(data) dt = jq('#tableExample1').DataTable({ "data": dat, "columns": [{ 'title': v } for v in cols.split(",")], "dom": "<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp", "lengthMenu": [[10, 16, 50, -1], [10, 16, 50, "All"]], "columnDefs": [{ "targets": 5, "render": cell_buttons }], "drawCallback": table_drawn, "buttons": [{ "extend": 'copy', "className": 'btn-sm' }, { "extend": 'csv', "title": 'ExampleFile', "className": 'btn-sm' }, { "extend": 'pdf', "title": 'ExampleFile', "className": 'btn-sm' }, { "extend": 'print', "className": 'btn-sm' }] }) #jq('#panel1').removeClass('ld-loading') elif 'orderbook' in data: market = data['orderbook']['market'] maxv = data['orderbook']['data'][0][3] data['orderbook']['data'].insert(0, ['buy', 0, 0, maxv]) ChartData[market] = data['orderbook']['data'] elif 'market_trades' in data: market = data['market_trades']['market'] ograph = window.echarts.init(document.getElementById("echarty")) og = w_mod_graphs.MarketTrades1('trades', ograph, None) og.title = market + " trades" og.market = market og.orders = Order_pos[market] og.load_data(data['market_trades']['data']) elif 'balances' in data: print("----- balances") for b in data['balances']: print(b)
def incoming_data(data): global Order_pos # [market, 'sell', "{0:,.5f}".format(q1), "{0:,.8f}".format(q2 / q1), "{0:,.5f}".format(q2), t[1]] print('module', Module_name, "incoming_data") if 'open_positions' in data['data']: if data['data']['open_positions'] is None: return #jq('#panel1').addClass('ld-loading') cols = "Market,Operation,Quantity,Price,Total,Date" dat1 = data['data']['open_positions'] dat1.sort(key=lambda x: x[0]+x[3]+x[1]) markets = dict() # populate table print(dat1[-2:]) dat = [] 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: markets[market] += 1 Order_pos[market].append([d[0], d[5]]) else: markets[market] = 1 Order_pos[market] = [[d[0], d[5]]] # create tabs lmkts = list(markets.keys()) lmkts.sort() for t in enumerate(lmkts): create_tab(t[0]+2, t[1], t[1], markets[t[1]]) # enqueue orderbooks query for l in lmkts[:]: Ws_comm.send({'operation': 'enqueue_bg', 'module': Module_name, 'what': 'orderbook', 'market': l}) jq('#tableExample1').DataTable({"data": dat, "columns": [{'title': v} for v in cols.split(",")], "dom": "<'row'<'col-sm-4'l><'col-sm-4 text-center'B><'col-sm-4'f>>tp", "lengthMenu": [[10, 16, 50, -1], [10, 16, 50, "All"]], "buttons": [{"extend": 'copy', "className": 'btn-sm'}, {"extend": 'csv', "title": 'ExampleFile', "className": 'btn-sm'}, {"extend": 'pdf', "title": 'ExampleFile', "className": 'btn-sm'}, {"extend": 'print', "className": 'btn-sm'}]}) #jq('#panel1').removeClass('ld-loading') elif 'orderbook' in data['data']: print(data['data']['orderbook']['date'], data['data']['orderbook']['market'], data['data']['orderbook']['data'][0]) market = data['data']['orderbook']['market'] maxv = data['data']['orderbook']['data'][0][3] data['data']['orderbook']['data'].insert(0, ['buy', 0, 0, maxv]) ChartData[market] = data['data']['orderbook']['data'] elif 'market_trades' in data['data']: jq("#echarty").show() print("Market trades received") print(data['data']['market_trades']['market']) print(data['data']['market_trades']['market'], len(data['data']['market_trades']['data'])) print(data['data']['market_trades']['data'][0], len(data['data']['market_trades']['data'])) market = data['data']['market_trades']['market'] ograph = window.echarts.init(document.getElementById("echarty")) og = w_mod_graphs.MarketTrades1(ograph) og.title = market + " trades" og.market = market og.orders = Order_pos[market] og.load_data(data['data']['market_trades']['data']) elif 'balances' in data['data']: print("----- balances") for b in data['data']['balances']: print(b)