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