File size: 109,247 Bytes
c95b927 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 | ```gmp.tex
\documentclass[conference]{IEEEtran}
% ββ Packages ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{hyperref}
\usepackage{cleveref}
% ββ Meta ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\hypersetup{
colorlinks=true,
linkcolor=blue,
citecolor=blue,
urlcolor=blue
}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% TITLE
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\title{GMP: Gap-filled Market Profile Universal Construction for Any Data Points}
\author{\IEEEauthorblockN{ConQ Research Team}\\
\IEEEauthorblockA{\textit{Continual Quasars}\\
\today}
}
\maketitle
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% ABSTRACT
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\begin{abstract}
Conventional Market Profile (CMP) aggregates price activity into histogram bins, but when applied to any ordered sequence of price points (ticks, candlesticks, or other sampled data), it leaves bins between consecutive points empty. We propose \textbf{GMP (Gap-Filled Market Profile)}, a universal construction method that (i) operates on any sequence of price observations and (ii) interpolates every intermediate price bin traversed between successive points, producing a \emph{gap-filled} profile. Building on this gapβfilled structure, we introduce an \emph{Up/DownβBin Footprint Profile} that classifies each bin's contribution directionally, revealing net upward or downward pressure across the price traversal. We formalise CMP and GMP with explicit algorithms, derive the relationship between bin count and a userβdefined binβsize parameter $\beta$, and present a complete worked example showing how points are grouped into bins under CMP, how gapβfilling transforms the sparse CMP output into a dense GMP profile, and how directional footprints are assigned. Charts and tables demonstrate that GMP yields a strictly denser and more informative distribution than CMP, independent of the original data source.
\end{abstract}
\begin{IEEEkeywords}
Market Profile, gap-filling interpolation, price bins, directional footprint, high-frequency data, time series
\end{IEEEkeywords}
% ββ Sideβbyβside introductory CMP vs GMP figure βββββββββββββββββββββββββββββ
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={\textbf{CMP Profile}},
xbar,
xlabel={Stacks},
ylabel={Price (USD)},
ytick={3000,3001,...,3010},
yticklabel style={font=\scriptsize},
xmin=0, xmax=2,
ymin=2999.5, ymax=3010.5,
bar width=4pt,
width=0.42\columnwidth,
height=6.5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny},
name=cmp
]
\addplot[fill=gray!60, draw=black] coordinates {
(1,3000) (0,3001) (0,3002) (0,3003) (0,3004) (0,3005)
(0,3006) (0,3007) (0,3008) (0,3009) (1,3010)
};
\end{axis}
\begin{axis}[
title={\textbf{GMP Profile}},
xbar,
xlabel={Stacks},
ylabel={},
ytick={3000,3001,...,3010},
yticklabel style={font=\scriptsize},
xmin=0, xmax=2,
ymin=2999.5, ymax=3010.5,
bar width=4pt,
width=0.42\columnwidth,
height=6.5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny},
at={(cmp.east)},
anchor=west,
xshift=1.2cm
]
\addplot[fill=blue!50, draw=black] coordinates {
(1,3000) (1,3001) (1,3002) (1,3003) (1,3004) (1,3005)
(1,3006) (1,3007) (1,3008) (1,3009) (1,3010)
};
\end{axis}
\end{tikzpicture}
\caption{Horizontal histogram comparison of CMP (left, grey) and GMP (right, blue) for a price move from 3000 to 3010 with $\beta=1$. CMP shows activity only at the two observed prices; GMP fills all 11 traversed bins. Gapβfilling applies to any data sequence.}
\label{fig:profile}
\end{figure}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% I. INTRODUCTION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Introduction}\label{sec:intro}
The Market Profile, introduced by Steidlmayer~\cite{steidlmayer1986market} and later formalised by Dalton et~al.~\cite{dalton2007markets}, represents price activity as a horizontal histogram whose bins correspond to discrete price levels and whose bar lengths (``stacks'') reflect the amount of activity observed at each level. In practice, most implementations construct the profile from candlestick TOCHLV (time, open, close, high, low, volume) data: each candle contributes one stack to every bin between its high and low.
This approach suffers from a fundamental shortcoming when applied to any sequence of discrete price points: when consecutive points are separated by several price levels, the conventional profile records activity only at the two observed prices, ignoring the fact that price must have traversed every intermediate level. This gap neglect is not specific to any data sourceβit occurs with ticks, candlesticks, or any sampled price series.
We address this issue with \textbf{GMP (GapβFilled Market Profile)}. The construction rule is universal: for every ordered sequence of price observations $\{p_i\}_{i=1}^{N}$, every bin between two successive points receives an interpolated stack, producing a profile with no gaps. The method does not depend on the original data frequency, source, or aggregation level; it applies equally to millisecond tick data, hourly candlesticks, or irregularly sampled price records.
The main contributions of this work are:
\begin{enumerate}
\item A rigorous formalisation of CMP and GMP with explicit algorithms and complexity analyses.
\item A theoretical relationship between the userβcontrolled binβsize parameter $\beta$ and profile resolution, including a scaling proposition.
\item A universal gapβfilling methodology that can be applied to any ordered price sequence, irrespective of source.
\item The introduction of an \emph{Up/DownβBin Footprint Profile}, a directional classification derived purely from the price traversal without requiring volume or orderβbook data.
\item A complete, selfβcontained illustration of the construction on a tenβpoint price sequence, demonstrating all theoretical constructs.
\end{enumerate}
The remainder of this paper is organised as follows. \Cref{sec:related} surveys related work. \Cref{sec:prelim} establishes notation. \Cref{sec:method} defines CMP and GMP formally, presents the GMP algorithm, and introduces the Up/DownβBin Footprint Profile. \Cref{sec:walkthrough} provides a complete profile construction example using a 10βpoint price sequence. \Cref{sec:binsize} analyses the effect of bin size on profile resolution. \Cref{sec:example} offers a minimal illustrative example. \Cref{sec:discussion} discusses theoretical implications, and \Cref{sec:conclusion} concludes.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% II. RELATED WORK
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Related Work}\label{sec:related}
\subsection{Market Profile}
The Market Profile concept originates with Steidlmayer's observation that price distributions at each level reveal where market participants find ``fair value''~\cite{steidlmayer1986market}. Dalton et~al.~\cite{dalton2007markets} extended the framework with auctionβmarket theory, using halfβhour brackets as timeβprice opportunities (TPOs). Both formulations rely on timeβbased bars rather than raw ticks, but the underlying logic of binning price activity is independent of the data source.
\subsection{Interpolation in Financial Time Series}
Interpolation techniques are common in highβfrequency finance. Clark~\cite{clark1973subordinated} demonstrated that subordinating returns to tradeβcount time yields closerβtoβGaussian distributions, motivating tradeβindexed analysis. An\'{e} and Geman~\cite{ane2000order} confirmed that businessβtime transformations normalise returns at the tick level. The gapβfilling approach we propose is conceptually similar to linear interpolation on the price axis, but applied to histogram bin counts rather than to prices themselves.
\subsection{Footprint and OrderβFlow Analysis}
Market microstructure theory, including Glosten and Milgrom~\cite{glosten1985bid}, O'Hara~\cite{ohara1995market}, and Madhavan~\cite{madhavan2000market}, provides foundations for analysing directional pressure. Traditional footprint charts distinguish trades at bid versus ask prices. Our Up/DownβBin Footprint provides a complementary directional classification derived purely from the sequence of price observations, without requiring volume or orderβbook data.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% III. PRELIMINARIES
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Preliminaries}\label{sec:prelim}
\Cref{tab:notation} summarises the notation used throughout.
\begin{table}[!t]
\centering
\caption{Notation Summary}
\label{tab:notation}
\begin{tabular}{@{}cl@{}}
\toprule
\textbf{Symbol} & \textbf{Description} \\
\midrule
$N$ & Total number of price observations in the sequence \\
$p_i$ & Price of the $i$-th observation, $i\in\{1,\dots,N\}$ \\
$\beta$ & Bin size (price units per bin); default $\beta=1$ \\
$b(p)$ & Bin index of price $p$: $b(p)=\lfloor p/\beta \rfloor$ \\
$S[k]$ & Stack count (profile value) at bin~$k$ \\
$\Delta_i$ & Price displacement: $\Delta_i = p_i - p_{i-1}$ \\
$K_i$ & Number of bins traversed from observation $i{-}1$ to $i$ \\
$U[k]$ & Upβbin count at bin $k$ \\
$D[k]$ & Downβbin count at bin $k$ \\
$\delta[k]$ & Net footprint delta at bin $k$: $\delta[k] = U[k] - D[k]$ \\
\bottomrule
\end{tabular}
\end{table}
\begin{definition}[Price observation sequence]
A \emph{price observation sequence} is an ordered set $\mathcal{P}=\{(t_i,\,p_i)\}_{i=1}^{N}$ where $t_i$ is an index (time, trade number, or any monotonic identifier) and $p_i$ is the observed price.
\end{definition}
\begin{definition}[Bin]
Given bin size $\beta>0$, the \emph{bin} for price $p$ is the integer index
\begin{equation}\label{eq:bin}
b(p) = \left\lfloor \frac{p}{\beta} \right\rfloor.
\end{equation}
All prices $p$ satisfying $k\beta \le p < (k+1)\beta$ map to bin~$k$.
\end{definition}
\begin{definition}[Market Profile]
A \emph{market profile} is a mapping $S:\mathbb{Z}\to\mathbb{N}_0$ where $S[k]$ counts the number of stacks accumulated at bin~$k$.
\end{definition}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% IV. METHODOLOGY
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Methodology}\label{sec:method}
\subsection{Conventional Market Profile (CMP)}\label{sec:cmp}
CMP records a stack only at the bin of each observed data point:
\begin{equation}\label{eq:cmp}
S_{\text{CMP}}[k] \;=\; \sum_{i=1}^{N} \mathbf{1}\!\bigl[b(p_i)=k\bigr],
\end{equation}
where $\mathbf{1}[\cdot]$ is the indicator function. Bins with no observed point receive $S_{\text{CMP}}[k]=0$.
\begin{algorithm}[!t]
\caption{CMP Construction}\label{alg:cmp}
\begin{algorithmic}[1]
\REQUIRE Price sequence $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile array $S_{\text{CMP}}[\cdot]$
\STATE Initialise $S_{\text{CMP}}[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 1$ \TO $N$}
\STATE $k \leftarrow \lfloor p_i / \beta \rfloor$
\STATE $S_{\text{CMP}}[k] \leftarrow S_{\text{CMP}}[k] + 1$
\ENDFOR
\RETURN $S_{\text{CMP}}$
\end{algorithmic}
\end{algorithm}
\textbf{Complexity.} CMP performs exactly $N$ binβindex computations and $N$ increments, giving $\mathcal{O}(N)$ time complexity.
\subsection{GapβFilled Market Profile (GMP)}\label{sec:gmp}
GMP augments CMP by filling every \emph{intermediate} bin between two consecutive observations. The construction proceeds in two phases:
\begin{enumerate}
\item \textbf{CMP placement.} Each observation $p_i$ contributes one stack to its own bin $b(p_i)$, exactly as in CMP.
\item \textbf{Gapβfilling.} For each consecutive pair $(p_{i-1},\,p_i)$ with $i\ge 2$, every bin \emph{strictly between} $b(p_{i-1})$ and $b(p_i)$ (exclusive of both endpoints) receives one additional stack.
\end{enumerate}
Formally, writing $b_i = b(p_i)$:
\begin{equation}\label{eq:gmp}
S_{\text{GMP}}[k]
\;=\;
\underbrace{\sum_{i=1}^{N}\mathbf{1}\!\bigl[b_i=k\bigr]}_{S_{\text{CMP}}[k]}
\;+\;
\sum_{i=2}^{N}
\;\sum_{j=\min(b_{i-1},\,b_i)+1}^{\max(b_{i-1},\,b_i)-1}
\!\mathbf{1}\!\bigl[j=k\bigr].
\end{equation}
When $|b_i - b_{i-1}| \le 1$ (adjacent or same bin), the inner sum is empty and no gapβfilling occurs. When $|b_i - b_{i-1}| > 1$, the number of gapβfilled (intermediate) bins is
\begin{equation}\label{eq:Ki}
G_i \;=\; \bigl|b(p_i) - b(p_{i-1})\bigr| - 1.
\end{equation}
The total span of bins traversed, inclusive of both endpoints, is $K_i = G_i + 2 = |b_i - b_{i-1}| + 1$.
\begin{algorithm}[!t]
\caption{GMP Construction (TwoβPhase)}\label{alg:gmp}
\begin{algorithmic}[1]
\REQUIRE Price sequence $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile array $S_{\text{GMP}}[\cdot]$
\STATE Initialise $S_{\text{GMP}}[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 1$ \TO $N$} \COMMENT{Phase~1: CMP placement}
\STATE $S_{\text{GMP}}[\lfloor p_i/\beta \rfloor] \leftarrow S_{\text{GMP}}[\lfloor p_i/\beta \rfloor] + 1$
\ENDFOR
\FOR{$i = 2$ \TO $N$} \COMMENT{Phase~2: gapβfill}
\STATE $k_{\text{from}} \leftarrow \lfloor p_{i-1}/\beta \rfloor$; $k_{\text{to}} \leftarrow \lfloor p_i/\beta \rfloor$
\IF{$|k_{\text{to}} - k_{\text{from}}| > 1$}
\STATE $d \leftarrow \text{sign}(k_{\text{to}} - k_{\text{from}})$
\FOR{$k = k_{\text{from}} + d$ \TO $k_{\text{to}} - d$ \textbf{step} $d$}
\STATE $S_{\text{GMP}}[k] \leftarrow S_{\text{GMP}}[k] + 1$
\ENDFOR
\ENDIF
\ENDFOR
\RETURN $S_{\text{GMP}}$
\end{algorithmic}
\end{algorithm}
\textbf{Complexity.} Let $D=\sum_{i=2}^{N}|b(p_i)-b(p_{i-1})|$ denote the cumulative bin displacement. GMP performs $\mathcal{O}(N + D)$ operations. In the degenerate case where all observations share the same bin, $D=0$ and GMP reduces to CMP. In the worst case, $D=\mathcal{O}(N\cdot\Delta p_{\max}/\beta)$.
\subsection{GMP as a Universal Construction}\label{sec:universal}
The key contribution of GMP is its universality: the gapβfilling rule applies to \emph{any} ordered price sequence, regardless of the original data's temporal spacing, source, or aggregation level. This includes:
\begin{itemize}
\item Raw tick data (millisecondβresolution bid/ask records)
\item Candlestick TOCHLV sequences (using close, high, low, or any representative price)
\item Irregularly sampled price points
\item Synthetic price paths or simulated data
\end{itemize}
The only requirement is that the sequence be ordered (by time, trade index, or any monotonic index). The construction makes no assumption about the mechanism that generated the prices; it purely interpolates bin traversals between consecutive observations.
\subsection{Up/DownβBin Footprint Profile}\label{sec:updown}
Building upon the gapβfilled structure of GMP, we introduce a directional classification layer termed the \emph{Up/DownβBin Footprint Profile}. For every consecutive pair $(p_{i-1},\,p_i)$, the trajectory is evaluated as upward or downward based on the price difference. The origin bin $b(p_{i-1})$ is assigned no directional credit for this move (it has already been evaluated by prior action). However, every subsequent bin along the traversed path up to and including the destination bin $b(p_i)$ increments its \emph{upβbin} count $U[k]$ if $p_i > p_{i-1}$, or its \emph{downβbin} count $D[k]$ if $p_i \le p_{i-1}$.
\begin{algorithm}[!t]
\caption{Up/DownβBin Footprint Construction}\label{alg:updown}
\begin{algorithmic}[1]
\REQUIRE Price sequence $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile arrays $U[\cdot], D[\cdot], \delta[\cdot]$
\STATE Initialise $U[k]\leftarrow 0, D[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 2$ \TO $N$}
\STATE $k_{\text{from}} \leftarrow \lfloor p_{i-1}/\beta \rfloor$; $k_{\text{to}} \leftarrow \lfloor p_i/\beta \rfloor$
\IF{$k_{\text{from}} = k_{\text{to}}$}
\IF{$p_i > p_{i-1}$}
\STATE $U[k_{\text{from}}] \leftarrow U[k_{\text{from}}] + 1$
\ELSE
\STATE $D[k_{\text{from}}] \leftarrow D[k_{\text{from}}] + 1$
\ENDIF
\STATE \textbf{continue}
\ENDIF
\STATE $\text{is\_up} \leftarrow (k_{\text{to}} > k_{\text{from}})$
\STATE $d \leftarrow \text{sign}(k_{\text{to}} - k_{\text{from}})$
\STATE $k \leftarrow k_{\text{from}} + d$
\WHILE{\textbf{true}}
\IF{$\text{is\_up}$}
\STATE $U[k] \leftarrow U[k] + 1$
\ELSE
\STATE $D[k] \leftarrow D[k] + 1$
\ENDIF
\IF{$k = k_{\text{to}}$}
\STATE \textbf{break}
\ENDIF
\STATE $k \leftarrow k + d$
\ENDWHILE
\ENDFOR
\FORALL{$k$}
\STATE $\delta[k] \leftarrow U[k] - D[k]$
\ENDFOR
\RETURN $U,\,D,\,\delta$
\end{algorithmic}
\end{algorithm}
This algorithm traces the same $\mathcal{O}(N+D)$ bins as the GMP phase, maintaining computational efficiency while providing deep structural insight into directional dominance across the price range.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% V. PROFILE CONSTRUCTION WALKTHROUGH
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Profile Construction Walkthrough}\label{sec:walkthrough}
We illustrate the construction on a tenβpoint price sequence. Each observation is a triple $(\text{label}, x, y)$ where \textit{label} is an alphabetic identifier, $x$ is the index, and $y$ the price. \Cref{tab:datapoints} lists the data.
\begin{table}[!t]
\centering
\caption{Input Observations (10 Points)}
\label{tab:datapoints}
\begin{tabular}{@{}ccc@{}}
\toprule
\textbf{Label} & \textbf{Index \#} & \textbf{Price (USD)} \\
\midrule
A & 1 & 3000.914 \\
B & 2 & 3003.837 \\
C & 3 & 3002.432 \\
D & 4 & 3009.892 \\
E & 5 & 3007.698 \\
F & 6 & 3009.176 \\
G & 7 & 3003.381 \\
H & 8 & 3004.283 \\
I & 9 & 3003.512 \\
J & 10 & 3003.012 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={Price vs.\ Index},
xlabel={Index},
ylabel={Price (USD)},
ymin=2999.5, ymax=3011,
grid=both,
width=\columnwidth,
height=5cm,
legend style={at={(0.5,-0.15)}, anchor=north, legend columns=-1}
]
\addplot[
only marks,
mark=*,
mark size=2pt,
blue
] coordinates {
(1,3000.914) (2,3003.837) (3,3002.432) (4,3009.892) (5,3007.698)
(6,3009.176) (7,3003.381) (8,3004.283) (9,3003.512) (10,3003.012)
};
\legend{Observed price}
\end{axis}
\end{tikzpicture}
\caption{Price vs.\ index for the 10βpoint example.}
\label{fig:price_scatter}
\end{figure}
\subsection{CMP Profile Table}\label{sec:cmp_table}
With $\beta=1$, the bin index is $b(p)=\lfloor p\rfloor$. CMP counts points per bin. \Cref{tab:cmp_profile} shows that bins 2, 6, 7, and 9 are emptyβthe gaps in the conventional profile.
\begin{table}[!t]
\centering
\caption{CMP Profile Table ($\beta=1$)}
\label{tab:cmp_profile}
\begin{tabular}{@{}ccccc@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until} & \textbf{Group} & \textbf{Stacks} \\
\midrule
1 & 3000 & 3001 & A & 1 \\
2 & 3001 & 3002 & & 0 \\
3 & 3002 & 3003 & C & 1 \\
4 & 3003 & 3004 & BGIJ & 4 \\
5 & 3004 & 3005 & H & 1 \\
6 & 3005 & 3006 & & 0 \\
7 & 3006 & 3007 & & 0 \\
8 & 3007 & 3008 & E & 1 \\
9 & 3008 & 3009 & & 0 \\
10 & 3009 & 3010 & DF & 2 \\
\midrule
\multicolumn{4}{c}{\textbf{Total stacks}} & \textbf{10} \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={CMP Profile},
xbar,
xlabel={Stacks},
ylabel={Price (USD)},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=5,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=\columnwidth,
height=5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny}
]
\addplot[fill=orange!50, draw=black] coordinates {
(1,3000) (0,3001) (1,3002) (4,3003) (1,3004)
(0,3005) (0,3006) (1,3007) (0,3008) (2,3009)
};
\end{axis}
\end{tikzpicture}
\caption{CMP profile for the 10βpoint example ($\beta=1$). Four bins are empty.}
\label{fig:cmp_chart}
\end{figure}
\subsection{GMP Profile Table}\label{sec:gmp_table}
GMP fills intermediate bins between consecutive points. \Cref{tab:gmp_profile} shows every bin now populated, with total stack count 25.
\begin{table}[!t]
\centering
\caption{GMP Profile Table ($\beta=1$)}
\label{tab:gmp_profile}
\begin{tabular}{@{}ccccc@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until} & \textbf{Group} & \textbf{Stacks} \\
\midrule
1 & 3000 & 3001 & A & 1 \\
2 & 3001 & 3002 & A & 1 \\
3 & 3002 & 3003 & AC & 2 \\
4 & 3003 & 3004 & BCGIJ & 5 \\
5 & 3004 & 3005 & CFH & 3 \\
6 & 3005 & 3006 & CF & 2 \\
7 & 3006 & 3007 & CF & 2 \\
8 & 3007 & 3008 & CEF & 3 \\
9 & 3008 & 3009 & CDEF & 4 \\
10 & 3009 & 3010 & DF & 2 \\
\midrule
\multicolumn{4}{c}{\textbf{Total stacks}} & \textbf{25} \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={GMP Profile},
xbar,
xlabel={Stacks},
ylabel={Price (USD)},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=6,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=\columnwidth,
height=5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny}
]
\addplot[fill=green!40, draw=black] coordinates {
(1,3000) (1,3001) (2,3002) (5,3003) (3,3004)
(2,3005) (2,3006) (3,3007) (4,3008) (2,3009)
};
\end{axis}
\end{tikzpicture}
\caption{GMP profile for the 10βpoint example ($\beta=1$). Every bin is populated.}
\label{fig:gmp_chart}
\end{figure}
\subsection{CMP vs.\ GMP SideβbyβSide}\label{sec:cmp_gmp_compare}
\Cref{fig:cmp_vs_gmp_10pt} places both profiles side by side. CMP (10 stacks) leaves 40\% of bins empty; GMP (25 stacks) fully covers the range.
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={CMP},
xbar,
xlabel={Stacks},
ylabel={Price (USD)},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=6,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=0.42\columnwidth,
height=6cm,
enlarge y limits=0.05,
name=cmp_10
]
\addplot[fill=orange!50, draw=black] coordinates {
(1,3000) (0,3001) (1,3002) (4,3003) (1,3004)
(0,3005) (0,3006) (1,3007) (0,3008) (2,3009)
};
\end{axis}
\begin{axis}[
title={GMP},
xbar,
xlabel={Stacks},
ylabel={},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=6,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=0.42\columnwidth,
height=6cm,
enlarge y limits=0.05,
at={(cmp_10.east)},
anchor=west,
xshift=0.8cm
]
\addplot[fill=green!40, draw=black] coordinates {
(1,3000) (1,3001) (2,3002) (5,3003) (3,3004)
(2,3005) (2,3006) (3,3007) (4,3008) (2,3009)
};
\end{axis}
\end{tikzpicture}
\caption{CMP vs.\ GMP sideβbyβside.}
\label{fig:cmp_vs_gmp_10pt}
\end{figure}
\Cref{fig:combined_3panel} presents the entire construction pipelineβraw data, CMP, GMPβin a single threeβpanel TikZ graphic, ensuring full reproducibility.
\begin{figure*}[!t]
\centering
\begin{tikzpicture}
% Panel 1: raw data scatter
\begin{axis}[
title={Raw Data},
xlabel={Index},
ylabel={Price (USD)},
ymin=2999.5, ymax=3011,
width=0.30\textwidth,
height=6cm,
name=raw
]
\addplot[only marks, mark=*, mark size=2pt, blue] coordinates {
(1,3000.914) (2,3003.837) (3,3002.432) (4,3009.892) (5,3007.698)
(6,3009.176) (7,3003.381) (8,3004.283) (9,3003.512) (10,3003.012)
};
\end{axis}
% Panel 2: CMP profile
\begin{axis}[
title={CMP Profile},
xbar,
xlabel={Stacks},
ylabel={},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=5,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=0.30\textwidth,
height=6cm,
enlarge y limits=0.05,
at={(raw.east)},
anchor=west,
xshift=1.2cm
]
\addplot[fill=orange!50, draw=black] coordinates {
(1,3000) (0,3001) (1,3002) (4,3003) (1,3004)
(0,3005) (0,3006) (1,3007) (0,3008) (2,3009)
};
\end{axis}
% Panel 3: GMP profile
\begin{axis}[
title={GMP Profile},
xbar,
xlabel={Stacks},
ylabel={},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=0, xmax=6,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=0.30\textwidth,
height=6cm,
enlarge y limits=0.05,
at={(raw.east)},
anchor=west,
xshift=6cm
]
\addplot[fill=green!40, draw=black] coordinates {
(1,3000) (1,3001) (2,3002) (5,3003) (3,3004)
(2,3005) (2,3006) (3,3007) (4,3008) (2,3009)
};
\end{axis}
\end{tikzpicture}
\caption{Threeβpanel overview: raw data (left), CMP (centre), and GMP (right). Gapβfilling produces a continuous profile without empty bins.}
\label{fig:combined_3panel}
\end{figure*}
\subsection{Up/DownβBin Footprint Table}\label{sec:updown_table}
Applying \Cref{alg:updown} yields the directional footprint in \Cref{tab:updown_table}. For instance, the move from A to B adds upβbins at bins~2--4; the move from C to D adds upβbins at bins~4--10.
\begin{table}[!t]
\centering
\caption{Up/DownβBin Footprint Table ($\beta=1$)}
\label{tab:updown_table}
\begin{tabular}{@{}cccccrr@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until} & \textbf{Group} & \textbf{Down} & \textbf{Up} & \textbf{Delta} \\
\midrule
1 & 3000 & 3001 & A & 0 & 0 & 0 \\
2 & 3001 & 3002 & A & 0 & 1 & +1 \\
3 & 3002 & 3003 & AC & 1 & 1 & 0 \\
4 & 3003 & 3004 & BCGIJ & 3 & 2 & -1 \\
5 & 3004 & 3005 & CFH & 1 & 2 & +1 \\
6 & 3005 & 3006 & CF & 1 & 1 & 0 \\
7 & 3006 & 3007 & CF & 1 & 1 & 0 \\
8 & 3007 & 3008 & CEF & 2 & 1 & -1 \\
9 & 3008 & 3009 & CDEF & 2 & 2 & 0 \\
10 & 3009 & 3010 & DF & 0 & 2 & +2 \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={Up/DownβBin Footprint},
xbar,
xlabel={Count (Down / Up)},
ylabel={Price (USD)},
ytick={3000,3001,...,3009},
yticklabel style={font=\scriptsize},
xmin=-3.5, xmax=3.5,
ymin=2999.5, ymax=3010,
bar width=4pt,
width=\columnwidth,
height=5cm,
enlarge y limits=0.05,
legend style={at={(0.5,-0.15)}, anchor=north, legend columns=2}
]
\addplot[fill=red!60, draw=black] coordinates {
(0,3000) (0,3001) (-1,3002) (-3,3003) (-1,3004)
(-1,3005) (-1,3006) (-2,3007) (-2,3008) (0,3009)
};
\addplot[fill=teal!60, draw=black] coordinates {
(0,3000) (1,3001) (1,3002) (2,3003) (2,3004)
(1,3005) (1,3006) (1,3007) (2,3008) (2,3009)
};
\legend{Down bins, Up bins}
\end{axis}
\end{tikzpicture}
\caption{Directional footprint: downβbins (red) and upβbins (teal).}
\label{fig:updown_footprint}
\end{figure}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VI. BINβSIZE ANALYSIS
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Effect of Bin Size on Profile Resolution}\label{sec:binsize}
The binβsize parameter $\beta$ controls granularity. For a single displacement $\Delta p = |p_i - p_{i-1}|$, the number of traversed bins is
\begin{equation}\label{eq:bins_beta}
K_i(\beta) \;=\;
\left|\left\lfloor \frac{p_i}{\beta} \right\rfloor
- \left\lfloor \frac{p_{i-1}}{\beta} \right\rfloor\right|
+ 1.
\end{equation}
Halving $\beta$ roughly doubles $K_i$.
\begin{proposition}[Binβcount scaling]\label{prop:scaling}
For fixed $\Delta p$ and $\beta_1 > \beta_2 > 0$,
\begin{equation}\label{eq:scaling}
K_i(\beta_2) \;\ge\;
\left\lfloor \frac{\beta_1}{\beta_2} \right\rfloor
\cdot \bigl(K_i(\beta_1) - 1\bigr) + 1.
\end{equation}
\end{proposition}
\begin{proof}
Write $\Delta p = (K_i(\beta_1)-1)\,\beta_1 + r_1$, $0 \le r_1 < \beta_1$. Then
$K_i(\beta_2) = \lfloor \Delta p/\beta_2 \rfloor + 1
\ge \lfloor (K_i(\beta_1)-1)\,\beta_1/\beta_2 \rfloor + 1
\ge \lfloor \beta_1/\beta_2 \rfloor\,(K_i(\beta_1)-1) + 1$.
\end{proof}
\Cref{tab:binsize} quantifies this for $\Delta p = 10$.
\begin{table}[!t]
\centering
\caption{Bin count vs.\ $\beta$ for $\Delta p = 10$}
\label{tab:binsize}
\begin{tabular}{@{}cccc@{}}
\toprule
$\beta$ & $K_i(\beta)$ & CMP bins & GMP bins filled \\
\midrule
2.0 & 6 & 2 & 6 \\
1.0 & 11 & 2 & 11 \\
0.5 & 21 & 2 & 21 \\
0.25 & 41 & 2 & 41 \\
0.1 & 101 & 2 & 101 \\
\bottomrule
\end{tabular}
\end{table}
Key observations:
\begin{itemize}
\item \textbf{CMP is invariant:} always 2 bins, regardless of $\beta$.
\item \textbf{GMP scales as $\mathcal{O}(\Delta p/\beta)$:} resolution improves inversely with $\beta$. The lower bound is the minimum meaningful price increment.
\end{itemize}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VII. ILLUSTRATIVE EXAMPLE
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Illustrative Example}\label{sec:example}
Two observations: $p_1 = 3000$, $p_2 = 3010$, $\beta=1$. \Cref{tab:cmp_vs_gmp} shows CMP (2 stacks) vs.\ GMP (11 stacks). \Cref{fig:profile} plots both.
\begin{table}[!t]
\centering
\caption{CMP vs.\ GMP ($\beta=1$)}
\label{tab:cmp_vs_gmp}
\begin{tabular}{@{}cccc@{}}
\toprule
Observation \# & Price & CMP stacks & GMP stacks \\
\midrule
1 & 3000 & 1 & 1 \\
0 & 3001 & 0 & 1 \\
0 & 3002 & 0 & 1 \\
0 & 3003 & 0 & 1 \\
0 & 3004 & 0 & 1 \\
0 & 3005 & 0 & 1 \\
0 & 3006 & 0 & 1 \\
0 & 3007 & 0 & 1 \\
0 & 3008 & 0 & 1 \\
0 & 3009 & 0 & 1 \\
2 & 3010 & 1 & 1 \\
\midrule
\multicolumn{2}{c}{\textbf{Total stacks}} & \textbf{2} & \textbf{11} \\
\bottomrule
\end{tabular}
\end{table}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VIII. DISCUSSION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Discussion}\label{sec:discussion}
\subsection{Advantages}
\begin{enumerate}
\item \textbf{No profile gaps.} All traversed price levels are represented, avoiding sparse CMP histograms.
\item \textbf{Volumeβneutral interpolation.} Interpolated stacks mark traversal, not fabricated volume.
\item \textbf{Directional context.} The footprint reveals net pressure without external orderβflow data.
\item \textbf{Tunable resolution.} $\beta$ adjusts granularity independently of data frequency.
\item \textbf{Universality.} GMP applies to any ordered price sequence.
\end{enumerate}
\subsection{Limitations}
\begin{enumerate}
\item \textbf{Interpolation assumption.} Assumes continuous traversal; genuine price gaps may be overβrepresented.
\item \textbf{Computational cost.} $\mathcal{O}(N+D)$ may be high for large cumulative displacement.
\item \textbf{Not a volume profile.} GMP is a pure priceβtraversal profile; combining with volume is future work.
\end{enumerate}
\subsection{Choosing $\beta$}
\begin{itemize}
\item Set $\beta$ near the minimum price increment for maximum resolution.
\item Enlarge $\beta$ to reduce noise or align with psychological levels.
\item The resolution advantage of GMP over CMP grows as $\beta$ decreases.
\end{itemize}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% IX. CONCLUSION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Conclusion}\label{sec:conclusion}
We have presented \textbf{GMP (GapβFilled Market Profile)}, a universal construction that interpolates all intermediate price bins between consecutive observations. We formalised CMP and GMP, provided algorithms with complexity analysis, and derived the inverse relationship between bin size $\beta$ and profile resolution. The detailed 10βpoint illustration and accompanying charts demonstrate that GMP yields a strictly denser and more informative profile, closing the gaps inherent in conventional methods. Future work may explore weighted interpolation and application across asset classes.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% REFERENCES
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\begin{thebibliography}{10}
\bibitem{steidlmayer1986market}
J.~Steidlmayer, \emph{Market Profile}, Chicago Board of Trade, 1986.
\bibitem{dalton2007markets}
J.~F.~Dalton, E.~T.~Jones, and R.~B.~Dalton, \emph{Markets in Profile: Profiting from the Auction Process}, John Wiley \& Sons, 2007.
\bibitem{clark1973subordinated}
P.~K.~Clark, ``A subordinated stochastic process model with finite variance for speculative prices,'' \emph{Econometrica}, vol.~41, no.~1, pp.~135--155, 1973.
\bibitem{ane2000order}
T.~An\'{e} and H.~Geman, ``Order flow, transaction clock, and normality of asset returns,'' \emph{The Journal of Finance}, vol.~55, no.~5, pp.~2259--2284, 2000.
\bibitem{glosten1985bid}
L.~R.~Glosten and P.~R.~Milgrom, ``Bid, ask and transaction prices in a specialist market with heterogeneously informed traders,'' \emph{Journal of Financial Economics}, vol.~14, no.~1, pp.~71--100, 1985.
\bibitem{ohara1995market}
M.~O'Hara, \emph{Market Microstructure Theory}, Blackwell, 1995.
\bibitem{madhavan2000market}
A.~Madhavan, ``Market microstructure: A survey,'' \emph{Journal of Financial Markets}, vol.~3, no.~3, pp.~205--258, 2000.
\end{thebibliography}
\end{document}
```
---
```alternative.tex
\documentclass[conference]{IEEEtran}
% ββ Packages ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\usepackage{cite}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{algorithmic}
\usepackage{algorithm}
\usepackage{graphicx}
\usepackage{textcomp}
\usepackage{booktabs}
\usepackage{multirow}
\usepackage{tikz}
\usepackage{pgfplots}
\pgfplotsset{compat=1.18}
\usepackage{hyperref}
\usepackage{cleveref}
% ββ Meta ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\hypersetup{
colorlinks=true,
linkcolor=blue,
citecolor=blue,
urlcolor=blue
}
\def\BibTeX{{\rm B\kern-.05em{\sc i\kern-.025em b}\kern-.08em
T\kern-.1667em\lower.7ex\hbox{E}\kern-.125emX}}
\begin{document}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% TITLE
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\title{mBA-GMP.\textit{v3}: Micro Bid-Ask Gap-Filled Market Profile\textsuperscript{*}}
\author{%
\href{https://github.com/ContinualQuasars}{\includegraphics[height=1.6ex]{ContinualQuasars_icon.png}}\ \textit{Continual Quasars, Research Team}\\%
February 20, 2026%
}
\maketitle
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% ABSTRACT
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\begin{abstract}
Conventional Market Profile (CMP) aggregates price activity into histogram
bins using candlestick-derived data (TOCHLV), discarding the intra-bar
microstructure and leaving price bins between consecutive trades empty. We
propose \textbf{mBA-GMP} (\textit{micro Bid-Ask Gap-filled Market Profile}),
a method that (i)~operates on raw, microsecond-resolution bid/ask
tick-formation data rather than pre-aggregated candlesticks, and
(ii)~interpolates every intermediate price bin traversed between successive
ticks, producing a \emph{gap-filled} profile. Building on this gap-filled
structure, we further introduce an \emph{Up/Down-Bin Footprint Profile} that
classifies each bin's contribution directionally, revealing the net upward
or downward pressure across the price traversal. We formalise CMP and
GMP with explicit algorithms, derive the relationship between bin-count and
a user-defined bin-size parameter~$\beta$, and introduce a \emph{dataframe
recording approach} that walks through a 10-datapoint XAUUSD example to
show how datapoints are grouped into price bins (the CMP dataframe),
how gap-filling transforms the sparse CMP output into a dense GMP
dataframe, and how directional footprints are assigned. We demonstrate via
generated charts and CSV data that mBA-GMP yields a strictly denser and
more informative distribution than CMP.
\end{abstract}
\begin{IEEEkeywords}
Market Profile, tick data, bid-ask spread, gap-filling interpolation,
high-frequency data, market microstructure, XAUUSD
\end{IEEEkeywords}
\vspace{0.5\baselineskip}
\hrule
\vspace{0.5\baselineskip}
{\footnotesize\noindent\textsuperscript{*}This research is conducted by the Continual Quasars Research Team at: {\color{blue}\href{https://github.com/ContinualQuasars}{github.com/ContinualQuasars}}\par}
\begin{figure}[!t]
\centering
\begin{tikzpicture}
\begin{axis}[
title={\textbf{CMP Profile}},
xbar,
xlabel={Stacks},
ylabel={Price (USD)},
ytick={3000,3001,...,3010},
yticklabel style={font=\scriptsize},
xmin=0, xmax=2,
ymin=2999.5, ymax=3010.5,
bar width=4pt,
width=0.42\columnwidth,
height=6.5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny},
name=cmp
]
\addplot[fill=gray!60, draw=black] coordinates {
(1,3000) (0,3001) (0,3002) (0,3003) (0,3004) (0,3005)
(0,3006) (0,3007) (0,3008) (0,3009) (1,3010)
};
\end{axis}
\begin{axis}[
title={\textbf{GMP Profile}},
xbar,
xlabel={Stacks},
ylabel={},
ytick={3000,3001,...,3010},
yticklabel style={font=\scriptsize},
xmin=0, xmax=2,
ymin=2999.5, ymax=3010.5,
bar width=4pt,
width=0.42\columnwidth,
height=6.5cm,
enlarge y limits=0.05,
nodes near coords,
nodes near coords style={font=\tiny},
at={(cmp.east)},
anchor=west,
xshift=1.2cm
]
\addplot[fill=blue!50, draw=black] coordinates {
(1,3000) (1,3001) (1,3002) (1,3003) (1,3004) (1,3005)
(1,3006) (1,3007) (1,3008) (1,3009) (1,3010)
};
\end{axis}
\end{tikzpicture}
\caption{Horizontal histogram comparison of CMP (left, grey) and GMP
(right, blue) for XAUUSD with $\beta=1$. CMP shows activity only at
the two observed prices; GMP fills all 11~traversed bins. The
gap-filling approach is most effective when applied to micro bid/ask
(mBA) raw tick-formation data.}
\label{fig:profile}
\end{figure}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% I. INTRODUCTION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Introduction}\label{sec:intro}
The Market Profile, introduced by Steidlmayer~\cite{steidlmayer1986market}
and later formalised by Dalton et~al.~\cite{dalton2007markets}, represents
price activity as a horizontal histogram whose bins correspond to discrete
price levels and whose bar lengths (``stacks'') reflect the amount of
activity observed at each level. In practice, most implementations
construct the profile from candlestick TOCHLV (time, open, close, high, low, volume) data: each candle
contributes one stack to every bin between its high and low.
This approach suffers from two shortcomings:
\begin{enumerate}
\item \textbf{Aggregation loss.}\;Candlesticks pre-aggregate raw ticks
into time-based bars chosen by the broker or exchange, irreversibly
discarding the sequence and microsecond timing of individual
bid/ask updates~\cite{engle2000econometrics,easley1992time}.
\item \textbf{Gap neglect.}\;When consecutive \emph{raw} ticks are
separated by several price levels, the conventional profile records
activity only at the two observed prices, ignoring the fact that price
must have traversed every intermediate level.
\end{enumerate}
We address both issues with \textbf{mBA-GMP}. The prefix \textit{mBA}
(micro Bid-Ask) specifies the data domain: raw, micro\-/millisecond-stamped
bid/ask tick-formation records---the smallest observable price changes.
The suffix \textit{GMP} (Gap-filled Market Profile) specifies the
construction rule: every price bin between two successive ticks receives an
interpolated stack, producing a profile with no gaps.
The remainder of this paper is organised as follows.
\Cref{sec:related} surveys related work.
\Cref{sec:prelim} establishes notation.
\Cref{sec:method} defines CMP and GMP formally, presents the mBA-GMP
algorithm, and introduces the Up/Down-Bin Footprint Profile.
\Cref{sec:dataframe} introduces the dataframe recording approach and
walks through a 10-datapoint worked example showing CMP, GMP, and footprint
construction step by step.
\Cref{sec:binsize} analyses the effect of bin-size on profile resolution.
\Cref{sec:example} provides an additional worked example with XAUUSD.
\Cref{sec:discussion} discusses practical implications, and
\Cref{sec:conclusion} concludes.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% II. RELATED WORK
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Related Work}\label{sec:related}
\subsection{Market Profile}
The Market Profile concept originates with Steidlmayer's observation that
price distributions at each level reveal where market participants find
``fair value''~\cite{steidlmayer1986market}. Dalton et~al.~\cite{dalton2007markets} extended the framework with auction-market
theory, using half-hour brackets as time-price opportunities (TPOs). Both
formulations rely on time-based bars rather than raw ticks.
\subsection{Tick-Level Analysis}
Clark~\cite{clark1973subordinated} demonstrated that subordinating returns
to trade-count time yields closer-to-Gaussian distributions, motivating
trade-indexed (rather than time-indexed) analysis.
An\'{e} and Geman~\cite{ane2000order} confirmed that business-time
transformations normalise returns at the tick level.
Engle~\cite{engle2000econometrics} introduced econometric models tailored
to ultra-high-frequency data.
\subsection{Market Microstructure}
The theoretical foundations of bid-ask price formation are laid out by
Glosten and Milgrom~\cite{glosten1985bid}, O'Hara~\cite{ohara1995market},
and the comprehensive survey of Madhavan~\cite{madhavan2000market}.
Hasbrouck~\cite{hasbrouck2007empirical} provides empirical methods for
tick-level inference. Bouchaud et~al.~\cite{bouchaud2018trades} present a
modern, physics-inspired treatment linking order flow to price dynamics.
A common thread across these works is that raw tick data preserves
information lost by any form of aggregation. Our contribution is to
combine this insight with a gap-filling interpolation rule applied to the
Market Profile histogram.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% III. PRELIMINARIES
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Preliminaries}\label{sec:prelim}
\Cref{tab:notation} summarises the notation used throughout.
\begin{table}[!t]
\centering
\caption{Notation Summary}
\label{tab:notation}
\begin{tabular}{@{}cl@{}}
\toprule
\textbf{Symbol} & \textbf{Description} \\
\midrule
$N$ & Total number of raw ticks in the dataset \\
$p_i$ & Price of the $i$-th tick, $i\in\{1,\dots,N\}$ \\
$\beta$ & Bin size (price units per bin); default $\beta=1$ \\
$b(p)$ & Bin index of price $p$: $b(p)=\lfloor p/\beta \rfloor$ \\
$S[k]$ & Stack count (profile value) at bin~$k$ \\
$\Delta_i$ & Price displacement: $\Delta_i = p_i - p_{i-1}$ \\
$K_i$ & Number of bins traversed from tick $i{-}1$ to $i$ \\
$U[k]$ & Up-bin count at bin $k$ \\
$D[k]$ & Down-bin count at bin $k$ \\
$\delta[k]$ & Net footprint delta at bin $k$: $\delta[k] = U[k] - D[k]$ \\
\bottomrule
\end{tabular}
\end{table}
\begin{definition}[Tick-formation]
A \emph{tick-formation} is the smallest observable change in the bid or
ask price as recorded by the broker. Formally, a tick stream is an
ordered sequence $\mathcal{T}=\{(t_i,\,p_i)\}_{i=1}^{N}$ where $t_i$
is the micro\-/millisecond timestamp and $p_i$ is the observed price.
\end{definition}
\begin{definition}[Bin]
Given bin size $\beta>0$, the \emph{bin} for price $p$ is the integer
index
\begin{equation}\label{eq:bin}
b(p) = \left\lfloor \frac{p}{\beta} \right\rfloor.
\end{equation}
All prices $p$ satisfying $k\beta \le p < (k+1)\beta$ map to bin~$k$.
\end{definition}
\begin{definition}[Market Profile]
A \emph{market profile} is a mapping $S:\mathbb{Z}\to\mathbb{N}_0$
where $S[k]$ counts the number of stacks accumulated at bin~$k$.
\end{definition}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% IV. METHODOLOGY
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Methodology}\label{sec:method}
\subsection{Conventional Market Profile (CMP)}\label{sec:cmp}
CMP records a stack only at the bin of each observed data point:
\begin{equation}\label{eq:cmp}
S_{\text{CMP}}[k] \;=\; \sum_{i=1}^{N} \mathbf{1}\!\bigl[b(p_i)=k\bigr],
\end{equation}
where $\mathbf{1}[\cdot]$ is the indicator function. Bins with no
observed tick receive $S_{\text{CMP}}[k]=0$.
\smallskip
\begin{algorithm}[!t]
\caption{CMP Construction}\label{alg:cmp}
\begin{algorithmic}[1]
\REQUIRE Tick stream $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile array $S_{\text{CMP}}[\cdot]$
\STATE Initialise $S_{\text{CMP}}[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 1$ \TO $N$}
\STATE $k \leftarrow \lfloor p_i / \beta \rfloor$
\STATE $S_{\text{CMP}}[k] \leftarrow S_{\text{CMP}}[k] + 1$
\ENDFOR
\RETURN $S_{\text{CMP}}$
\end{algorithmic}
\end{algorithm}
\textbf{Complexity.}\;CMP performs exactly $N$ bin-index computations and
$N$ increments, giving $\mathcal{O}(N)$ time complexity.
\subsection{Gap-Filled Market Profile (GMP)}\label{sec:gmp}
GMP augments CMP by filling every \emph{intermediate} bin between two
consecutive ticks. The construction proceeds in two phases:
\begin{enumerate}
\item \textbf{CMP placement.}\;Each tick~$p_i$ contributes one stack to
its own bin~$b(p_i)$, exactly as in CMP.
\item \textbf{Gap-filling.}\;For each consecutive pair
$(p_{i-1},\,p_i)$ with $i\ge 2$, every bin \emph{strictly between}
$b(p_{i-1})$ and $b(p_i)$ (exclusive of both endpoints) receives one
additional stack.
\end{enumerate}
\noindent Formally, writing $b_i = b(p_i)$:
\begin{equation}\label{eq:gmp}
S_{\text{GMP}}[k]
\;=\;
\underbrace{\sum_{i=1}^{N}\mathbf{1}\!\bigl[b_i=k\bigr]}_{S_{\text{CMP}}[k]}
\;+\;
\sum_{i=2}^{N}
\;\sum_{j=\min(b_{i-1},\,b_i)+1}^{\max(b_{i-1},\,b_i)-1}
\!\mathbf{1}\!\bigl[j=k\bigr].
\end{equation}
When $|b_i - b_{i-1}| \le 1$ (adjacent or same bin), the inner sum is
empty and no gap-filling occurs. When $|b_i - b_{i-1}| > 1$, the number
of gap-filled (intermediate) bins is
\begin{equation}\label{eq:Ki}
G_i \;=\; \bigl|b(p_i) - b(p_{i-1})\bigr| - 1.
\end{equation}
The total span of bins traversed, inclusive of both endpoints, is
$K_i = G_i + 2 = |b_i - b_{i-1}| + 1$.
\begin{algorithm}[!t]
\caption{GMP Construction (Two-Phase)}\label{alg:gmp}
\begin{algorithmic}[1]
\REQUIRE Tick stream $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile array $S_{\text{GMP}}[\cdot]$
\STATE Initialise $S_{\text{GMP}}[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 1$ \TO $N$} \COMMENT{Phase~1: CMP placement}
\STATE $S_{\text{GMP}}[\lfloor p_i/\beta \rfloor] \leftarrow
S_{\text{GMP}}[\lfloor p_i/\beta \rfloor] + 1$
\ENDFOR
\FOR{$i = 2$ \TO $N$} \COMMENT{Phase~2: gap-fill}
\STATE $k_{\text{from}} \leftarrow \lfloor p_{i-1}/\beta \rfloor$;
$k_{\text{to}} \leftarrow \lfloor p_i/\beta \rfloor$
\IF{$|k_{\text{to}} - k_{\text{from}}| > 1$}
\STATE $d \leftarrow \text{sign}(k_{\text{to}} - k_{\text{from}})$
\FOR{$k = k_{\text{from}} + d$ \TO $k_{\text{to}} - d$ \textbf{step} $d$}
\STATE $S_{\text{GMP}}[k] \leftarrow S_{\text{GMP}}[k] + 1$
\ENDFOR
\ENDIF
\ENDFOR
\RETURN $S_{\text{GMP}}$
\end{algorithmic}
\end{algorithm}
\textbf{Complexity.}\;Let
$D=\sum_{i=2}^{N}|b(p_i)-b(p_{i-1})|$ denote the cumulative bin
displacement. GMP performs $\mathcal{O}(N + D)$ operations. In the
degenerate case where all ticks share the same bin, $D=0$ and GMP reduces
to CMP. In the worst case, $D=\mathcal{O}(N\cdot\Delta p_{\max}/\beta)$.
\subsection{mBA-GMP: Applying GMP to Raw Tick Data}\label{sec:mba}
The key contribution of mBA-GMP is \emph{not} a novel interpolation rule
per~se, but rather the principled insistence that GMP must be applied to
raw bid/ask tick-formation data:
\begin{enumerate}
\item \textbf{Data source.}\;Use the broker's micro\-/millisecond
bid/ask feed---the lowest-granularity record available---rather than
any TOCHLV candlestick derivative.
\item \textbf{Trade indexing.}\;Index the $x$-axis by trade sequence
number, not by wall-clock time (cf.~\cite{clark1973subordinated,
ane2000order}).
\item \textbf{Gap filling.}\;Apply \Cref{alg:gmp} to the tick stream.
\end{enumerate}
\begin{algorithm}[!t]
\caption{mBA-GMP Pipeline}\label{alg:mba}
\begin{algorithmic}[1]
\REQUIRE Raw bid/ask tick feed $\mathcal{T}$, bin size $\beta$
\ENSURE Gap-filled profile $S_{\text{GMP}}[\cdot]$
\STATE Extract price sequence $\{p_i\}_{i=1}^{N}$ from $\mathcal{T}$,
indexed by trade count
\STATE $S_{\text{GMP}} \leftarrow \textsc{GMP}(\{p_i\},\,\beta)$
\COMMENT{Algorithm~\ref{alg:gmp}}
\RETURN $S_{\text{GMP}}$
\end{algorithmic}
\end{algorithm}
By operating on raw ticks, mBA-GMP avoids the aggregation artefacts
inherent in candlestick data~\cite{harris1990estimation} (e.g., arbitrary
bar boundaries, concealed intra-bar reversals) and ensures that every
micro-level price traversal is captured in the profile.
\subsection{Up/Down-Bin Footprint Profile}\label{sec:updown}
Building upon the gap-filled structure of GMP, we introduce a directional
classification layer termed the \emph{Up/Down-Bin Footprint Profile}.
Unlike order-flow bid/ask footprint charts which rely on volume traded at
the bid versus the ask, our footprint is derived purely from the GMP
transitive mechanics.
For every consecutive pair $(p_{i-1},\,p_i)$, the trajectory is evaluated
as an upward or downward movement based solely on the price difference.
The origin bin $b(p_{i-1})$ is assigned no directional credit relating
to this specific move (it has already been evaluated by prior action).
However, every subsequent bin along the traversed path up to and including
the destination bin $b(p_i)$ increments its \emph{up-bin} count $U[k]$ if $p_i > p_{i-1}$,
or its \emph{down-bin} count $D[k]$ if $p_i \le p_{i-1}$.
\begin{algorithm}[!t]
\caption{Up/Down-Bin Footprint Construction}\label{alg:updown}
\begin{algorithmic}[1]
\REQUIRE Tick stream $\{p_i\}_{i=1}^{N}$, bin size $\beta$
\ENSURE Profile arrays $U[\cdot], D[\cdot], \delta[\cdot]$
\STATE Initialise $U[k]\leftarrow 0, D[k]\leftarrow 0\;\;\forall\,k$
\FOR{$i = 2$ \TO $N$}
\STATE $k_{\text{from}} \leftarrow \lfloor p_{i-1}/\beta \rfloor$;
$k_{\text{to}} \leftarrow \lfloor p_i/\beta \rfloor$
\IF{$k_{\text{from}} = k_{\text{to}}$}
\IF{$p_i > p_{i-1}$}
\STATE $U[k_{\text{from}}] \leftarrow U[k_{\text{from}}] + 1$
\ELSE
\STATE $D[k_{\text{from}}] \leftarrow D[k_{\text{from}}] + 1$
\ENDIF
\STATE \textbf{continue}
\ENDIF
\STATE $\text{is\_up} \leftarrow (k_{\text{to}} > k_{\text{from}})$
\STATE $d \leftarrow \text{sign}(k_{\text{to}} - k_{\text{from}})$
\STATE $k \leftarrow k_{\text{from}} + d$
\WHILE{\textbf{true}}
\IF{$\text{is\_up}$}
\STATE $U[k] \leftarrow U[k] + 1$
\ELSE
\STATE $D[k] \leftarrow D[k] + 1$
\ENDIF
\IF{$k = k_{\text{to}}$}
\STATE \textbf{break}
\ENDIF
\STATE $k \leftarrow k + d$
\ENDWHILE
\ENDFOR
\FORALL{$k$}
\STATE $\delta[k] \leftarrow U[k] - D[k]$
\ENDFOR
\RETURN $U,\,D,\,\delta$
\end{algorithmic}
\end{algorithm}
This algorithm traces the same $\mathcal{O}(N+D)$ bins as the GMP phase,
maintaining computational efficiency while providing deep structural
insight into directional dominance across the price range.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% V. DATAFRAME RECORDING APPROACH
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Dataframe Recording Approach}\label{sec:dataframe}
To build practical intuition for how CMP and GMP profiles are constructed,
this section walks through a concrete 10-datapoint example using a
\emph{dataframe}-style representation. Each raw data record is a triple
$(\text{label},\;x,\;y)$ where \textit{label} is an alphabetic identifier,
$x$ is the trade index (or time), and $y$ is the observed price.
\Cref{tab:datapoints} lists the input data.
\begin{table}[!t]
\centering
\caption{Input Datapoints (XAUUSD Example, 10 Ticks)}
\label{tab:datapoints}
\begin{tabular}{@{}ccc@{}}
\toprule
\textbf{Datapoint} & \textbf{Trade \#} & \textbf{Price (USD)} \\
\midrule
A & 1 & 3000.914 \\
B & 2 & 3003.837 \\
C & 3 & 3002.432 \\
D & 4 & 3009.892 \\
E & 5 & 3007.698 \\
F & 6 & 3009.176 \\
G & 7 & 3003.381 \\
H & 8 & 3004.283 \\
I & 9 & 3003.512 \\
J & 10 & 3003.012 \\
\bottomrule
\end{tabular}
\end{table}
\Cref{fig:price_scatter} plots these datapoints as a price-vs-trade-index
scatter chart, illustrating the raw price path that both CMP and GMP
will profile.
\begin{figure}[!t]
\centering
\includegraphics[width=\columnwidth]{fig_price_scatter.png}
\caption{Price vs.\ trade index for the 10-datapoint XAUUSD example
(A--J). Each point represents one raw tick-formation record.}
\label{fig:price_scatter}
\end{figure}
\subsection{CMP Output Dataframe}\label{sec:df_cmp}
Using $\beta=1$, the bin index for each tick is $b(p)=\lfloor p\rfloor$.
CMP simply counts how many datapoints fall into each bin.
\Cref{tab:cmp_df} shows the resulting dataframe: bins are numbered~1
through~10 from the lowest observed price to the highest. The
\emph{datapoint group} column records which labels landed in each bin,
and \emph{stacks} is the group size.
\begin{table}[!t]
\centering
\caption{CMP Output Dataframe ($\beta=1$)}
\label{tab:cmp_df}
\begin{tabular}{@{}ccccc@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until}
& \textbf{Group} & \textbf{Stacks} \\
\midrule
1 & 3000 & 3001 & A & 1 \\
2 & 3001 & 3002 & & 0 \\
3 & 3002 & 3003 & C & 1 \\
4 & 3003 & 3004 & BGIJ & 4 \\
5 & 3004 & 3005 & H & 1 \\
6 & 3005 & 3006 & & 0 \\
7 & 3006 & 3007 & & 0 \\
8 & 3007 & 3008 & E & 1 \\
9 & 3008 & 3009 & & 0 \\
10 & 3009 & 3010 & DF & 2 \\
\midrule
\multicolumn{4}{c}{\textbf{Total stacks}} & \textbf{10} \\
\bottomrule
\end{tabular}
\end{table}
Note that bins~2, 6, 7, and~9 have zero stacks---these are the
\emph{gaps} in the CMP profile. The CMP histogram formed by the
\emph{datapoint group} column is exactly the $y$-distribution
histogram used by traditional Market Profile implementations.
\begin{figure}[!t]
\centering
\includegraphics[width=0.85\columnwidth]{fig_cmp_profile.png}
\caption{CMP profile for the 10-datapoint example ($\beta=1$).
Four bins (2,\,6,\,7,\,9) are empty, revealing gaps in price coverage.}
\label{fig:cmp_chart}
\end{figure}
\subsection{GMP Output Dataframe}\label{sec:df_gmp}
GMP augments the CMP result by filling every intermediate bin that price
must have traversed between consecutive datapoints. The gap-filling
convention is:
\begin{enumerate}
\item Each datapoint contributes one stack to its own bin (identical to
CMP).
\item For each consecutive pair $(i,\,i{+}1)$, every bin strictly
\emph{between} $b(p_i)$ and $b(p_{i+1})$ (exclusive of both
endpoints) receives one additional stack, labelled with the
source datapoint~$i$.
\end{enumerate}
\Cref{tab:gmp_df} shows the resulting GMP dataframe. All bins now have
at least one stack---no gaps remain.
\begin{table}[!t]
\centering
\caption{GMP Output Dataframe ($\beta=1$)}
\label{tab:gmp_df}
\begin{tabular}{@{}ccccc@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until}
& \textbf{Group} & \textbf{Stacks} \\
\midrule
1 & 3000 & 3001 & A & 1 \\
2 & 3001 & 3002 & A & 1 \\
3 & 3002 & 3003 & AC & 2 \\
4 & 3003 & 3004 & BCGIJ & 5 \\
5 & 3004 & 3005 & CFH & 3 \\
6 & 3005 & 3006 & CF & 2 \\
7 & 3006 & 3007 & CF & 2 \\
8 & 3007 & 3008 & CEF & 3 \\
9 & 3008 & 3009 & CDEF & 4 \\
10 & 3009 & 3010 & DF & 2 \\
\midrule
\multicolumn{4}{c}{\textbf{Total stacks}} & \textbf{25} \\
\bottomrule
\end{tabular}
\end{table}
\begin{figure}[!t]
\centering
\includegraphics[width=0.85\columnwidth]{fig_gmp_profile.png}
\caption{GMP profile for the 10-datapoint example ($\beta=1$).
Every bin is populated; the profile fully represents the price
range traversed by the market.}
\label{fig:gmp_chart}
\end{figure}
\subsection{CMP vs.\ GMP Side-by-Side}\label{sec:df_compare}
\Cref{fig:cmp_vs_gmp_10pt} places both profiles side by side. The
contrast is striking: CMP concentrates stacks at a handful of prices
(total~10~stacks), leaving 40\,\% of bins empty, while GMP distributes
25~stacks across all 10~bins, yielding a strictly denser and more
informative volume-at-price distribution.
\begin{figure}[!t]
\centering
\includegraphics[width=\columnwidth]{fig_cmp_vs_gmp.png}
\caption{Side-by-side comparison of CMP (left, orange) and GMP (right,
green) for the 10-datapoint XAUUSD example with $\beta=1$.}
\label{fig:cmp_vs_gmp_10pt}
\end{figure}
\Cref{fig:combined_3panel} presents the entire pipeline---from raw
datapoints, through CMP, to GMP---in a single three-panel view, with
every bar annotated by its constituent datapoint letters.
\begin{figure*}[!t]
\centering
\includegraphics[width=\textwidth]{fig_combined_3panel.png}
\caption{Three-panel overview: raw datapoints (left), CMP profile
with group letters (centre), and GMP profile with group letters
(right). Every bar is annotated with the alphabetic labels of the
datapoints it contains, making the gap-filling effect directly
visible. The gap-filling approach is most effective when applied to micro bid/ask
(mBA) raw tick-formation data.}
\label{fig:combined_3panel}
\end{figure*}
\begin{quote}
\textbf{Rendering note.}\;In the dataframe tables above, bin~1
(lowest price) appears at the \emph{top} of the table. On an actual
price chart, however, the lowest price is at the \emph{bottom} of the
$y$-axis and the highest price at the top---the profile histogram is
effectively ``flipped'' relative to the tabular representation.
\end{quote}
\subsection{Up/Down-Bin Footprint Dataframe}\label{sec:df_updown}
Applying \Cref{alg:updown} to the same 10-datapoint trajectory yields
the directional footprint dataframe shown in \Cref{tab:updown_df}.
For example, the move from A (3000.914) to B (3003.837) causes bins 2, 3, and 4
to receive $+1$ up-bin point. The movement from C (3002.432) to D (3009.892)
applies up-bin points to bins 4 through 10. Downward movements, such as
B down to C, or D down to E, function symmetrically. Note that
the very first datapoint (A) does not carry directional value as there is
no precedent movement. Price movement within the same bin is correctly
assigned its respective directional label.
\begin{table}[!t]
\centering
\caption{Up/Down-Bin Footprint Output Dataframe ($\beta=1$)}
\label{tab:updown_df}
\begin{tabular}{@{}cccccrr@{}}
\toprule
\textbf{Bin} & \textbf{From} & \textbf{Until}
& \textbf{Group} & \textbf{Down} & \textbf{Up} & \textbf{Delta} \\
\midrule
1 & 3000 & 3001 & A & 0 & 0 & 0 \\
2 & 3001 & 3002 & A & 0 & 1 & +1 \\
3 & 3002 & 3003 & AC & 1 & 1 & 0 \\
4 & 3003 & 3004 & BCGIJ & 3 & 2 & -1 \\
5 & 3004 & 3005 & CFH & 1 & 2 & +1 \\
6 & 3005 & 3006 & CF & 1 & 1 & 0 \\
7 & 3006 & 3007 & CF & 1 & 1 & 0 \\
8 & 3007 & 3008 & CEF & 2 & 1 & -1 \\
9 & 3008 & 3009 & CDEF & 2 & 2 & 0 \\
10 & 3009 & 3010 & DF & 0 & 2 & +2 \\
\bottomrule
\end{tabular}
\end{table}
\Cref{fig:updown_footprint} visualises this footprint as a dual-axis
histogram. Each bin possesses opposing horizontal stacks indicating the
total amount of upward versus downward crossing, exposing the directional bias
driving the profile gap-fills.
\begin{figure}[!t]
\centering
\includegraphics[width=\columnwidth]{fig_updown_footprint.png}
\caption{Up/Down-Bin Footprint Profile for the 10-datapoint example.
Red bars (left) signify down-bin gap-fills; teal bars (right) signify
up-bin gap-fills. Delta values $\delta[k]$ denote net directional
pressure at each price bin.}
\label{fig:updown_footprint}
\end{figure}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VI. BIN-SIZE ANALYSIS
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Effect of Bin Size on Profile Resolution}\label{sec:binsize}
The bin-size parameter $\beta$ controls the granularity of the profile.
For two consecutive ticks at prices $p_{i-1}$ and $p_i$, the total number
of bins traversed (inclusive of both endpoints) is
\begin{equation}\label{eq:bins_beta}
K_i(\beta) \;=\;
\left|\left\lfloor \frac{p_i}{\beta} \right\rfloor
- \left\lfloor \frac{p_{i-1}}{\beta} \right\rfloor\right|
+ 1.
\end{equation}
\noindent Halving $\beta$ approximately doubles the number of interpolated
bins, while doubling $\beta$ approximately halves it.
\begin{proposition}[Bin-count scaling]\label{prop:scaling}
For a fixed price displacement $\Delta p = |p_i - p_{i-1}|$ and bin
sizes $\beta_1 > \beta_2 > 0$, the bin counts satisfy
\begin{equation}\label{eq:scaling}
K_i(\beta_2) \;\ge\;
\left\lfloor \frac{\beta_1}{\beta_2} \right\rfloor
\cdot \bigl(K_i(\beta_1) - 1\bigr) + 1.
\end{equation}
\end{proposition}
\begin{proof}
Write $\Delta p = (K_i(\beta_1)-1)\,\beta_1 + r_1$ where
$0 \le r_1 < \beta_1$. Then
$K_i(\beta_2) = \lfloor \Delta p / \beta_2 \rfloor + 1
\ge \lfloor (K_i(\beta_1)-1)\,\beta_1 / \beta_2 \rfloor + 1
\ge \lfloor \beta_1/\beta_2 \rfloor\,(K_i(\beta_1)-1) + 1$.
\end{proof}
\Cref{tab:binsize} illustrates how varying $\beta$ changes the GMP
resolution for the XAUUSD example where price moves from \$3{,}000 to
\$3{,}010 ($\Delta p = 10$).
\begin{table}[!t]
\centering
\caption{Effect of Bin Size ($\beta$) on GMP Bin Count for $\Delta p = 10$}
\label{tab:binsize}
\begin{tabular}{@{}cccc@{}}
\toprule
$\beta$ (USD) & $K_i(\beta)$ & CMP bins & GMP bins filled \\
\midrule
2.0 & 6 & 2 & 6 \\
1.0 & 11 & 2 & 11 \\
0.5 & 21 & 2 & 21 \\
0.25 & 41 & 2 & 41 \\
0.1 & 101 & 2 & 101 \\
\bottomrule
\end{tabular}
\end{table}
\noindent
Two key observations follow:
\begin{itemize}
\item \textbf{CMP is invariant to~$\beta$ in bin count:} regardless
of~$\beta$, CMP always fills exactly~2 bins (one per observed tick),
because no intermediate bins are populated.
\item \textbf{GMP scales as~$\mathcal{O}(\Delta p\,/\,\beta)$:}
the filled bin count grows inversely with~$\beta$, producing a
progressively finer-grained profile. Setting $\beta$~below the
instrument's tick size yields redundant empty bins, so the practical
lower bound is $\beta \ge \text{tick\_size}$.
\end{itemize}
\Cref{tab:binsize_half} presents the full GMP profile comparison for
$\beta=1$ versus $\beta=0.5$.
\begin{table}[!t]
\centering
\caption{GMP Profile: $\beta=1$ vs.\ $\beta=0.5$ (Price from \$3{,}000 to \$3{,}010)}
\label{tab:binsize_half}
\begin{tabular}{@{}cccc@{}}
\toprule
Price (USD) & CMP & GMP ($\beta\!=\!1$) & GMP ($\beta\!=\!0.5$) \\
\midrule
3000.0 & 1 & 1 & 1 \\
3000.5 & 0 & & 1 \\
3001.0 & 0 & 1 & 1 \\
3001.5 & 0 & & 1 \\
3002.0 & 0 & 1 & 1 \\
3002.5 & 0 & & 1 \\
3003.0 & 0 & 1 & 1 \\
3003.5 & 0 & & 1 \\
3004.0 & 0 & 1 & 1 \\
3004.5 & 0 & & 1 \\
3005.0 & 0 & 1 & 1 \\
3005.5 & 0 & & 1 \\
3006.0 & 0 & 1 & 1 \\
3006.5 & 0 & & 1 \\
3007.0 & 0 & 1 & 1 \\
3007.5 & 0 & & 1 \\
3008.0 & 0 & 1 & 1 \\
3008.5 & 0 & & 1 \\
3009.0 & 0 & 1 & 1 \\
3009.5 & 0 & & 1 \\
3010.0 & 1 & 1 & 1 \\
\midrule
\textbf{Total bins} & \textbf{2} & \textbf{11} & \textbf{21} \\
\bottomrule
\end{tabular}
\end{table}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VII. ILLUSTRATIVE EXAMPLE
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Illustrative Example}\label{sec:example}
Consider two raw XAUUSD ticks with $\beta=1$:
\begin{itemize}
\item Tick~1: trade at $p_1 = \$3{,}000$.
\item Tick~2: trade at $p_2 = \$3{,}010$.
\end{itemize}
\Cref{tab:cmp_vs_gmp} shows the resulting profiles side-by-side.
\begin{table}[!t]
\centering
\caption{CMP vs.\ GMP Comparison ($\beta=1$, XAUUSD)}
\label{tab:cmp_vs_gmp}
\begin{tabular}{@{}cccc@{}}
\toprule
Trade \# & Price (USD) & CMP stacks & GMP stacks \\
\midrule
1 & 3000 & 1 & 1 \\
0 & 3001 & 0 & 1 \\
0 & 3002 & 0 & 1 \\
0 & 3003 & 0 & 1 \\
0 & 3004 & 0 & 1 \\
0 & 3005 & 0 & 1 \\
0 & 3006 & 0 & 1 \\
0 & 3007 & 0 & 1 \\
0 & 3008 & 0 & 1 \\
0 & 3009 & 0 & 1 \\
2 & 3010 & 1 & 1 \\
\midrule
\multicolumn{2}{c}{\textbf{Total stacks}} & \textbf{2} & \textbf{11} \\
\bottomrule
\end{tabular}
\end{table}
CMP records only 2~stacks at the observed prices; GMP records
11~stacks spanning the full traversal. \Cref{fig:profile} visualises
both profiles as horizontal histograms.
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% VIII. DISCUSSION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Discussion}\label{sec:discussion}
\subsection{Advantages}
\begin{enumerate}
\item \textbf{Maximal resolution.}\;By operating on raw bid/ask ticks,
mBA-GMP captures every price movement the broker records---no
information is pre-aggregated or discarded.
\item \textbf{No profile gaps.}\;Gap-filling ensures that every price
level traversed by the market is represented, preventing the sparse,
misleading histograms produced by CMP on fast-moving ticks.
\item \textbf{Volume-neutral interpolation.}\;Interpolated bins receive
exactly one stack each, reflecting a traversal rather than fabricating
volume. This preserves the interpretive semantics of the profile:
high-stack regions still correspond to genuine price acceptance.
\item \textbf{Directional Context.}\;By classifying gap-filled stacks into
up/down bins, the resultant footprint profile reveals net directional
pressure across the evaluated interval, independent of conventional
bid/ask volume mechanics.
\item \textbf{Tunable resolution via~$\beta$.}\;The bin-size parameter
allows practitioners to control profile granularity without altering
the underlying data, unlike candlestick-based approaches where
resolution is fixed by the bar period.
\end{enumerate}
\subsection{Limitations}
\begin{enumerate}
\item \textbf{Data availability.}\;Not all brokers expose raw
micro\-/millisecond tick feeds. Where only TOCHLV data is available,
GMP can still be applied to candlestick prices, but the
``mBA'' guarantee is lost.
\item \textbf{Computational cost.}\;The $\mathcal{O}(N + D)$ complexity
implies that highly volatile instruments with large cumulative
displacement~$D$ will require proportionally more computation. For
modern hardware this is rarely a practical bottleneck, but
memory-constrained environments may require streaming or windowed
implementations.
\item \textbf{Interpolation assumption.}\;Gap-filling assumes that price
continuously traverses every intermediate level. In instruments with
genuine price gaps (e.g., exchange-traded equities at market open),
this assumption may over-represent bins that were never actually
available for trading.
\end{enumerate}
\subsection{Practical Guidance on Choosing $\beta$}
\begin{itemize}
\item Set $\beta$ near to the instrument's minimum tick size for maximum
resolution (e.g., $\beta = 0.01$ for XAUUSD's 0.001 lowest tick, on many brokers).
\item Increase $\beta$ to reduce noise in low-liquidity regimes or to
align bins with round-number psychological levels.
\item As shown in \Cref{sec:binsize}, CMP bin count is invariant
to~$\beta$; thus, the resolution advantage of GMP grows as $\beta$
decreases.
\end{itemize}
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% IX. CONCLUSION
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\section{Conclusion}\label{sec:conclusion}
We have presented \textbf{mBA-GMP}, a market-profile construction method
that combines two principles: (i)~sourcing data from raw micro\-/millisecond
bid/ask tick-formation records rather than pre-aggregated candlesticks,
and (ii)~interpolating all intermediate price bins between consecutive
ticks. We formalised both Conventional Market Profile (CMP) and
Gap-filled Market Profile (GMP), provided pseudocode algorithms with
complexity analysis, and demonstrated that the bin-size parameter~$\beta$
controls profile resolution with a simple inverse relationship.
The dataframe recording approach (\Cref{sec:dataframe}) showed concretely
how 10~raw datapoints map to CMP bins with gaps, how gap-filling
produces a GMP dataframe in which every price bin is populated, and how
these intermediate bins are classified into directional up/down stacks
to yield a structural footprint. The accompanying charts and tabulated
outputs make the method reproducible and directly applicable to real-world
tick streams.
Future directions include extending the gap-filling convention to
weighted interpolation (where intermediate bins receive fractional stacks
proportional to their traversal speed) and evaluating mBA-GMP on
live order-book data across multiple asset classes.
\newpage
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
% REFERENCES
% ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
\bibliographystyle{IEEEtran}
\bibliography{references}
\end{document}
```
```generate_profiles.py
#!/usr/bin/env python3
"""
generate_profiles.py β mBA-GMP.v3 Dataframe & Chart Generator
==============================================================
Produces CSV files and publication-quality PNG charts demonstrating the
Conventional Market Profile (CMP), Gap-filled Market Profile (GMP),
and Up/Down-Bin Footprint Profile using a 10-datapoint XAUUSD example.
Outputs:
CSV: datapoints.csv, cmp_profile.csv, gmp_profile.csv,
updown_profile.csv
PNG: fig_price_scatter.png, fig_cmp_profile.png,
fig_gmp_profile.png, fig_cmp_vs_gmp.png,
fig_updown_footprint.png
"""
import math
import csv
import os
# ββ Try to import optional plotting libs βββββββββββββββββββββββββββββββββββββ
try:
import matplotlib
matplotlib.use("Agg") # non-interactive backend
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
HAS_MPL = True
except ImportError:
HAS_MPL = False
print("[WARN] matplotlib not found β CSV files will still be generated "
"but PNG charts will be skipped.")
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 1. RAW DATAPOINTS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
DATAPOINTS = [
("A", 1, 3000.914),
("B", 2, 3003.837),
("C", 3, 3002.432),
("D", 4, 3009.892),
("E", 5, 3007.698),
("F", 6, 3009.176),
("G", 7, 3003.381),
("H", 8, 3004.283),
("I", 9, 3003.512),
("J", 10, 3003.012),
]
BIN_SIZE = 1 # Ξ² = 1 symbol price unit
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 2. HELPER FUNCTIONS
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def bin_index(price: float, beta: float = BIN_SIZE) -> int:
"""Return the bin index for a given price: floor(price / Ξ²)."""
return int(math.floor(price / beta))
def bin_range(price: float, beta: float = BIN_SIZE):
"""Return (price_from, price_until) for the bin containing *price*."""
b = bin_index(price, beta)
return b * beta, (b + 1) * beta
def make_bin_key(b: int, beta: float = BIN_SIZE):
"""Return (bin_number_1based, price_from, price_until) for bin index *b*."""
return (b * beta, (b + 1) * beta)
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 3. CMP CONSTRUCTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def build_cmp(datapoints, beta=BIN_SIZE):
"""
Build CMP profile.
Returns dict: bin_index -> {"labels": [str], "count": int}
"""
profile = {}
for label, _trade, price in datapoints:
b = bin_index(price, beta)
if b not in profile:
profile[b] = {"labels": [], "count": 0}
profile[b]["labels"].append(label)
profile[b]["count"] += 1
return profile
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 4. GMP CONSTRUCTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def build_gmp(datapoints, beta=BIN_SIZE):
"""
Build GMP profile (gap-filled).
Convention (matches the dataframe approach):
1. Every datapoint fills its OWN bin with its own label (same as CMP).
2. For each consecutive pair (i, i+1), the intermediate bins BETWEEN
b(p_i) and b(p_{i+1}) β exclusive of both endpoints β are filled
with the SOURCE datapoint's label (datapoint i).
Returns dict: bin_index -> {"labels": [str], "count": int}
"""
profile = {}
def add_to_bin(b, label):
if b not in profile:
profile[b] = {"labels": [], "count": 0}
profile[b]["labels"].append(label)
profile[b]["count"] += 1
# ββ Step 1: CMP-style placement β each datapoint fills its own bin ββ
for label, _trade, price in datapoints:
add_to_bin(bin_index(price, beta), label)
# ββ Step 2: Gap-fill intermediate bins between consecutive pairs βββββ
for idx in range(len(datapoints) - 1):
src_label, _, src_price = datapoints[idx]
_dst_label, _, dst_price = datapoints[idx + 1]
b_from = bin_index(src_price, beta)
b_to = bin_index(dst_price, beta)
if abs(b_to - b_from) <= 1:
# Adjacent or same bin β no intermediate bins to fill
continue
direction = 1 if b_to > b_from else -1
# Fill bins strictly BETWEEN b_from and b_to (exclusive of both)
b = b_from + direction
while b != b_to:
add_to_bin(b, src_label)
b += direction
return profile
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 4b. UP/DOWN-BIN FOOTPRINT PROFILE CONSTRUCTION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def build_updown_profile(datapoints, beta=BIN_SIZE):
"""
Build the Up/Down-Bin Footprint Profile.
For each consecutive pair of datapoints, every bin on the gap-filled
path (excluding the source datapoint's own bin) is classified as an
up-bin or down-bin depending on the direction of the move.
The first datapoint (no prior movement) receives 0 up / 0 down.
Returns dict: bin_index -> {"labels": [str], "up": int, "down": int}
"""
# ββ Collect GMP group labels (reuse from GMP logic) ββββββββββββββββββ
groups = {} # bin_index -> list of labels
def add_label(b, label):
if b not in groups:
groups[b] = []
groups[b].append(label)
# CMP placement
for label, _trade, price in datapoints:
add_label(bin_index(price, beta), label)
# Gap-fill intermediate labels
for idx in range(len(datapoints) - 1):
src_label, _, src_price = datapoints[idx]
_, _, dst_price = datapoints[idx + 1]
b_from = bin_index(src_price, beta)
b_to = bin_index(dst_price, beta)
if abs(b_to - b_from) <= 1:
continue
direction = 1 if b_to > b_from else -1
b = b_from + direction
while b != b_to:
add_label(b, src_label)
b += direction
# ββ Now compute up/down counts per bin ββββββββββββββββββββββββββββββββ
up_counts = {} # bin_index -> int
down_counts = {} # bin_index -> int
for idx in range(len(datapoints) - 1):
_, _, src_price = datapoints[idx]
_, _, dst_price = datapoints[idx + 1]
b_from = bin_index(src_price, beta)
b_to = bin_index(dst_price, beta)
if b_from == b_to:
# Same bin, but price might have moved
if dst_price > src_price:
up_counts[b_from] = up_counts.get(b_from, 0) + 1
elif dst_price < src_price:
down_counts[b_from] = down_counts.get(b_from, 0) + 1
continue
is_up = b_to > b_from
direction = 1 if is_up else -1
# Every bin on the path AFTER the source bin (exclusive of source,
# inclusive of destination) gets a directional count.
b = b_from + direction
while True:
if is_up:
up_counts[b] = up_counts.get(b, 0) + 1
else:
down_counts[b] = down_counts.get(b, 0) + 1
if b == b_to:
break
b += direction
# ββ Merge into result dict βββββββββββββββββββββββββββββββββββββββββββ
all_bins = set(groups.keys()) | set(up_counts.keys()) | set(down_counts.keys())
profile = {}
for b in all_bins:
profile[b] = {
"labels": sorted(groups.get(b, [])),
"up": up_counts.get(b, 0),
"down": down_counts.get(b, 0),
}
return profile
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 5. CSV OUTPUT
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def write_datapoints_csv(datapoints, path="datapoints.csv"):
"""Write the raw datapoints to CSV."""
with open(path, "w", newline="") as f:
w = csv.writer(f)
w.writerow(["datapoint", "x-axis trades (raw trades or time)", "y-axis Price"])
for label, trade, price in datapoints:
w.writerow([label, trade, f"{price:.3f}"])
print(f"[OK] {path}")
def write_profile_csv(profile, beta, path):
"""Write a profile (CMP or GMP) to CSV, bins numbered 1..N from lowest."""
if not profile:
print(f"[WARN] Empty profile, skipping {path}")
return
b_min = min(profile.keys())
b_max = max(profile.keys())
# Include ALL bins from b_min to b_max (even empty ones)
rows = []
bin_number = 1
for b in range(b_min, b_max + 1):
p_from = b * beta
p_until = (b + 1) * beta
info = profile.get(b, {"labels": [], "count": 0})
group = "".join(sorted(info["labels"]))
count = info["count"]
rows.append([bin_number, int(p_from), int(p_until), group, count])
bin_number += 1
with open(path, "w", newline="") as f:
w = csv.writer(f)
w.writerow([
f"bin (with binsize = {beta} symbol's price unit)",
"price from", "price until", "datapoint group",
"number of profile's stacks"
])
for row in rows:
w.writerow(row)
print(f"[OK] {path}")
def write_updown_profile_csv(updown_profile, gmp_groups, beta, path):
"""Write the Up/Down-Bin Footprint Profile to CSV."""
if not updown_profile:
print(f"[WARN] Empty profile, skipping {path}")
return
b_min = min(updown_profile.keys())
b_max = max(updown_profile.keys())
rows = []
bin_number = 1
for b in range(b_min, b_max + 1):
p_from = b * beta
p_until = (b + 1) * beta
info = updown_profile.get(b, {"labels": [], "up": 0, "down": 0})
group = "".join(info["labels"])
up_val = info["up"]
down_val = info["down"]
delta_val = up_val - down_val
rows.append([bin_number, int(p_from), int(p_until), group,
down_val, up_val, delta_val])
bin_number += 1
with open(path, "w", newline="") as f:
w = csv.writer(f)
w.writerow([
f"bin (with binsize = {beta} symbol's price unit)",
"price from", "price until", "datapoint group",
"down-bin profile's stacks", "up-bin profile's stacks",
"delta-bin profile's stacks"
])
for row in rows:
w.writerow(row)
print(f"[OK] {path}")
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 6. CHART GENERATION
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# ββ Color palette (white / light theme) ββββββββββββββββββββββββββββββββββββββ
CLR_BG = "#ffffff"
CLR_FG = "#1a1a1a"
CLR_GRID = "#d0d0d0"
CLR_ACCENT1 = "#1565c0" # deep blue (scatter)
CLR_ACCENT2 = "#e65100" # deep orange (CMP)
CLR_ACCENT3 = "#2e7d32" # deep green (GMP)
CLR_MUTED = "#607d8b"
CLR_LABEL = "#333333" # label text
CHART_DPI = 300
def _apply_style(ax, title=""):
"""Apply a consistent white/light theme to an axes object."""
ax.set_facecolor(CLR_BG)
ax.figure.set_facecolor(CLR_BG)
ax.tick_params(colors=CLR_FG, labelsize=8)
ax.xaxis.label.set_color(CLR_FG)
ax.yaxis.label.set_color(CLR_FG)
ax.title.set_color(CLR_FG)
for spine in ax.spines.values():
spine.set_color(CLR_GRID)
ax.grid(True, color=CLR_GRID, linewidth=0.5, alpha=0.4)
if title:
ax.set_title(title, fontsize=11, fontweight="bold", pad=10)
def chart_price_scatter(datapoints, path="fig_price_scatter.png", ax=None):
"""Scatter + line plot of price vs trade index, labeled AβJ."""
labels = [d[0] for d in datapoints]
trades = [d[1] for d in datapoints]
prices = [d[2] for d in datapoints]
standalone = ax is None
if standalone:
fig, ax = plt.subplots(figsize=(7, 4))
_apply_style(ax, "Price vs. Trade Index (Datapoints AβJ)")
ax.plot(trades, prices, color=CLR_ACCENT1, linewidth=1.2, alpha=0.45,
zorder=1)
ax.scatter(trades, prices, color=CLR_ACCENT1, s=52, zorder=2,
edgecolors="white", linewidths=0.6)
for lbl, x, y in zip(labels, trades, prices):
ax.annotate(lbl, (x, y), textcoords="offset points",
xytext=(0, 10), ha="center", fontsize=8,
fontweight="bold", color=CLR_LABEL)
ax.set_xlabel("Trade Index (raw trades)", fontsize=9)
ax.set_ylabel("Price (USD)", fontsize=9)
ax.yaxis.set_major_formatter(ticker.FormatStrFormatter("%.0f"))
if standalone:
fig.tight_layout()
fig.savefig(path, dpi=CHART_DPI, bbox_inches="tight")
plt.close(fig)
print(f"[OK] {path}")
def _draw_profile(ax, profile, beta, title, bar_color):
"""Draw a horizontal bar chart for a profile onto *ax*."""
b_min = min(profile.keys())
b_max = max(profile.keys())
bin_labels = []
stacks = []
groups = []
for b in range(b_min, b_max + 1):
p_from = b * beta
p_until = (b + 1) * beta
bin_labels.append(f"{int(p_from)}β{int(p_until)}")
info = profile.get(b, {"labels": [], "count": 0})
stacks.append(info["count"])
groups.append("".join(sorted(info["labels"])))
y_pos = range(len(bin_labels))
bars = ax.barh(y_pos, stacks, color=bar_color, edgecolor="white",
linewidth=0.5, height=0.7, alpha=0.85)
ax.set_yticks(y_pos)
ax.set_yticklabels(bin_labels, fontsize=7)
ax.set_xlabel("Stacks", fontsize=9)
ax.set_ylabel("Price Bin (USD)", fontsize=9)
# Annotate bars with datapoint group letters
max_s = max(stacks) if stacks else 1
for i, (bar, grp) in enumerate(zip(bars, groups)):
if grp:
ax.text(bar.get_width() + 0.12, bar.get_y() + bar.get_height() / 2,
grp, va="center", ha="left", fontsize=7, color=CLR_LABEL,
fontweight="bold")
ax.set_xlim(0, max_s + 2)
_apply_style(ax, title)
def chart_profile(profile, beta, path, title, bar_color):
"""Standalone horizontal bar chart for a single profile (CMP or GMP)."""
if not profile:
return
fig, ax = plt.subplots(figsize=(6, 5))
_draw_profile(ax, profile, beta, title, bar_color)
fig.tight_layout()
fig.savefig(path, dpi=CHART_DPI, bbox_inches="tight")
plt.close(fig)
print(f"[OK] {path}")
def chart_cmp_vs_gmp(cmp_profile, gmp_profile, beta,
path="fig_cmp_vs_gmp.png"):
"""Side-by-side comparison of CMP and GMP profiles (2-panel)."""
if not cmp_profile or not gmp_profile:
return
fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(11, 5), sharey=True)
_draw_profile(ax1, cmp_profile, beta, "CMP Profile", CLR_ACCENT2)
_draw_profile(ax2, gmp_profile, beta, "GMP Profile", CLR_ACCENT3)
ax2.set_ylabel("") # avoid duplicate y-label
fig.suptitle("CMP vs. GMP β 10-Datapoint Example (Ξ² = 1)",
fontsize=13, fontweight="bold", color=CLR_FG, y=1.01)
fig.tight_layout()
fig.savefig(path, dpi=CHART_DPI, bbox_inches="tight")
plt.close(fig)
print(f"[OK] {path}")
def chart_combined_3panel(datapoints, cmp_profile, gmp_profile, beta,
path="fig_combined_3panel.png"):
"""Three-panel chart: Datapoints | CMP with letters | GMP with letters."""
if not cmp_profile or not gmp_profile:
return
fig, (ax1, ax2, ax3) = plt.subplots(1, 3, figsize=(16, 5.5),
gridspec_kw={"width_ratios": [1.1, 1, 1]})
# ββ Panel 1: Datapoints scatter with labels ββββββββββββββββββββββββββ
labels = [d[0] for d in datapoints]
trades = [d[1] for d in datapoints]
prices = [d[2] for d in datapoints]
_apply_style(ax1, "Datapoints (AβJ)")
ax1.plot(trades, prices, color=CLR_ACCENT1, linewidth=1.2, alpha=0.4,
zorder=1)
ax1.scatter(trades, prices, color=CLR_ACCENT1, s=52, zorder=2,
edgecolors="white", linewidths=0.6)
for lbl, x, y in zip(labels, trades, prices):
ax1.annotate(lbl, (x, y), textcoords="offset points",
xytext=(0, 10), ha="center", fontsize=9,
fontweight="bold", color=CLR_LABEL)
ax1.set_xlabel("Trade Index", fontsize=9)
ax1.set_ylabel("Price (USD)", fontsize=9)
ax1.yaxis.set_major_formatter(ticker.FormatStrFormatter("%.0f"))
# ββ Panel 2: CMP with group letters ββββββββββββββββββββββββββββββββββ
_draw_profile(ax2, cmp_profile, beta, "CMP with Letters", CLR_ACCENT2)
# ββ Panel 3: GMP with group letters ββββββββββββββββββββββββββββββββββ
_draw_profile(ax3, gmp_profile, beta, "GMP with Letters", CLR_ACCENT3)
ax3.set_ylabel("") # avoid duplicate y-label
fig.suptitle("Datapoints β CMP β GMP (Ξ² = 1)",
fontsize=14, fontweight="bold", color=CLR_FG, y=1.02)
fig.tight_layout()
fig.savefig(path, dpi=CHART_DPI, bbox_inches="tight")
plt.close(fig)
print(f"[OK] {path}")
def chart_updown_footprint(updown_profile, beta,
path="fig_updown_footprint.png"):
"""Dual horizontal bar chart: down-bins (left/red) vs up-bins (right/teal)."""
if not updown_profile:
return
CLR_UP = "#00897b" # teal
CLR_DOWN = "#e53935" # red
b_min = min(updown_profile.keys())
b_max = max(updown_profile.keys())
bin_labels = []
up_vals = []
down_vals = []
delta_vals = []
for b in range(b_min, b_max + 1):
p_from = b * beta
p_until = (b + 1) * beta
bin_labels.append(f"{int(p_from)}-{int(p_until)}")
info = updown_profile.get(b, {"labels": [], "up": 0, "down": 0})
up_vals.append(info["up"])
down_vals.append(info["down"])
delta_vals.append(info["up"] - info["down"])
y_pos = list(range(len(bin_labels)))
max_val = max(max(up_vals, default=1), max(down_vals, default=1), 1)
fig, ax = plt.subplots(figsize=(8, 5.5))
_apply_style(ax, "Up/Down-Bin Footprint Profile (GMP-based)")
# Down bars extend to the LEFT (negative x)
bars_down = ax.barh(y_pos, [-d for d in down_vals], color=CLR_DOWN,
edgecolor="white", linewidth=0.5, height=0.65,
alpha=0.85, label="Down-bin")
# Up bars extend to the RIGHT (positive x)
bars_up = ax.barh(y_pos, up_vals, color=CLR_UP,
edgecolor="white", linewidth=0.5, height=0.65,
alpha=0.85, label="Up-bin")
# Annotate bars with counts
for i, (dv, uv, deltav) in enumerate(zip(down_vals, up_vals, delta_vals)):
if dv > 0:
ax.text(-dv - 0.15, i, str(dv), va="center", ha="right",
fontsize=7, color=CLR_DOWN, fontweight="bold")
if uv > 0:
ax.text(uv + 0.15, i, str(uv), va="center", ha="left",
fontsize=7, color=CLR_UP, fontweight="bold")
# Delta annotation at far right
delta_color = CLR_UP if deltav > 0 else (CLR_DOWN if deltav < 0 else CLR_MUTED)
delta_str = f"{deltav:+d}" if deltav != 0 else "0"
ax.text(max_val + 1.0, i, f"\u0394={delta_str}", va="center", ha="left",
fontsize=6.5, color=delta_color)
ax.set_yticks(y_pos)
ax.set_yticklabels(bin_labels, fontsize=7)
ax.set_xlabel("Stacks", fontsize=9)
ax.set_ylabel("Price Bin (USD)", fontsize=9)
ax.axvline(0, color=CLR_FG, linewidth=0.6)
ax.set_xlim(-max_val - 1.5, max_val + 2.5)
ax.legend(loc="lower right", fontsize=8)
fig.tight_layout()
fig.savefig(path, dpi=CHART_DPI, bbox_inches="tight")
plt.close(fig)
print(f"[OK] {path}")
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
# 7. MAIN
# ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
def main():
out_dir = os.path.dirname(os.path.abspath(__file__))
# ββ Build profiles ββββββββββββββββββββββββββββββββββββββββββββββββββββ
cmp = build_cmp(DATAPOINTS, BIN_SIZE)
gmp = build_gmp(DATAPOINTS, BIN_SIZE)
updown = build_updown_profile(DATAPOINTS, BIN_SIZE)
# ββ Write CSVs ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
write_datapoints_csv(DATAPOINTS, os.path.join(out_dir, "datapoints.csv"))
write_profile_csv(cmp, BIN_SIZE, os.path.join(out_dir, "cmp_profile.csv"))
write_profile_csv(gmp, BIN_SIZE, os.path.join(out_dir, "gmp_profile.csv"))
write_updown_profile_csv(updown, gmp, BIN_SIZE,
os.path.join(out_dir, "updown_profile.csv"))
# ββ Generate charts βββββββββββββββββββββββββββββββββββββββββββββββββββ
if HAS_MPL:
chart_price_scatter(
DATAPOINTS, os.path.join(out_dir, "fig_price_scatter.png"))
chart_profile(
cmp, BIN_SIZE, os.path.join(out_dir, "fig_cmp_profile.png"),
"Conventional Market Profile (CMP)", CLR_ACCENT2)
chart_profile(
gmp, BIN_SIZE, os.path.join(out_dir, "fig_gmp_profile.png"),
"Gap-Filled Market Profile (GMP)", CLR_ACCENT3)
chart_cmp_vs_gmp(
cmp, gmp, BIN_SIZE,
os.path.join(out_dir, "fig_cmp_vs_gmp.png"))
chart_combined_3panel(
DATAPOINTS, cmp, gmp, BIN_SIZE,
os.path.join(out_dir, "fig_combined_3panel.png"))
chart_updown_footprint(
updown, BIN_SIZE,
os.path.join(out_dir, "fig_updown_footprint.png"))
# ββ Print summary βββββββββββββββββββββββββββββββββββββββββββββββββββββ
print("\nββ CMP Profile ββ")
b_min = min(cmp.keys())
b_max = max(cmp.keys())
for b in range(b_min, b_max + 1):
info = cmp.get(b, {"labels": [], "count": 0})
grp = "".join(sorted(info["labels"]))
print(f" Bin {b - b_min + 1}: {int(b * BIN_SIZE)}β{int((b+1) * BIN_SIZE)} "
f"group={grp or 'β':6s} stacks={info['count']}")
print("\nββ GMP Profile ββ")
b_min = min(gmp.keys())
b_max = max(gmp.keys())
for b in range(b_min, b_max + 1):
info = gmp.get(b, {"labels": [], "count": 0})
grp = "".join(sorted(info["labels"]))
print(f" Bin {b - b_min + 1}: {int(b * BIN_SIZE)}β{int((b+1) * BIN_SIZE)} "
f"group={grp or 'β':6s} stacks={info['count']}")
print("\nββ Up/Down-Bin Footprint Profile ββ")
b_min = min(updown.keys())
b_max = max(updown.keys())
for b in range(b_min, b_max + 1):
info = updown.get(b, {"labels": [], "up": 0, "down": 0})
grp = "".join(info["labels"])
delta = info["up"] - info["down"]
print(f" Bin {b - b_min + 1}: {int(b * BIN_SIZE)}β{int((b+1) * BIN_SIZE)} "
f"group={grp or 'β':6s} up={info['up']} down={info['down']} "
f"delta={delta:+d}")
if __name__ == "__main__":
main()
```
```datapoints.csv
datapoint,x-axis trades (raw trades or time),y-axis Price
A,1,3000.914
B,2,3003.837
C,3,3002.432
D,4,3009.892
E,5,3007.698
F,6,3009.176
G,7,3003.381
H,8,3004.283
I,9,3003.512
J,10,3003.012
```
```cmp_profile.csv
bin (with binsize = 1 symbol's price unit),price from,price until,datapoint group,number of profile's stacks
1,3000,3001,A,1
2,3001,3002,,0
3,3002,3003,C,1
4,3003,3004,BGIJ,4
5,3004,3005,H,1
6,3005,3006,,0
7,3006,3007,,0
8,3007,3008,E,1
9,3008,3009,,0
10,3009,3010,DF,2
```
```gmp_profile.csv
bin (with binsize = 1 symbol's price unit),price from,price until,datapoint group,number of profile's stacks
1,3000,3001,A,1
2,3001,3002,A,1
3,3002,3003,AC,2
4,3003,3004,BCGIJ,5
5,3004,3005,CFH,3
6,3005,3006,CF,2
7,3006,3007,CF,2
8,3007,3008,CEF,3
9,3008,3009,CDEF,4
10,3009,3010,DF,2
```
```updown_profile.csv
bin (with binsize = 1 symbol's price unit),price from,price until,datapoint group,down-bin profile's stacks,up-bin profile's stacks,delta-bin profile's stacks
1,3000,3001,A,0,0,0
2,3001,3002,A,0,1,1
3,3002,3003,AC,1,1,0
4,3003,3004,BCGIJ,3,2,-1
5,3004,3005,CFH,1,2,1
6,3005,3006,CF,1,1,0
7,3006,3007,CF,1,1,0
8,3007,3008,CEF,2,1,-1
9,3008,3009,CDEF,2,2,0
10,3009,3010,DF,0,2,2
``` |