細かいところを調整しているが、大まかにはフェイクサーバはできたんじゃないだろうか。
'use strict'; // ref: https://shizenkarasuzon.hatenablog.com/entry/2021/04/21/004132 const fs = require('fs'); const WebSocket = require('ws'); const wss = new WebSocket.Server({ port: 8000 }); const output = (() => { return { "OverSellQty": 187600, // OVER気配数量 "UnderBuyQty": 115300, // UNDER気配数量 "TotalMarketValue": 7222044650000, // 時価総額 "MarketOrderSellQty": 0, // 売成行数量 "MarketOrderBuyQty": 0, "BidTime": "2021-09-10T11:12:23+09:00", "AskTime": "2021-09-10T11:12:23+09:00", "Exchange": 1, "ExchangeName": "東証1部", "TradingVolume": 476400, "TradingVolumeTime": "2021-09-10T11:12:13+09:00", "VWAP": 54702.097, "TradingValue": 26060079000, "BidQty": 600, "BidPrice": 54870, "BidSign": "0101", "Sell1": { "Price": 54870, "Qty": 600, "Sign": "0101", "Time": "2021-09-10T11:12:23+09:00" }, "Sell2": { "Price": 54880, "Qty": 600 }, "Sell3": { "Price": 54890, "Qty": 1500 }, "Sell4": { "Price": 54900, "Qty": 1400 }, "Sell5": { "Price": 54910, "Qty": 500 }, "Sell6": { "Price": 54920, "Qty": 800 }, "Sell7": { "Price": 54930, "Qty": 900 }, "Sell8": { "Price": 54940, "Qty": 800 }, "Sell9": { "Price": 54950, "Qty": 800 }, "Sell10": { "Price": 54960, "Qty": 800 }, "AskQty": 200, "AskPrice": 54840, "AskSign": "0101", "Buy1": { "Price": 54840, "Qty": 200, "Sign": "0101", "Time": "2021-09-10T11:12:23+09:00" }, "Buy2": { "Price": 54830, "Qty": 500 }, "Buy3": { "Price": 54820, "Qty": 500 }, "Buy4": { "Price": 54810, "Qty": 1000 }, "Buy5": { "Price": 54800, "Qty": 600 }, "Buy6": { "Price": 54790, "Qty": 1400 }, "Buy7": { "Price": 54780, "Qty": 700 }, "Buy8": { "Price": 54770, "Qty": 1000 }, "Buy9": { "Price": 54760, "Qty": 300 }, "Buy10": { "Price": 54750, "Qty": 400 }, "Symbol": "7974", "SymbolName": "任天堂", "CurrentPrice": 54850, "CurrentPriceTime": "2021-09-10T11:12:13+09:00", "CurrentPriceChangeStatus": "0056", "CurrentPriceStatus": 1, "CalcPrice": 54850, "PreviousClose": 54340, "PreviousCloseTime": "2021-09-09T00:00:00+09:00", "ChangePreviousClose": 510, "ChangePreviousClosePer": 0.94, "OpeningPrice": 54400, "OpeningPriceTime": "2021-09-10T09:00:00+09:00", "HighPrice": 55090, "HighPriceTime": "2021-09-10T09:07:49+09:00", "LowPrice": 54400, "LowPriceTime": "2021-09-10T09:00:00+09:00", "SecurityType": 1 } }); wss.on('connection', function connection(ws) { ws.on('message', function incoming(message) { console.log('received: %s', message); ws.send(JSON.stringify(output())); }); ws.send(JSON.stringify(output())); });