|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "id": "30d768ca", |
| 7 | + "metadata": {}, |
| 8 | + "outputs": [], |
| 9 | + "source": [ |
| 10 | + "import tradingeconomics as te" |
| 11 | + ] |
| 12 | + }, |
| 13 | + { |
| 14 | + "cell_type": "code", |
| 15 | + "execution_count": 2, |
| 16 | + "id": "2494d5ac", |
| 17 | + "metadata": {}, |
| 18 | + "outputs": [ |
| 19 | + { |
| 20 | + "data": { |
| 21 | + "text/plain": [ |
| 22 | + "'You are logged in as a 51a072f89c934bd:l011saq3ckgd3ka'" |
| 23 | + ] |
| 24 | + }, |
| 25 | + "execution_count": 2, |
| 26 | + "metadata": {}, |
| 27 | + "output_type": "execute_result" |
| 28 | + } |
| 29 | + ], |
| 30 | + "source": [ |
| 31 | + "te.login(\"51a072f89c934bd:l011saq3ckgd3ka\")" |
| 32 | + ] |
| 33 | + }, |
| 34 | + { |
| 35 | + "cell_type": "markdown", |
| 36 | + "id": "f9ee71d0", |
| 37 | + "metadata": {}, |
| 38 | + "source": [ |
| 39 | + "### To get historical to symbol\n", |
| 40 | + "\n" |
| 41 | + ] |
| 42 | + }, |
| 43 | + { |
| 44 | + "cell_type": "code", |
| 45 | + "execution_count": 3, |
| 46 | + "id": "845e3df2", |
| 47 | + "metadata": {}, |
| 48 | + "outputs": [ |
| 49 | + { |
| 50 | + "data": { |
| 51 | + "text/html": [ |
| 52 | + "<div>\n", |
| 53 | + "<style scoped>\n", |
| 54 | + " .dataframe tbody tr th:only-of-type {\n", |
| 55 | + " vertical-align: middle;\n", |
| 56 | + " }\n", |
| 57 | + "\n", |
| 58 | + " .dataframe tbody tr th {\n", |
| 59 | + " vertical-align: top;\n", |
| 60 | + " }\n", |
| 61 | + "\n", |
| 62 | + " .dataframe thead th {\n", |
| 63 | + " text-align: right;\n", |
| 64 | + " }\n", |
| 65 | + "</style>\n", |
| 66 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 67 | + " <thead>\n", |
| 68 | + " <tr style=\"text-align: right;\">\n", |
| 69 | + " <th></th>\n", |
| 70 | + " <th>Symbol</th>\n", |
| 71 | + " <th>Date</th>\n", |
| 72 | + " <th>Open</th>\n", |
| 73 | + " <th>High</th>\n", |
| 74 | + " <th>Low</th>\n", |
| 75 | + " <th>Close</th>\n", |
| 76 | + " </tr>\n", |
| 77 | + " </thead>\n", |
| 78 | + " <tbody>\n", |
| 79 | + " <tr>\n", |
| 80 | + " <th>0</th>\n", |
| 81 | + " <td>Free accounts have access to the following cou...</td>\n", |
| 82 | + " <td>26/11/2022</td>\n", |
| 83 | + " <td>None</td>\n", |
| 84 | + " <td>None</td>\n", |
| 85 | + " <td>None</td>\n", |
| 86 | + " <td>None</td>\n", |
| 87 | + " </tr>\n", |
| 88 | + " </tbody>\n", |
| 89 | + "</table>\n", |
| 90 | + "</div>" |
| 91 | + ], |
| 92 | + "text/plain": [ |
| 93 | + " Symbol Date Open High \\\n", |
| 94 | + "0 Free accounts have access to the following cou... 26/11/2022 None None \n", |
| 95 | + "\n", |
| 96 | + " Low Close \n", |
| 97 | + "0 None None " |
| 98 | + ] |
| 99 | + }, |
| 100 | + "execution_count": 3, |
| 101 | + "metadata": {}, |
| 102 | + "output_type": "execute_result" |
| 103 | + } |
| 104 | + ], |
| 105 | + "source": [ |
| 106 | + "te.getHistorical(symbol='aapl:us',output_type='df')\n" |
| 107 | + ] |
| 108 | + }, |
| 109 | + { |
| 110 | + "cell_type": "markdown", |
| 111 | + "id": "593f80f7", |
| 112 | + "metadata": {}, |
| 113 | + "source": [ |
| 114 | + "### To get historical to multiple symbols\n", |
| 115 | + "\n" |
| 116 | + ] |
| 117 | + }, |
| 118 | + { |
| 119 | + "cell_type": "code", |
| 120 | + "execution_count": 4, |
| 121 | + "id": "16094e5d", |
| 122 | + "metadata": {}, |
| 123 | + "outputs": [ |
| 124 | + { |
| 125 | + "data": { |
| 126 | + "text/html": [ |
| 127 | + "<div>\n", |
| 128 | + "<style scoped>\n", |
| 129 | + " .dataframe tbody tr th:only-of-type {\n", |
| 130 | + " vertical-align: middle;\n", |
| 131 | + " }\n", |
| 132 | + "\n", |
| 133 | + " .dataframe tbody tr th {\n", |
| 134 | + " vertical-align: top;\n", |
| 135 | + " }\n", |
| 136 | + "\n", |
| 137 | + " .dataframe thead th {\n", |
| 138 | + " text-align: right;\n", |
| 139 | + " }\n", |
| 140 | + "</style>\n", |
| 141 | + "<table border=\"1\" class=\"dataframe\">\n", |
| 142 | + " <thead>\n", |
| 143 | + " <tr style=\"text-align: right;\">\n", |
| 144 | + " <th></th>\n", |
| 145 | + " <th>Symbol</th>\n", |
| 146 | + " <th>Date</th>\n", |
| 147 | + " <th>Open</th>\n", |
| 148 | + " <th>High</th>\n", |
| 149 | + " <th>Low</th>\n", |
| 150 | + " <th>Close</th>\n", |
| 151 | + " </tr>\n", |
| 152 | + " </thead>\n", |
| 153 | + " <tbody>\n", |
| 154 | + " <tr>\n", |
| 155 | + " <th>0</th>\n", |
| 156 | + " <td>Free accounts have access to the following cou...</td>\n", |
| 157 | + " <td>26/11/2022</td>\n", |
| 158 | + " <td>None</td>\n", |
| 159 | + " <td>None</td>\n", |
| 160 | + " <td>None</td>\n", |
| 161 | + " <td>None</td>\n", |
| 162 | + " </tr>\n", |
| 163 | + " </tbody>\n", |
| 164 | + "</table>\n", |
| 165 | + "</div>" |
| 166 | + ], |
| 167 | + "text/plain": [ |
| 168 | + " Symbol Date Open High \\\n", |
| 169 | + "0 Free accounts have access to the following cou... 26/11/2022 None None \n", |
| 170 | + "\n", |
| 171 | + " Low Close \n", |
| 172 | + "0 None None " |
| 173 | + ] |
| 174 | + }, |
| 175 | + "execution_count": 4, |
| 176 | + "metadata": {}, |
| 177 | + "output_type": "execute_result" |
| 178 | + } |
| 179 | + ], |
| 180 | + "source": [ |
| 181 | + "te.getHistorical(symbol=['aapl:us','gac:com'],output_type='df')" |
| 182 | + ] |
| 183 | + }, |
| 184 | + { |
| 185 | + "cell_type": "markdown", |
| 186 | + "id": "ca115563", |
| 187 | + "metadata": {}, |
| 188 | + "source": [ |
| 189 | + "### To get historical market data for specific symbol and time range:\n", |
| 190 | + "\n" |
| 191 | + ] |
| 192 | + }, |
| 193 | + { |
| 194 | + "cell_type": "code", |
| 195 | + "execution_count": 5, |
| 196 | + "id": "ede82fb9", |
| 197 | + "metadata": {}, |
| 198 | + "outputs": [ |
| 199 | + { |
| 200 | + "data": { |
| 201 | + "text/plain": [ |
| 202 | + "[{'Symbol': 'Free accounts have access to the following countries: Mexico, New Zealand, Sweden, Thailand. For more, contact us at [email protected].',\n", |
| 203 | + " 'Date': '26/11/2022',\n", |
| 204 | + " 'Open': None,\n", |
| 205 | + " 'High': None,\n", |
| 206 | + " 'Low': None,\n", |
| 207 | + " 'Close': None}]" |
| 208 | + ] |
| 209 | + }, |
| 210 | + "execution_count": 5, |
| 211 | + "metadata": {}, |
| 212 | + "output_type": "execute_result" |
| 213 | + } |
| 214 | + ], |
| 215 | + "source": [ |
| 216 | + "te.fetchMarkets(symbol='aapl:us', initDate='2017-01-01', endDate='2017-06-15')" |
| 217 | + ] |
| 218 | + }, |
| 219 | + { |
| 220 | + "cell_type": "markdown", |
| 221 | + "id": "454546c7", |
| 222 | + "metadata": {}, |
| 223 | + "source": [ |
| 224 | + "### To get historical market data for multiple symbols and specific time range:" |
| 225 | + ] |
| 226 | + }, |
| 227 | + { |
| 228 | + "cell_type": "code", |
| 229 | + "execution_count": 6, |
| 230 | + "id": "2b57e883", |
| 231 | + "metadata": {}, |
| 232 | + "outputs": [ |
| 233 | + { |
| 234 | + "data": { |
| 235 | + "text/plain": [ |
| 236 | + "[{'Symbol': 'Free accounts have access to the following countries: Mexico, New Zealand, Sweden, Thailand. For more, contact us at [email protected].',\n", |
| 237 | + " 'Date': '26/11/2022',\n", |
| 238 | + " 'Open': None,\n", |
| 239 | + " 'High': None,\n", |
| 240 | + " 'Low': None,\n", |
| 241 | + " 'Close': None}]" |
| 242 | + ] |
| 243 | + }, |
| 244 | + "execution_count": 6, |
| 245 | + "metadata": {}, |
| 246 | + "output_type": "execute_result" |
| 247 | + } |
| 248 | + ], |
| 249 | + "source": [ |
| 250 | + " te.fetchMarkets(symbol=['aapl:us', 'gac:com'], initDate='2017-01-01', endDate='2017-06-15')\n" |
| 251 | + ] |
| 252 | + } |
| 253 | + ], |
| 254 | + "metadata": { |
| 255 | + "kernelspec": { |
| 256 | + "display_name": "Python 3 (ipykernel)", |
| 257 | + "language": "python", |
| 258 | + "name": "python3" |
| 259 | + }, |
| 260 | + "language_info": { |
| 261 | + "codemirror_mode": { |
| 262 | + "name": "ipython", |
| 263 | + "version": 3 |
| 264 | + }, |
| 265 | + "file_extension": ".py", |
| 266 | + "mimetype": "text/x-python", |
| 267 | + "name": "python", |
| 268 | + "nbconvert_exporter": "python", |
| 269 | + "pygments_lexer": "ipython3", |
| 270 | + "version": "3.9.12" |
| 271 | + } |
| 272 | + }, |
| 273 | + "nbformat": 4, |
| 274 | + "nbformat_minor": 5 |
| 275 | +} |
0 commit comments