Spaces:
Running
Running
Update js/socket.js
Browse files- js/socket.js +9 -3
js/socket.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import { state } from './state.js';
|
| 2 |
import { getSeries } from './chart.js';
|
| 3 |
-
|
|
|
|
| 4 |
|
| 5 |
export function startSocket() {
|
| 6 |
if(state.isReplay) return;
|
|
@@ -15,7 +16,7 @@ export function startSocket() {
|
|
| 15 |
|
| 16 |
const data = JSON.parse(e.data);
|
| 17 |
|
| 18 |
-
// Kline
|
| 19 |
if(data.e === 'kline') {
|
| 20 |
const k = data.k;
|
| 21 |
const candle = {
|
|
@@ -29,9 +30,14 @@ export function startSocket() {
|
|
| 29 |
updatePrice(candle.close);
|
| 30 |
}
|
| 31 |
|
| 32 |
-
//
|
| 33 |
if(data.e === 'aggTrade') {
|
| 34 |
const qty = parseFloat(data.q);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
if(qty > 0.02) spawnBubble(qty, data.m);
|
| 36 |
}
|
| 37 |
|
|
|
|
| 1 |
import { state } from './state.js';
|
| 2 |
import { getSeries } from './chart.js';
|
| 3 |
+
// IMPORANT: Add updateDelta here
|
| 4 |
+
import { updatePrice, renderDom, spawnBubble, setStatus, updateDelta } from './ui.js';
|
| 5 |
|
| 6 |
export function startSocket() {
|
| 7 |
if(state.isReplay) return;
|
|
|
|
| 16 |
|
| 17 |
const data = JSON.parse(e.data);
|
| 18 |
|
| 19 |
+
// Kline
|
| 20 |
if(data.e === 'kline') {
|
| 21 |
const k = data.k;
|
| 22 |
const candle = {
|
|
|
|
| 30 |
updatePrice(candle.close);
|
| 31 |
}
|
| 32 |
|
| 33 |
+
// Trades (This is where we fix the footprint)
|
| 34 |
if(data.e === 'aggTrade') {
|
| 35 |
const qty = parseFloat(data.q);
|
| 36 |
+
|
| 37 |
+
// 1. Update Delta/Footprint Numbers
|
| 38 |
+
updateDelta(qty, data.m);
|
| 39 |
+
|
| 40 |
+
// 2. Spawn Bubble (only big ones to reduce lag)
|
| 41 |
if(qty > 0.02) spawnBubble(qty, data.m);
|
| 42 |
}
|
| 43 |
|