-
Notifications
You must be signed in to change notification settings - Fork 340
How the script works
-
The script requests as many APIs as there are in the
settings.js
, in parallel. Once the JSON is available for any market, itslast()
method is called, which loops through the JSON and gets the last price of every coin available, adding those results to the global objectcoin_prices
. As soon as there as been a response from at least 2 markets the functioncomputePrices(coin_prices)
is called, which finds the highest difference in price between markets for each coin, and adds that to an array which sorted from lowest to highest difference in price, and finally is sent to the browser via websockets. Every time a new market loads the function is called again, sending the updated results to the browser. This whole process is repeated every 10s (requests and computes the JSON again) and the browser automatically updates the frontend every time because of the magic which is websockets!