summaryrefslogtreecommitdiff
path: root/srv/src/http/static/trading-in-the-rain/SeriesComposer.js
diff options
context:
space:
mode:
authorBrian Picciano <mediocregopher@gmail.com>2022-09-13 12:56:08 +0200
committerBrian Picciano <mediocregopher@gmail.com>2022-09-13 12:56:08 +0200
commit4f01edb9230f58ff84b0dd892c931ec8ac9aad55 (patch)
tree9c1598a3f98203913ac2548883c02a81deb33dc7 /srv/src/http/static/trading-in-the-rain/SeriesComposer.js
parent5485984e05aebde22819adebfbd5ad51475a6c21 (diff)
move src out of srv, clean up default.nix and Makefile
Diffstat (limited to 'srv/src/http/static/trading-in-the-rain/SeriesComposer.js')
-rw-r--r--srv/src/http/static/trading-in-the-rain/SeriesComposer.js51
1 files changed, 0 insertions, 51 deletions
diff --git a/srv/src/http/static/trading-in-the-rain/SeriesComposer.js b/srv/src/http/static/trading-in-the-rain/SeriesComposer.js
deleted file mode 100644
index 134c64c..0000000
--- a/srv/src/http/static/trading-in-the-rain/SeriesComposer.js
+++ /dev/null
@@ -1,51 +0,0 @@
-function SeriesComposer(resource, rainCanvas, color) {
- this.rainCanvas = rainCanvas;
- this.color = color;
-
- this.priceDist = new Distributor(200);
- this.volumeDist = new Distributor(200);
- this.musicBox = new MusicBox(this.priceDist, this.volumeDist);
-
- this.enabled = false;
- this.setEnabled = (enabled) => this.enabled = enabled;
- this.getEnabled = () => { return this.enabled; }
-
- this.totalTrades = 0;
- this.getTotalTrades = () => { return this.totalTrades; }
-
- this.cw = new CW(resource);
- this.cw.ontrades = (trades) => {
- if (this.totalTrades > 0 && this.enabled) {
- let priceVols = {}; // sum volumes by price, for deduplication
- for (let i in trades) {
- let price = trades[i].price, volume = trades[i].volume;
- if (!priceVols[price]) priceVols[price] = 0;
- priceVols[price] += volume;
- }
-
- trades = []; // overwrite trades with deduplicated ones.
- for (let price in priceVols) {
- let volume = priceVols[price];
- let intensity = this.volumeDist.distribute(volume, 0, 1);
- this.rainCanvas.newDrop({
- x: this.priceDist.distribute(price, 0, 1),
- y: Math.random(),
- intensity: intensity,
- color: this.color,
- });
-
- trades.push({price: price, volume: volume});
- }
-
- this.musicBox.playTrades(trades);
- }
-
- for (let i in trades) {
- this.priceDist.add(trades[i].price);
- this.volumeDist.add(trades[i].volume);
- }
-
- this.totalTrades += trades.length;
- if (this.ontrades) this.ontrades(trades);
- };
-}