MCPcopy Create free account
hub / github.com/ccxt/ccxt / plotOrderBook

Function plotOrderBook

cli/ts/charts/orderbook.ts:10–63  ·  view source on GitHub ↗
(exchangeNames: string, symbol: string, args: any, cliOptions: any)

Source from the content-addressed store, hash-verified

8const defaultDepth = 15;
9
10async function plotOrderBook (exchangeNames: string, symbol: string, args: any, cliOptions: any) {
11 spinner.start ();
12 const exchangeIds = exchangeNames.split (',');
13
14 const exchangePromises = exchangeIds.map ((id) => loadSettingsAndCreateExchange (id, cliOptions));
15
16 const exchanges = await Promise.all (exchangePromises);
17
18 const depth = args[0] ?? defaultDepth;
19 const boxWidth = 35;
20 const boxHeight = depth * 2 + 7;
21
22 const screen = blessed.screen ({
23 'smartCSR': true,
24 'title': `Order Book - ${symbol}`,
25 });
26
27 // append screens
28 const boxes = [];
29 for (let i = 0; i < exchanges.length; i++) {
30 const box = blessed.box ({
31 'top': 'center',
32 'left': boxWidth * i + 2,
33 'width': boxWidth,
34 'height': boxHeight,
35 'tags': true,
36 'border': {
37 'type': 'line',
38 },
39 'style': {
40 'fg': 'white',
41 'bg': 'black',
42 'border': { 'fg': 'magenta' },
43 },
44 });
45 boxes.push (box);
46 screen.append (box);
47 }
48 screen.key ([ 'escape', 'q', 'C-c' ], () => {
49 process.exit (0);
50 });
51
52 process.on ('SIGINT', () => {
53 screen.destroy (); // cleanup blessed screen
54 spinner.clear ();
55 process.exit (0);
56 });
57 // screen.render ();
58 const renderPromises = [];
59 for (let i = 0; i < exchanges.length; i++) {
60 renderPromises.push (renderOrderBook (screen, exchanges[i], symbol, boxes[i], exchanges[i].id, depth));
61 }
62 await Promise.all (renderPromises);
63}
64
65function center (str, width) {
66 const len = str.length;

Callers 1

cli.tsFile · 0.85

Calls 9

renderOrderBookFunction · 0.85
startMethod · 0.80
splitMethod · 0.80
pushMethod · 0.80
onMethod · 0.65
mapMethod · 0.45
appendMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…