{ "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#Introduction-to-Jupyter\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": [ "#load \"QuantConnect.csx\"\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", "var fxv = qb.AddData(\"EURUSD_Vol\", Resolution.Hour);" ] }, { "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()))" ] } ], "metadata": { "kernelspec": { "display_name": "C#", "language": "csharp", "name": "csharp" }, "language_info": { "file_extension": ".cs", "mimetype": "text/x-csharp", "name": "C#", "pygments_lexer": "c#", "version": "4.0.30319" } }, "nbformat": 4, "nbformat_minor": 2 }