update websocket
This commit is contained in:
parent
2a34847fa1
commit
be59e44bf5
@ -349,7 +349,7 @@
|
||||
try {
|
||||
const newList = JSON?.parse(data);
|
||||
if (newList?.length > 0) {
|
||||
//console.log("Received message:", newList);
|
||||
console.log("Received message:", newList);
|
||||
if (originalData.some((item) => "changesPercentage" in item)) {
|
||||
originalData = calculateChange(originalData, newList);
|
||||
stockList = updateStockList(stockList, originalData);
|
||||
|
||||
@ -132,9 +132,9 @@ export const calculateChange = (oldList?: any[], newList?: any[]) => {
|
||||
const item = oldList[i];
|
||||
const newItem = newListMap.get(item.symbol);
|
||||
|
||||
if (newItem?.ap) {
|
||||
if (newItem?.avgPrice) {
|
||||
const { price, changesPercentage } = item;
|
||||
const newPrice = newItem.ap;
|
||||
const newPrice = newItem.avgPrice;
|
||||
|
||||
if (price != null && changesPercentage != null) {
|
||||
const baseLine = price / (1 + Number(changesPercentage) / 100);
|
||||
|
||||
@ -167,7 +167,7 @@
|
||||
//console.log('Received message:', data);
|
||||
try {
|
||||
const parsedData = JSON.parse(data);
|
||||
const { type, lp, time, bp, ap } = parsedData || {};
|
||||
const { type, lp, time, bp, ap, avgPrice } = parsedData || {};
|
||||
|
||||
if (type === "T") {
|
||||
$realtimePrice = typeof lp !== "undefined" ? lp : null;
|
||||
@ -179,7 +179,7 @@
|
||||
} else if (type === "Q") {
|
||||
$wsBidPrice = typeof bp !== "undefined" ? bp : null;
|
||||
$wsAskPrice = typeof ap !== "undefined" ? ap : null;
|
||||
$realtimePrice = $wsAskPrice?.toFixed(2);
|
||||
$realtimePrice = typeof avgPrice !== "undefined" ? avgPrice : null;
|
||||
}
|
||||
|
||||
// Update price increase state
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user