Public
Edited
Jan 17, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
365 * 5
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
s1xtA1 = s1xtAGen(0.259, 0.0001)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
randomAprData.data.map((x, i) => x.yield).reduce((a, b, i) => i === 0 ? [b] : [...a, b + a[i - 1]], 0);

Insert cell
d3.mean(randomAprData.data.map(x => x.apr))
Insert cell
d3.deviation(randomAprData.data.map(x => x.apr))
Insert cell
uInstrument = (m, s) => {
return {
floatingConfig: {
gen: () => {
const rate = d3.randomNormal(m, s)()
return rate > 0 ? rate : 0
}
}
}
}
Insert cell
randomAprData = randomAprDataGen(realData.N, dataStats.apr.mean, dataStats.apr.deviation)
Insert cell
test = dataDiffMeansRaw.filter(x => x.s === 0.025 && x.m === 0.20)
Insert cell
dataDiffMeansRaw = {
const data = []
for (const d of dataDiffMeans) {
d.data.forEach(x => {
data.push({
m: d.m,
s: d.s,
dm: d.dm,
...x
})
})
}
return data
}
Insert cell
dataDiffMeans = multiData(5, 10)
Insert cell
[...Array(50).keys()].map(x => 0.4 * (x + 1) / 100).pop()
Insert cell
test2 = multiData(1, 10, [...Array(50).keys()].map(x => 0.4 * (x + 1) / 100) )
Insert cell
multiData = (x, N = 10, sRange = [0.025, 0.05, 0.1, 0.15]) => {
const m0 = params.vault.fixedRateAPR
// const s = 0.05
const results = []
for (const s of sRange) {
for (let i = 0; i < x * 2; i += 0.25) {
const mx = x / 100
const m = (m0 - mx) + i/100
const dm = m/m0 - 1
const data = {
dm,
m,
s,
...randomAprDataGen(N, m, s)
}
results.push(data)
}
}
return results
}
Insert cell
Insert cell
Insert cell
realData = {
const N = 10
const bankruptLimit = 10
const start = new Date("06/01/2022")
const end = new Date("12/01/2022")
const daysRange = Math.floor((end - start )/ (1000 * 60 * 60 * 24))
const pool = "0x8ad599c3a0ff1de082011efddc58f1908eb6e6d8"
const dataRaw = parsedPerfAll.filter(d => d.date >= start && d.date < end && d.pool === pool)
const symbol = dataRaw[0].symbol
return {
N,
start,
end,
daysRange,
pool,
symbol,
dataRaw,
bankruptLimit
}
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dashi = require('@saffron-finance/dashi@0.1.31')
Insert cell
Insert cell
import { parsedPerfAll, tokenIconUrls } from '@rx3a97/uniswap-historical-data'
Insert cell
Insert cell
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