-
Notifications
You must be signed in to change notification settings - Fork 81
/
6_0_candlestick.fsx
73 lines (57 loc) · 2.24 KB
/
6_0_candlestick.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
(*** hide ***)
(*** condition: prepare ***)
#r "nuget: Newtonsoft.JSON, 12.0.3"
#r "../bin/Plotly.NET/netstandard2.0/Plotly.NET.dll"
(*** condition: ipynb ***)
#if IPYNB
#r "nuget: Plotly.NET, {{fsdocs-package-version}}"
#r "nuget: Plotly.NET.Interactive, {{fsdocs-package-version}}"
#endif // IPYNB
(**
# Candlestick Charts
[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/plotly/Plotly.NET/gh-pages?filepath=6_0_candlestick.ipynb)
*Summary:* This example shows how to create candlestick charts in F#.
let's first create some data for the purpose of creating example charts:
*)
open Plotly.NET
let candles =
[|("2020-01-17T13:40:00", 0.68888, 0.68888, 0.68879, 0.6888);
("2020-01-17T13:41:00", 0.68883, 0.68884, 0.68875, 0.68877);
("2020-01-17T13:42:00", 0.68878, 0.68889, 0.68878, 0.68886);
("2020-01-17T13:43:00", 0.68886, 0.68886, 0.68876, 0.68879);
("2020-01-17T13:44:00", 0.68879, 0.68879, 0.68873, 0.68874);
("2020-01-17T13:45:00", 0.68875, 0.68877, 0.68867, 0.68868);
("2020-01-17T13:46:00", 0.68869, 0.68887, 0.68869, 0.68883);
("2020-01-17T13:47:00", 0.68883, 0.68899, 0.68883, 0.68899);
("2020-01-17T13:48:00", 0.68898, 0.689, 0.68885, 0.68889);
("2020-01-17T13:49:00", 0.68889, 0.68893, 0.68881, 0.68893);
("2020-01-17T13:50:00", 0.68891, 0.68896, 0.68886, 0.68891);
|]
|> Array.map (fun (d,o,h,l,c)->System.DateTime.Parse d, StockData.Create(o,h,l,c))
(**
A candlestick chart is useful for plotting stock prices over time. A candle
is a group of high, open, close and low values over a period of time, e.g. 1 minute, 5 minute, hour, day, etc..
The x-axis is usually dateime values and y is a sequence of candle structures.
*)
let candles1 = Chart.Candlestick candles
(*** condition: ipynb ***)
#if IPYNB
candles1
#endif // IPYNB
(***hide***)
candles1 |> GenericChart.toChartHTML
(***include-it-raw***)
(**
If you want to hide the rangeslider, use `withX_AxisRangeSlider` and hide it:
*)
let rangeslider = RangeSlider.init(Visible=false)
let candles2 =
Chart.Candlestick candles
|> Chart.withX_AxisRangeSlider rangeslider
(*** condition: ipynb ***)
#if IPYNB
candles2
#endif // IPYNB
(***hide***)
candles2 |> GenericChart.toChartHTML
(***include-it-raw***)