Skip to content

Instantly share code, notes, and snippets.

@al6x
Created December 21, 2024 09:29
Show Gist options
  • Save al6x/318f84dcd7c4f609e10d2577e58ffe57 to your computer and use it in GitHub Desktop.
Save al6x/318f84dcd7c4f609e10d2577e58ffe57 to your computer and use it in GitHub Desktop.
Julia vs Ruby
table = [
sort(
map(
(c) -> (type = :Without, moneyness = c.moneyness),
filter((c) -> c.tenor == 856, normalized_jl)
)
)...,
sort(
map(
(c) -> (type = "With CPI", moneyness = c.moneyness),
filter((c) -> c.tenor == 852, normalized)
)
)...
]
# table = map((i, item) -> ( i = i, item...) )
plot(
"Normalization with CPI and without, for last tenor of ~900 days",
table,
(
( height = 300, ),
( mark = :tick, ),
( x = :type, type = :nominal, domain = ["Without", "With CPI"] ),
( y = :moneyness, scale = :log, domain = [0.4, 2.5], axis_values..., title = "Moneyness" ),
)
)
table = [
normalized_jl
.select { |c| c.tenor == 856 }
.map { |c| { type: :Without, moneyness: c.moneyness } }
.sort,
normalized
.select { |c| c.tenor == 852 }
.map { |c| { type: "With CPI", moneyness: c.moneyness } }
.sort
].flatten
plot(
"Normalization with CPI and without, for last tenor of ~900 days",
table,
height: 300,
mark: :tick,
x: { type: :nominal, field: :type, domain: ["Without", "With CPI"] },
y: { type: :quantitative, field: :moneyness, scale: :log, domain: [0.4, 2.5], axis: { values: [], title: "Moneyness" } }
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment