106 lines
2.4 KiB
Plaintext
106 lines
2.4 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"\n",
|
|
"## Welcome to The QuantConnect Research Page\n",
|
|
"#### Refer to this page for documentation https://www.quantconnect.com/docs/research/overview#\n",
|
|
"#### Contribute to this template file https://github.com/QuantConnect/Lean/blob/master/Research/BasicQuantBookTemplate.ipynb"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"## QuantBook Basics\n",
|
|
"\n",
|
|
"### Start QuantBook\n",
|
|
"- Add the references and imports\n",
|
|
"- Create a QuantBook instance"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"// QuantBook C# Research Environment\n",
|
|
"// For more information see https://www.quantconnect.com/docs/research/overview\n",
|
|
"#load \"./Initialize.csx\""
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"#load \"./QuantConnect.csx\"\n",
|
|
"\n",
|
|
"using QuantConnect;\n",
|
|
"using QuantConnect.Data;\n",
|
|
"using QuantConnect.Algorithm;\n",
|
|
"using QuantConnect.Research;"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"var qb = new QuantBook();\n",
|
|
"var spy = qb.AddEquity(\"SPY\");"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"var startDate = new DateTime(2021,1,1);\n",
|
|
"var endDate = new DateTime(2021,12,31);\n",
|
|
"var history = qb.History(qb.Securities.Keys, startDate, endDate, Resolution.Daily);"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": [
|
|
"foreach(var slice in history.Take(5)) {\n",
|
|
" Console.WriteLine(slice.Bars[spy.Symbol].ToString());\n",
|
|
"}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"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"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|