FlowscopeDocs

C004

key is missing from a setup map

Severity Error

A setup map literal is frozen, so its set of keys is known before the script runs. This lookup uses a constant key that is not in the map and would always return null.

Use one of the keys present in the literal (check spelling and case), or add the key to the literal.

Failing example

Flowscope Script
script "Venue weights"
data cvd = subscribe(data.cvd, exchange: "okx", bucket: "day")
setup weights = {"binance-futures": 1.0, "bybit": 0.8}
pane p = pane(title: "Weighted CVD", height: 0.25)
plot line = plot.line(title: "OKX CVD x weight", on: p)
on cvd.close {
  line.plot(cvd.close * (weights["okx"] ?? 1.0))
}

Fixed example

Flowscope Script
script "Venue weights"
data cvd = subscribe(data.cvd, exchange: "okx", bucket: "day")
setup weights = {"binance-futures": 1.0, "bybit": 0.8, "okx": 0.6}
pane p = pane(title: "Weighted CVD", height: 0.25)
plot line = plot.line(title: "OKX CVD x weight", on: p)
on cvd.close {
  line.plot(cvd.close * (weights["okx"] ?? 1.0))
}