Coding Global Background
Coding Global

my journey into algorithmic trading and machine learning

c++
Archived a month ago
6 messages
2 members
Created 2 months ago
Updated 2 months ago
Open in Discord
S
No1
Script Kiddie!
Gemini Writeup:
__
Here is the problem I faced and the solution I built:

πŸ“‰ The Problem: Visualizing the "Black Box"In algo trading and ML, the data isn't just textβ€”it is millions of floating-point numbers (market ticks, tensor weights, probability distributions) generated at high frequency. I needed to see this data in real-time to debug my models, but the backend requirements were heavy:

β€’ Server-Side Dependency: My trading engines and ML models relied on direct file system access and C++ DLLs that simply cannot run in a browser.β€’ Data Volume: A single training epoch or backtest could generate gigabytes of Float64 arrays.
πŸ›‘ Why Standard Web Tech Failed (JSON)I quickly realized I couldn't use standard REST or JSON over WebSockets.

β€’ The Serialization Bottleneck: Converting a 1GB array of market ticks into JSON (text) explodes the size to ~3GB and forces the CPU to burn cycles parsing strings back into numbers.β€’ Latency: For real-time trading visualization, the "garbage collection pause" caused by parsing massive JSON objects was unacceptable.
⚑ The Solution: A Custom Binary BridgeTo bridge this gap, I built a custom binary RPC protocol that treats the browser like a direct extension of my server's memory.

β€’ Zero-Copy Math: I implemented a system in rpc-args.ts and encoding.ts that serializes TypedArrays (like Float64Array) directly into binary. This allows my trading algorithms to dump raw numerical buffers into a WebSocket, which the browser reads immediately without parsing overhead.β€’ Remote Execution: I built a transport layer (sender.ts) that lets the client invoke server-only functions (like executing a trade via a DLL) by sending compact binary commands.

Replies (6)