Volatility cone
The range of past volatility over several windows, and where it stands now. Good for judging if a market is calm or wild against its own past.
The smallest code that works. change the code, then press Run
In your framework
import { Chart } from 'nervure/react';
import 'nervure/themes';
const spec = {
type: 'volcone',
prices: [
50300, 49981, 48996, 48954, 47856, 46770, 47100, 47212, 46409, 45684, 44888, 44105, 45319,
44047, 44382, 43079, 42870, 42195, 41568, 42153, 40946, 40783, 41004, 40872, 41694, 40911,
40640, 40718, 41654, 40953, 41103, 40737, 39668, 40275, 39761, 39642, 40740, 41644, 41266,
40371, 40964, 40690, 40623, 40679, 40271, 41489, 41125, 40460, 39835, 38717, 38210, 37115,
36811, 37282, 37439, 37416, 37962, 37064, 36407, 36578, 37359, 38965, 38445, 40057, 40580,
41098, 42722, 41827, 40945, 43234, 42255, 43631, 44455, 46476, 44465, 42388, 44254, 44665,
47172, 48793, 46702, 48349, 48423, 46998, 48139, 47893, 46697, 49148, 48528, 45819, 44636,
46989, 48558, 48108, 49801, 49809, 47262, 44842, 45530, 45551, 45646, 46176, 45197, 45443,
45728, 47017, 49499, 48491, 48772, 46696, 45059, 46242, 47290, 46041, 43692, 44315, 45231,
45968, 47200, 48944, 49628, 49741, 49263, 48695, 49588, 50337, 50703, 50108, 50245, 51063,
50416, 50675, 51103, 51232, 52135, 51767, 51543, 52424, 53240, 52748, 53206, 52944, 53910,
53232, 52607, 51776, 52269, 52490, 53371, 53352, 53977, 54771, 54179, 54318, 55173, 54805,
54459, 55414, 55984, 56510, 57011, 57339, 56444, 55799, 56432, 56810, 56365, 56440, 57303,
58003, 57175, 56205, 56206, 56108, 57118, 56497, 57171, 57826, 58654, 58797, 59628, 62078,
64762, 62783, 62473, 65812, 62142, 60235, 63779, 63602, 67192, 64973, 61798, 58782, 58851,
56968, 55880, 54367, 55188, 55316, 55448, 57137, 59916, 61421, 63340, 66999, 70905, 70338,
72400, 69605, 65778, 67746, 68533, 69531, 68416, 65948, 65187, 63390, 63096, 61361, 61113,
57650, 59444, 60417, 62167, 61349, 63155, 66367, 68910, 72316, 69859, 68692, 69948, 66912,
65136, 64595, 66896, 63258, 60998, 59471, 62015, 63324, 62048, 63199, 60327, 58376, 58861,
59677, 58837, 59029, 60958, 59353, 58977, 56757, 55648, 57563, 58710, 60862, 62413, 63568,
66148, 68455, 66161, 65179, 62207, 61033, 63878, 64083, 61321, 62459, 64376, 65387, 63706,
65622, 67077, 64966, 65800, 62578, 60136, 61838, 60718, 58850, 57331, 59418, 58045, 56150,
56516, 55585, 56356, 54418, 54143, 55048, 52532, 54929, 53321, 50626, 51181, 49056, 49959,
50229, 50704, 48065, 45506, 47729, 48464, 47088, 45649, 43669, 44595, 43810, 41720, 41887,
43224, 43059, 42472, 40267, 40079, 39451, 37641, 37806, 36522, 37234, 35290, 34588, 36029,
37955, 38392, 36882, 35747, 34304, 34799, 33629, 32734, 31943, 31448, 32294, 30567, 29753,
29226, 27637, 27251, 27459, 26043, 26140, 25380, 26449, 25338, 24250, 23792, 24745, 25263,
24998, 23733, 24566, 25567, 25548, 25338, 24336, 24505, 23342, 22801, 23043, 22890, 23235,
23036, 23542, 23737, 24504, 24292, 23707, 23044, 23297, 22991, 22665, 23219, 23133, 23519,
22807, 23527, 23467, 22726, 22941, 23237, 23551, 23511, 23127, 23048, 22371, 22233, 21992,
21361, 20729, 20651, 20553, 20247, 20258, 20175, 20804, 21027, 21268,
],
};
export default function Example() {
return <Chart spec={spec} style={{ height: 340 }} />;
}Or import this chart alone: what each import weighs.
Options
Beside the fields shared by every chart (title, format, heading, export…), type volcone takes:
/** Volatility cone: the range of past volatility over several windows, and where it stands now. */
interface VolConeSpec extends Base {
type: 'volcone';
/** Closing prices, one a day, oldest first. */
prices: number[];
/** Windows, in days: 7, 14, 30, 60, 90 by default. */
windows?: number[];
/** Days in a year, to put the volatility on a year: 365 by default (markets that never close). */
year?: number;
legend?: boolean | LegendOptions;
}Style it
- Colours:
theme.palette,chart.setColor(name, colour), or--nervure-palettein your CSS. More - Marks:
[data-series="name"], parts:[data-part="axes"],legend,series. What you change is kept in exports. - Movement:
animation: falsedraws at once. More - Files:
chart.download('png'),svg,csv. More