{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "![QuantConnect Logo](https://cdn.quantconnect.com/web/i/qc_notebook_logo_rev0.png)\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/BasicCSharpQuantBookTemplate.ipynb" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## QuantBook Basics\n", "\n", "### Start QuantBook\n", "- Load \"../QuantConnect.csx\" with all the basic imports\n", "- Create a QuantBook instance" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// We need to load assemblies at the start in their own cell\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.Research;\n", "using QuantConnect.Algorithm;\n", "\n", "var qb = new QuantBook();\n", "\n", "// Selecting asset data\n", "var spy = qb.AddEquity(\"SPY\");\n", "var eur = qb.AddForex(\"EURUSD\");\n", "var btc = qb.AddCrypto(\"BTCUSD\");\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Historical Data Requests\n", "\n", "We can use the QuantConnect API to make Historical Data Requests. The data will be presented as multi-index pandas.DataFrame where the first index is the Symbol.\n", "\n", "For more information, please follow the [link](https://www.quantconnect.com/docs#Historical-Data-Historical-Data-Requests)." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "// Gets historical data from the subscribed assets, the last 360 datapoints with daily resolution\n", "var h1 = qb.History(qb.Securities.Keys, 360, Resolution.Daily);\n", "Console.WriteLine(string.Join(\",\", h1.SelectMany(slice => slice.Keys).Distinct()))" ] }, { "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 }