Feed 'A' - Assets
Asset prices feed
Requests
{"event": "bind", "feed": "A"}
{"event": "unbind", "feed": "A"}
Feed handling
asset = {
"name": string,
"id": unsigned int32,
"price": Efx::Price // USD price of the asset
}
// snapshot
['A', 0, 'S', [array of assets]]
// assets added
['A', 0, '+', [array of assets]]
// asset price modified
['A', 0, 'M', [array of assets]]
// assets removed
['A', 0, '-', [array of assets]]
// failed to subscribe
['A', 0, 'Z', 2]
// unsubscribed
['A', 0, 'U', 0]
applyToSnapshot(prevSnapshot, feed, action, data) {
switch (feed) {
case 'A': {
switch (action) {
case 'S' : {
return data
}
case '+' : {
for (var asset in data) {
prevSnapshot[asset[0]] = asset
}
break
}
case 'M' : {
for (var asset in data) {
prevSnapshot[asset[0]] = asset
}
break
}
case '-' : {
for (var asset in data) {
prevSnapshot.delete(asset[0])
}
break
}
}
break
}
}
return prevSnapshot
}
Last updated