mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-13 08:08:05 +00:00
158 lines
38 KiB
Plaintext
158 lines
38 KiB
Plaintext
{
|
|||
|
|
"cells": [
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 1,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"vscode": {
|
||
|
|
"languageId": "dotnet-interactive.csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"<div><div></div><div></div><div></div></div>"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/markdown": [
|
||
|
|
"Loading extensions from `Plotly.NET.Interactive.dll`"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"#r \"nuget: QuanTAlib;\"\n",
|
||
|
|
"#r \"nuget: Plotly.NET;\"\n",
|
||
|
|
"#r \"nuget: Plotly.NET.Interactive;\"\n",
|
||
|
|
"\n",
|
||
|
|
"using QuanTAlib;\n",
|
||
|
|
"using Plotly.NET;\n",
|
||
|
|
"using Plotly.NET.LayoutObjects;\n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 49,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"vscode": {
|
||
|
|
"languageId": "dotnet-interactive.csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [],
|
||
|
|
"source": [
|
||
|
|
"Yahoo_Feed data = new(Symbol: \"MSFT\", Period: 200);\n",
|
||
|
|
"ZLEMA_Series calc1 = new(data.OHLC4,20,true);\n",
|
||
|
|
"HMA_Series calc2 = new(data.OHLC4,20, true);\n",
|
||
|
|
"HEMA_Series calc3 = new(data.OHLC4,20, true);"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
{
|
||
|
|
"cell_type": "code",
|
||
|
|
"execution_count": 50,
|
||
|
|
"metadata": {
|
||
|
|
"dotnet_interactive": {
|
||
|
|
"language": "csharp"
|
||
|
|
},
|
||
|
|
"vscode": {
|
||
|
|
"languageId": "dotnet-interactive.csharp"
|
||
|
|
}
|
||
|
|
},
|
||
|
|
"outputs": [
|
||
|
|
{
|
||
|
|
"data": {
|
||
|
|
"text/html": [
|
||
|
|
"\n",
|
||
|
|
"<div>\n",
|
||
|
|
" <div id=\"34d44d07-fcaa-4072-9017-5faa3448ff33\"><!-- Plotly chart will be drawn inside this DIV --></div>\r\n",
|
||
|
|
"<script type=\"text/javascript\">\r\n",
|
||
|
|
"\r\n",
|
||
|
|
" var renderPlotly_34d44d07fcaa407290175faa3448ff33 = function() {\r\n",
|
||
|
|
" var fsharpPlotlyRequire = requirejs.config({context:'fsharp-plotly',paths:{plotly:'https://cdn.plot.ly/plotly-2.6.3.min'}}) || require;\r\n",
|
||
|
|
" fsharpPlotlyRequire(['plotly'], function(Plotly) {\r\n",
|
||
|
|
"\r\n",
|
||
|
|
" var data = [{\"type\":\"candlestick\",\"name\":\"\",\"x\":[\"2022-04-26T13:30:00\",\"2022-04-27T13:30:00\",\"2022-04-28T13:30:00\",\"2022-04-29T13:30:00\",\"2022-05-02T13:30:00\",\"2022-05-03T13:30:00\",\"2022-05-04T13:30:00\",\"2022-05-05T13:30:00\",\"2022-05-06T13:30:00\",\"2022-05-09T13:30:00\",\"2022-05-10T13:30:00\",\"2022-05-11T13:30:00\",\"2022-05-12T13:30:00\",\"2022-05-13T13:30:00\",\"2022-05-16T13:30:00\",\"2022-05-17T13:30:00\",\"2022-05-18T13:30:00\",\"2022-05-19T13:30:00\",\"2022-05-20T13:30:00\",\"2022-05-23T13:30:00\",\"2022-05-24T13:30:00\",\"2022-05-25T13:30:00\",\"2022-05-26T13:30:00\",\"2022-05-27T13:30:00\",\"2022-05-31T13:30:00\",\"2022-06-01T13:30:00\",\"2022-06-02T13:30:00\",\"2022-06-03T13:30:00\",\"2022-06-06T13:30:00\",\"2022-06-07T13:30:00\",\"2022-06-08T13:30:00\",\"2022-06-09T13:30:00\",\"2022-06-10T13:30:00\",\"2022-06-13T13:30:00\",\"2022-06-14T13:30:00\",\"2022-06-15T13:30:00\",\"2022-06-16T13:30:00\",\"2022-06-17T13:30:00\",\"2022-06-21T13:30:00\",\"2022-06-22T13:30:00\",\"2022-06-23T13:30:00\",\"2022-06-24T13:30:00\",\"2022-06-27T13:30:00\",\"2022-06-28T13:30:00\",\"2022-06-29T13:30:00\",\"2022-06-30T13:30:00\",\"2022-07-01T13:30:00\",\"2022-07-05T13:30:00\",\"2022-07-06T13:30:00\",\"2022-07-07T13:30:00\",\"2022-07-08T13:30:00\",\"2022-07-11T13:30:00\",\"2022-07-12T13:30:00\",\"2022-07-13T13:30:00\",\"2022-07-14T13:30:00\",\"2022-07-15T13:30:00\",\"2022-07-18T13:30:00\",\"2022-07-19T13:30:00\",\"2022-07-20T13:30:00\",\"2022-07-21T13:30:00\",\"2022-07-22T13:30:00\",\"2022-07-25T13:30:00\",\"2022-07-26T13:30:00\",\"2022-07-27T13:30:00\",\"2022-07-28T13:30:00\",\"2022-07-29T13:30:00\",\"2022-08-01T13:30:00\",\"2022-08-02T13:30:00\",\"2022-08-03T13:30:00\",\"2022-08-04T13:30:00\",\"2022-08-05T13:30:00\",\"2022-08-08T13:30:00\",\"2022-08-09T13:30:00\",\"2022-08-10T13:30:00\",\"2022-08-11T13:30:00\",\"2022-08-12T13:30:00\",\"2022-08-15T13:30:00\",\"2022-08-16T13:30:00\",\"2022-08-17T13:30:00\",\"2022-08-18T13:30:00\",\"2022-08-19T13:30:00\",\"2022-08-22T13:30:00\",\"2022-08-23T13:30:00\",\"2022-08-24T13:30:00\",\"2022-08-25T13:30:00\",\"2022-08-26T13:30:00\",\"2022-08-29T13:30:00\",\"2022-08-30T13:30:00\",\"2022-08-31T13:30:00\",\"2022-09-01T13:30:00\",\"2022-09-02T13:30:00\",\"2022-09-06T13:30:00\",\"2022-09-07T13:30:00\",\"2022-09-08T13:30:00\",\"2022-09-09T13:30:00\",\"2022-09-12T13:30:00\",\"2022-09-13T13:30:00\",\"2022-09-14T13:30:00\",\"2022-09-15T13:30:00\",\"2022-09-16T13:30:00\",\"2022-09-19T13:30:00\",\"2022-09-20T13:30:00\",\"2022-09-21T13:30:00\",\"2022-09-22T13:30:00\",\"2022-09-23T13:30:00\",\"2022-09-26T13:30:00\",\"2022-09-27T13:30:00\",\"2022-09-28T13:30:00\",\"2022-09-29T13:30:00\",\"2022-09-30T13:30:00\",\"2022-10-03T13:30:00\",\"2022-10-04T13:30:00\",\"2022-10-05T13:30:00\",\"2022-10-06T13:30:00\",\"2022-10-07T13:30:00\",\"2022-10-10T13:30:00\",\"2022-10-11T13:30:00\",\"2022-10-12T13:30:00\",\"2022-10-13T13:30:00\",\"2022-10-14T13:30:00\",\"2022-10-17T13:30:00\",\"2022-10-18T13:30:00\",\"2022-10-19T13:30:00\",\"2022-10-20T13:30:00\",\"2022-10-21T13:30:00\",\"2022-10-24T13:30:00\",\"2022-10-25T13:30:00\",\"2022-10-26T13:30:00\",\"2022-10-27T13:30:00\",\"2022-10-28T13:30:00\",\"2022-10-31T13:30:00\",\"2022-11-01T13:30:00\",\"2022-11-02T13:30:00\",\"2022-11-03T13:30:00\",\"2022-11-04T13:30:00\",\"2022-11-07T14:30:00\",\"2022-11-08T14:30:00\",\"2022-11-09T14:30:00\",\"2022-11-10T14:30:00\"],\"close\":[270.22,283.22,289.63,277.52,284.47,281.78,289.98,277.35,274.73,264.58,269.5,260.55,255.35,261.12,261.5,266.82,254.08,253.14,252.56,260.65,259.62,262.52,265.9,273.24,271.87,272.42,274.58,270.02,268.75,272.5,270.41,264.79,252.99,242.26,244.49,251.76,244.97,247.65,253.74,253.13,258.86,267.7,264.89,256.48,260.26,256.83,259.58,262.85,266.21,268.4,267.66,264.51,253.67,252.72,254.08,256.72,254.25,259.53,262.27,264.84,260.36,258.83,251.9,268.74,276.41,280.74,278.01,274.82,282.47,283.65,282.91,280.32,282.3,289.16,287.02,291.91,293.47,292.71,291.32,290.17,286.15,277.75,276.44,275.79,278.85,268.09,265.23,262.97,261.47,260.4,256.06,253.25,258.09,258.52,264.46,266.65,251.9
|
||
|
|
" var layout = {\"width\":1200,\"height\":600,\"template\":{\"layout\":{\"title\":{\"x\":0.05},\"font\":{\"color\":\"rgba(42, 63, 95, 1.0)\"},\"paper_bgcolor\":\"rgba(255, 255, 255, 1.0)\",\"plot_bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"autotypenumbers\":\"strict\",\"colorscale\":{\"diverging\":[[0.0,\"#8e0152\"],[0.1,\"#c51b7d\"],[0.2,\"#de77ae\"],[0.3,\"#f1b6da\"],[0.4,\"#fde0ef\"],[0.5,\"#f7f7f7\"],[0.6,\"#e6f5d0\"],[0.7,\"#b8e186\"],[0.8,\"#7fbc41\"],[0.9,\"#4d9221\"],[1.0,\"#276419\"]],\"sequential\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]],\"sequentialminus\":[[0.0,\"#0d0887\"],[0.1111111111111111,\"#46039f\"],[0.2222222222222222,\"#7201a8\"],[0.3333333333333333,\"#9c179e\"],[0.4444444444444444,\"#bd3786\"],[0.5555555555555556,\"#d8576b\"],[0.6666666666666666,\"#ed7953\"],[0.7777777777777778,\"#fb9f3a\"],[0.8888888888888888,\"#fdca26\"],[1.0,\"#f0f921\"]]},\"hovermode\":\"closest\",\"hoverlabel\":{\"align\":\"left\"},\"coloraxis\":{\"colorbar\":{\"outlinewidth\":0.0,\"ticks\":\"\"}},\"geo\":{\"showland\":true,\"landcolor\":\"rgba(229, 236, 246, 1.0)\",\"showlakes\":true,\"lakecolor\":\"rgba(255, 255, 255, 1.0)\",\"subunitcolor\":\"rgba(255, 255, 255, 1.0)\",\"bgcolor\":\"rgba(255, 255, 255, 1.0)\"},\"mapbox\":{\"style\":\"light\"},\"polar\":{\"bgcolor\":\"rgba(229, 236, 246, 1.0)\",\"radialaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"},\"angularaxis\":{\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"ticks\":\"\"}},\"scene\":{\"xaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"yaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true},\"zaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"gridwidth\":2.0,\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"backgroundcolor\":\"rgba(229, 236, 246, 1.0)\",\"showbackground\":true}},\"ternary\":{\"aaxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"baxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"caxis\":{\"ticks\":\"\",\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\"},\"bgcolor\":\"rgba(229, 236, 246, 1.0)\"},\"xaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":true,\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"yaxis\":{\"title\":{\"standoff\":15},\"ticks\":\"\",\"automargin\":true,\"linecolor\":\"rgba(255, 255, 255, 1.0)\",\"gridcolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinecolor\":\"rgba(255, 255, 255, 1.0)\",\"zerolinewidth\":2.0},\"annotationdefaults\":{\"arrowcolor\":\"#2a3f5f\",\"arrowhead\":0,\"arrowwidth\":1},\"shapedefaults\":{\"line\":{\"color\":\"rgba(42, 63, 95, 1.0)\"}},\"colorway\":[\"rgba(99, 110, 250, 1.0)\",\"rgba(239, 85, 59, 1.0)\",\"rgba(0, 204, 150, 1.0)\",\"rgba(171, 99, 250, 1.0)\",\"rgba(255, 161, 90, 1.0)\",\"rgba(25, 211, 243, 1.0)\",\"rgba(255, 102, 146, 1.0)\",\"rgba(182, 232, 128, 1.0)\",\"rgba(255, 151, 255, 1.0)\",\"rgba(254, 203, 82, 1.0)\"]},\"data\":{\"bar\":[{\"marker\":{\"line\":{\"color\":\"rgba(229, 236, 246, 1.0)\",\"width\":0.5},\"pattern\":{\"fillmode\":\"overlay\",\"size\":10,\"solidity\":0.2}},\"error_x\":{\"color\":\"rgba(42, 63
|
||
|
|
" var config = {\"responsive\":true};\r\n",
|
||
|
|
" Plotly.newPlot('34d44d07-fcaa-4072-9017-5faa3448ff33', data, layout, config);\r\n",
|
||
|
|
"});\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" if ((typeof(requirejs) !== typeof(Function)) || (typeof(requirejs.config) !== typeof(Function))) {\r\n",
|
||
|
|
" var script = document.createElement(\"script\");\r\n",
|
||
|
|
" script.setAttribute(\"src\", \"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\");\r\n",
|
||
|
|
" script.onload = function(){\r\n",
|
||
|
|
" renderPlotly_34d44d07fcaa407290175faa3448ff33();\r\n",
|
||
|
|
" };\r\n",
|
||
|
|
" document.getElementsByTagName(\"head\")[0].appendChild(script);\r\n",
|
||
|
|
" }\r\n",
|
||
|
|
" else {\r\n",
|
||
|
|
" renderPlotly_34d44d07fcaa407290175faa3448ff33();\r\n",
|
||
|
|
" }\r\n",
|
||
|
|
"</script>\r\n",
|
||
|
|
"\n",
|
||
|
|
" \n",
|
||
|
|
"</div> \n"
|
||
|
|
]
|
||
|
|
},
|
||
|
|
"metadata": {},
|
||
|
|
"output_type": "display_data"
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"source": [
|
||
|
|
"var layout = Layout.init<IConvertible>( \n",
|
||
|
|
" PlotBGColor : Color.fromString(\"#1e1e1e\"),\n",
|
||
|
|
" PaperBGColor : Color.fromString(\"#1e1e1e\"),\n",
|
||
|
|
" Font:Font.init(Size:10, Color: Color.fromString(\"#ffffff\")));\n",
|
||
|
|
"\n",
|
||
|
|
"var yAxis = LinearAxis.init<IConvertible, IConvertible, IConvertible, IConvertible, IConvertible, IConvertible>(\n",
|
||
|
|
" GridColor:Color.fromString(\"#252525\")); \n",
|
||
|
|
"\n",
|
||
|
|
"var candles = Chart2D.Chart.Candlestick<double, double, double, double, DateTime, string>(data.Open.v, data.High.v, data.Low.v, data.Close.v, data.Open.t, \"\");\n",
|
||
|
|
"var line1 = Chart2D.Chart.Line<DateTime,double,bool>(calc1.t, calc1.v,false,\"\").WithLineStyle(Width: 2, Color: Color.fromString(\"yellow\"));\n",
|
||
|
|
"var line2 = Chart2D.Chart.Line<DateTime,double,bool>(calc2.t, calc2.v, false,\"\").WithLineStyle(Width: 3, Color: Color.fromString(\"red\"));\n",
|
||
|
|
"var line3 = Chart2D.Chart.Line<DateTime,double,bool>(calc3.t, calc3.v, false,\"\").WithLineStyle(Width: 2, Color: Color.fromString(\"blue\"));\n",
|
||
|
|
"var chart = Chart.Combine(new []{candles, line1, line2, line3})\n",
|
||
|
|
" .WithSize(1200,600)\n",
|
||
|
|
" .WithMargin(Margin.init<int, int, int, int, int, bool>(30,10,40,30,1,false))\n",
|
||
|
|
" .WithXAxisRangeSlider(RangeSlider.init(Visible:false))\n",
|
||
|
|
" .WithYAxis(yAxis)\n",
|
||
|
|
" .WithXAxis(yAxis)\n",
|
||
|
|
" .WithTitle(\"MSFT\")\n",
|
||
|
|
" .WithLayout(layout);\n",
|
||
|
|
"\n",
|
||
|
|
"chart"
|
||
|
|
]
|
||
|
|
}
|
||
|
|
],
|
||
|
|
"metadata": {
|
||
|
|
"kernelspec": {
|
||
|
|
"display_name": ".NET (C#)",
|
||
|
|
"language": "C#",
|
||
|
|
"name": ".net-csharp"
|
||
|
|
},
|
||
|
|
"language_info": {
|
||
|
|
"file_extension": ".cs",
|
||
|
|
"mimetype": "text/x-csharp",
|
||
|
|
"name": "C#",
|
||
|
|
"pygments_lexer": "csharp",
|
||
|
|
"version": "9.0"
|
||
|
|
},
|
||
|
|
"orig_nbformat": 4
|
||
|
|
},
|
||
|
|
"nbformat": 4,
|
||
|
|
"nbformat_minor": 2
|
||
|
|
}
|