Published
Edited
Jul 20, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof chart_events = {
// define our base line chart of stock prices
const rect = vl.markRect()
.title('Events')
.encode(
vl.x().fieldT('Date'),
vl.x2().fieldT('End_date'),
vl.color().fieldN('type').scale({ domain: local_event_check, scheme:'category10'}),
vl.tooltip('event'),

);

const line = vl.markLine().data(local_data)
.encode(
vl.x().fieldT('Date'),
//vl.y().fieldQ('Close').scale({type: 'log'}),
vl.y().fieldQ('Close'),
vl.color().fieldN('Symbol').scale({ domain: local_ticker_check, scheme:'category10'}),
vl.tooltip('Close'),
);
return vl.data(local_event_data)
.layer(
line, rect
)
.width(700)
.height(400)
.render()
}
Insert cell
Insert cell
Insert cell
Insert cell
md `## Global Configuration `
Insert cell
debug = true
Insert cell
W0 = 1200
Insert cell
w = width >= W0 ? Math.floor(width * 0.4) : width * 0.75 // for fullscreen
Insert cell
height_sankey = 600 * 0.6
Insert cell
colorVega = "#4C78A8"
Insert cell
// candle chart interval
interval = '1d'
Insert cell
md `## Internal Functions`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
md `## Data`
Insert cell
local_data = FileAttachment("tickers_full.csv").csv()
Insert cell
local_event_data = FileAttachment("events.csv").csv()
Insert cell
symbol = 'ETHUSD_PERP'
Insert cell
candle_data = candles(symbol, interval)
Insert cell
Insert cell
factsExample = crossfilter(local_data)
Insert cell
sportDim = factsExample.dimension(d => d.Close)
Insert cell
function sampleArray(a, n, random) {
return a.slice(0, n);
}
Insert cell
tickers = ['BTC-USD','ETH-USD', 'AAPL', 'TSLA', 'MSFT', 'NVDA', 'SQ', 'PYPL', 'MSTR', 'JPM', '^IXIC', '^DJI', '^GSPC', 'GC=F', "CL=F"]
Insert cell
type = ['BTC History', 'Global', 'Elon', 'Financial']
Insert cell
md `## Import Libraries `
Insert cell
vegalite = require("@observablehq/vega-lite@0.3")
Insert cell

import {vegaSync} from "@pierreleripoll/vegasync"

Insert cell
import {createFacts} from "@pierreleripoll/vegasync"
Insert cell
//crossfilter = require("crossfilter2")
Insert cell
crossfilter = require("crossfilter2@1.5.4")
Insert cell
import {fullscreen} from "@pierreleripoll/vegasync"

Insert cell
import {slider,button,select,text,radio,checkbox,number} from "@jashkenas/inputs"
Insert cell
import {candles, forwardRate} from "@pandawhisperer/binance-futures-with-forward-rate"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more