1228 lines
222 KiB
Plaintext
1228 lines
222 KiB
Plaintext
|
{
|
|||
|
"cells": [
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"### Начало лабораторной\n",
|
|||
|
"Выгрузка данных из csv файла в датафрейм"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 17,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"name": "stdout",
|
|||
|
"output_type": "stream",
|
|||
|
"text": [
|
|||
|
"Index(['Date', 'Open', 'High', 'Low', 'Close', 'Adj Close', 'Volume'], dtype='object')\n"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"df = pd.read_csv(\".//static//csv//Stocks.csv\")\n",
|
|||
|
"print(df.columns)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### Диаграмма числа продаж акций за год за весь период времени\n",
|
|||
|
"Данная диаграмма отображает зависимость обьема продаж от окончательных цен акций за каждый период что позволяет сделать вывод о том, что при низкой цене акций на них растет спрос. Однако если объемы растут, а цены - нет, то, возможно, это может свидетельствовать о нежелании инвесторов поддерживать высокую стоимость акций."
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 16,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABAsAAAHDCAYAAABCuZPJAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAACrKUlEQVR4nOzdd3gUVRfH8e8mkF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ygXLly7Nmzhx9//JHXXnuNrl27xvsRP3z4cKpVq8aAAQNcy5xXrKZMmcKDDz5IgwYNGDt2LMePH3eddG7cuJECBQq4HuPr6+s6EXXy9/ePd3/Xrl3cfffdPPLII/Tp04fJkyfTo0cPFi5cSNu2bQHzpT9v3jx69OhBSEgIx48fZ+LEibRo0YJt27ZRokSJePvMkycPkydPjnd1bOrUqfj4+HD58uUEr0+uXLn4999/2bhxI3Xq1HEtnzJlCnny5Emw/SeffEL16tW58847yZUrFz/++CODBg0iJiaGwYMHJ9g+riVLltChQwfKly/PqFGjuHTpEh988AHNmjVjw4YNrh9vp0+fZtKkSfj5+TFkyBCCgoL45ptv6Nq1K9OmTaNXr16ULVuWr7/+GoDt27fz+uuvJ3tsgOPHj9O4cWPXCX5QUBC//PILDz30EOfPn2fYsGEev5YpfW5OzthPnTrFxx9/TI8ePdi6dStVqlS54fOI65133km3PsQDBw50veeHDBlCWFgYH374IRs3bmTlypXkzp3b7X2m5v0TGRnJXXfdRbly5bh06RJTpkyhW7durFq1ioYNGwImmXfx4kUeffRRChcuzJo1a/jggw84dOgQs2bNSnLfixYtol+/fjz22GMJWrRER0dz22230bhxY958800WLlzIyJEjuXbtGqNHj3b7NXByvgfAnIhPmjSJ9957jyJFigBQrFixJB/7xx9/sGDBggTLw8LC6NixI8HBwbz88ssEBQUBcP/9998wnvPnz/P555/Tq1cv+vfvz4ULF/jiiy9o3749a9asSfTkH+Dq1at069aNAwcOsHLlSoKDg294rJR69tlnU7TduXPnGDt2bIr36+xq8Oyzz9K6dWuGDh1K06ZNGThwIAATJkzgzjvv5N577+XKlSt899139OjRg59++ilBF4UVK1Ywf/581/t37Nix3HHHHTzzzDN8/PHHDBo0iLNnz/Lmm2/Sr18/li5d6nqsO+/X6Oho2rdvT6NGjXj77bdZsmQJ77zzDhUqVODRRx91bedO7HHt3LmTnTt38vDDD7v1Y27UqFG88sortGnThkcffZQdO3bwySefsHbt2mQ/JyzLonPnzvz555888sgjVKtWjblz59KnT58UHzspPXv2JCQkhLFjx7JhwwY+//xzihYtyhtvvOHa5pVXXmHUqFE0bdqU0aNH4+Pjw99//83SpUtp166dR8e9vgtlREREvP8bgH///ZfmzZsTEBDAM888Q+7cuZk4cSItW7bk999/p1GjRjc8Tq9evbj99tvjLWvWrBlgvueaNm3KxYsXGTJkCIULF2bq1KnceeedzJ49m7vuuivRfX7yySeu//fExvRw573q7nmFiNyAJSKWZVnW5MmTLcBau3ZtirYLCwuzLMuyLl++bJUpU8bq0KGDBViTJ092bXvLLbdY/v7+1v79++PtIyYmJtF9ly1b1urTp0+C5VeuXLGKFi1q1ahRw7p06ZJr+U8//WQB1ssvv+xa1qdPHyt//vzJPoeyZctagPX999+7loWHh1vBwcFWnTp1XMsuX75sRUdHx3tsWFiY5evra40ePdq1bNmyZRZg9erVyypcuLAVFRXlWlepUiWrd+/eFmDNmjUrQZydOnWyHnvsMdfyFStWWHn
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1200x500 with 2 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"# Читаем данные из CSV файла\n",
|
|||
|
"df = pd.read_csv(\".//static//csv//Stocks.csv\")\n",
|
|||
|
"\n",
|
|||
|
"# Преобразуем колонку 'Date' в формат datetime\n",
|
|||
|
"df['Date'] = pd.to_datetime(df['Date'])\n",
|
|||
|
"\n",
|
|||
|
"# Добавляем колонку с годом\n",
|
|||
|
"df['Year'] = df['Date'].dt.year\n",
|
|||
|
"\n",
|
|||
|
"# Группируем данные по годам и суммируем объемы и цены закрытия\n",
|
|||
|
"annual_data = df.groupby('Year').agg({'Volume': 'sum', 'Close': 'mean'}).reset_index()\n",
|
|||
|
"\n",
|
|||
|
"# Создаем график\n",
|
|||
|
"fig, ax1 = plt.subplots(figsize=(12, 5))\n",
|
|||
|
"\n",
|
|||
|
"# Строим гистограмму объемов\n",
|
|||
|
"ax1.bar(annual_data['Year'], annual_data['Volume'], color='b', alpha=0.6, label='Объемы продаж')\n",
|
|||
|
"ax1.set_ylabel('Объем продаж', color='b')\n",
|
|||
|
"ax1.tick_params(axis='y', labelcolor='b')\n",
|
|||
|
"\n",
|
|||
|
"# Создаем вторую ось для отображения цены закрытия\n",
|
|||
|
"ax2 = ax1.twinx()\n",
|
|||
|
"ax2.plot(annual_data['Year'], annual_data['Close'], color='r', marker='o', label='Цена закрытия')\n",
|
|||
|
"ax2.set_ylabel('Цена закрытия', color='r')\n",
|
|||
|
"ax2.tick_params(axis='y', labelcolor='r')\n",
|
|||
|
"\n",
|
|||
|
"# Добавляем заголовок и легенды\n",
|
|||
|
"plt.title('Гистограмма объемов и цена закрытия акций Yamana Gold Inc. по годам')\n",
|
|||
|
"ax1.legend(loc='upper left')\n",
|
|||
|
"ax2.legend(loc='upper right')\n",
|
|||
|
"\n",
|
|||
|
"# Отображаем график\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### График визуализаций цен акций Yamana Gold Inc. \n",
|
|||
|
"Данный график отображает годовые цены акций, т.е. стоимость открытия, стоимость закрытия, максимум и минимум, что позволяет сделать вывод о тенденциях - если свеча красная - то цена открытия больше цены закрытия(т.е. стоимость акции в тот год преимущественно падала), иначе - если зеленая - то цена закрытия больше цены открытия(т.е. стоимотсь акции в тот год преимущественно росла)"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 15,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"application/vnd.plotly.v1+json": {
|
|||
|
"config": {
|
|||
|
"plotlyServerURL": "https://plot.ly"
|
|||
|
},
|
|||
|
"data": [
|
|||
|
{
|
|||
|
"close": [
|
|||
|
1.714286,
|
|||
|
2.571429,
|
|||
|
2.42,
|
|||
|
3.02,
|
|||
|
6.61,
|
|||
|
13.18,
|
|||
|
12.94,
|
|||
|
7.72,
|
|||
|
11.38,
|
|||
|
12.8,
|
|||
|
14.69,
|
|||
|
17.209999,
|
|||
|
8.62,
|
|||
|
4.02,
|
|||
|
1.86,
|
|||
|
2.81,
|
|||
|
3.12,
|
|||
|
2.36,
|
|||
|
3.95,
|
|||
|
5.71,
|
|||
|
4.22,
|
|||
|
5.44
|
|||
|
],
|
|||
|
"decreasing": {
|
|||
|
"line": {
|
|||
|
"color": "red"
|
|||
|
}
|
|||
|
},
|
|||
|
"high": [
|
|||
|
3.714286,
|
|||
|
4.857143,
|
|||
|
4,
|
|||
|
3.49,
|
|||
|
6.76,
|
|||
|
13.81,
|
|||
|
15.88,
|
|||
|
19.93,
|
|||
|
14.37,
|
|||
|
13.13,
|
|||
|
17.469999,
|
|||
|
20.59,
|
|||
|
18.23,
|
|||
|
10.72,
|
|||
|
4.84,
|
|||
|
5.99,
|
|||
|
3.65,
|
|||
|
3.8,
|
|||
|
4.03,
|
|||
|
7.02,
|
|||
|
6.16,
|
|||
|
6.4
|
|||
|
],
|
|||
|
"increasing": {
|
|||
|
"line": {
|
|||
|
"color": "green"
|
|||
|
}
|
|||
|
},
|
|||
|
"low": [
|
|||
|
1.142857,
|
|||
|
1.142857,
|
|||
|
1.142857,
|
|||
|
1.65,
|
|||
|
2.67,
|
|||
|
6.6,
|
|||
|
8.4,
|
|||
|
3.31,
|
|||
|
5.8,
|
|||
|
9.16,
|
|||
|
10.88,
|
|||
|
12.68,
|
|||
|
8.31,
|
|||
|
3.45,
|
|||
|
1.42,
|
|||
|
1.38,
|
|||
|
2.21,
|
|||
|
2,
|
|||
|
1.78,
|
|||
|
2.23,
|
|||
|
3.7,
|
|||
|
3.84
|
|||
|
],
|
|||
|
"name": "Candlestick",
|
|||
|
"open": [
|
|||
|
3.428571,
|
|||
|
1.714286,
|
|||
|
2.571429,
|
|||
|
2.42,
|
|||
|
2.83,
|
|||
|
6.81,
|
|||
|
13.17,
|
|||
|
13.21,
|
|||
|
7.67,
|
|||
|
11.85,
|
|||
|
12.82,
|
|||
|
15.13,
|
|||
|
17.59,
|
|||
|
8.82,
|
|||
|
3.94,
|
|||
|
1.92,
|
|||
|
2.84,
|
|||
|
3.17,
|
|||
|
2.37,
|
|||
|
4.01,
|
|||
|
5.94,
|
|||
|
4.16
|
|||
|
],
|
|||
|
"type": "candlestick",
|
|||
|
"x": [
|
|||
|
"2001-12-31T00:00:00",
|
|||
|
"2002-12-31T00:00:00",
|
|||
|
"2003-12-31T00:00:00",
|
|||
|
"2004-12-31T00:00:00",
|
|||
|
"2005-12-31T00:00:00",
|
|||
|
"2006-12-31T00:00:00",
|
|||
|
"2007-12-31T00:00:00",
|
|||
|
"2008-12-31T00:00:00",
|
|||
|
"2009-12-31T00:00:00",
|
|||
|
"2010-12-31T00:00:00",
|
|||
|
"2011-12-31T00:00:00",
|
|||
|
"2012-12-31T00:00:00",
|
|||
|
"2013-12-31T00:00:00",
|
|||
|
"2014-12-31T00:00:00",
|
|||
|
"2015-12-31T00:00:00",
|
|||
|
"2016-12-31T00:00:00",
|
|||
|
"2017-12-31T00:00:00",
|
|||
|
"2018-12-31T00:00:00",
|
|||
|
"2019-12-31T00:00:00",
|
|||
|
"2020-12-31T00:00:00",
|
|||
|
"2021-12-31T00:00:00",
|
|||
|
"2022-12-31T00:00:00"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"layout": {
|
|||
|
"plot_bgcolor": "rgba(240, 240, 240, 0.95)",
|
|||
|
"template": {
|
|||
|
"data": {
|
|||
|
"bar": [
|
|||
|
{
|
|||
|
"error_x": {
|
|||
|
"color": "#2a3f5f"
|
|||
|
},
|
|||
|
"error_y": {
|
|||
|
"color": "#2a3f5f"
|
|||
|
},
|
|||
|
"marker": {
|
|||
|
"line": {
|
|||
|
"color": "#E5ECF6",
|
|||
|
"width": 0.5
|
|||
|
},
|
|||
|
"pattern": {
|
|||
|
"fillmode": "overlay",
|
|||
|
"size": 10,
|
|||
|
"solidity": 0.2
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "bar"
|
|||
|
}
|
|||
|
],
|
|||
|
"barpolar": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"line": {
|
|||
|
"color": "#E5ECF6",
|
|||
|
"width": 0.5
|
|||
|
},
|
|||
|
"pattern": {
|
|||
|
"fillmode": "overlay",
|
|||
|
"size": 10,
|
|||
|
"solidity": 0.2
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "barpolar"
|
|||
|
}
|
|||
|
],
|
|||
|
"carpet": [
|
|||
|
{
|
|||
|
"aaxis": {
|
|||
|
"endlinecolor": "#2a3f5f",
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"minorgridcolor": "white",
|
|||
|
"startlinecolor": "#2a3f5f"
|
|||
|
},
|
|||
|
"baxis": {
|
|||
|
"endlinecolor": "#2a3f5f",
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"minorgridcolor": "white",
|
|||
|
"startlinecolor": "#2a3f5f"
|
|||
|
},
|
|||
|
"type": "carpet"
|
|||
|
}
|
|||
|
],
|
|||
|
"choropleth": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"type": "choropleth"
|
|||
|
}
|
|||
|
],
|
|||
|
"contour": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "contour"
|
|||
|
}
|
|||
|
],
|
|||
|
"contourcarpet": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"type": "contourcarpet"
|
|||
|
}
|
|||
|
],
|
|||
|
"heatmap": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "heatmap"
|
|||
|
}
|
|||
|
],
|
|||
|
"heatmapgl": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "heatmapgl"
|
|||
|
}
|
|||
|
],
|
|||
|
"histogram": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"pattern": {
|
|||
|
"fillmode": "overlay",
|
|||
|
"size": 10,
|
|||
|
"solidity": 0.2
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "histogram"
|
|||
|
}
|
|||
|
],
|
|||
|
"histogram2d": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "histogram2d"
|
|||
|
}
|
|||
|
],
|
|||
|
"histogram2dcontour": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "histogram2dcontour"
|
|||
|
}
|
|||
|
],
|
|||
|
"mesh3d": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"type": "mesh3d"
|
|||
|
}
|
|||
|
],
|
|||
|
"parcoords": [
|
|||
|
{
|
|||
|
"line": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "parcoords"
|
|||
|
}
|
|||
|
],
|
|||
|
"pie": [
|
|||
|
{
|
|||
|
"automargin": true,
|
|||
|
"type": "pie"
|
|||
|
}
|
|||
|
],
|
|||
|
"scatter": [
|
|||
|
{
|
|||
|
"fillpattern": {
|
|||
|
"fillmode": "overlay",
|
|||
|
"size": 10,
|
|||
|
"solidity": 0.2
|
|||
|
},
|
|||
|
"type": "scatter"
|
|||
|
}
|
|||
|
],
|
|||
|
"scatter3d": [
|
|||
|
{
|
|||
|
"line": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scatter3d"
|
|||
|
}
|
|||
|
],
|
|||
|
"scattercarpet": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scattercarpet"
|
|||
|
}
|
|||
|
],
|
|||
|
"scattergeo": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scattergeo"
|
|||
|
}
|
|||
|
],
|
|||
|
"scattergl": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scattergl"
|
|||
|
}
|
|||
|
],
|
|||
|
"scattermapbox": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scattermapbox"
|
|||
|
}
|
|||
|
],
|
|||
|
"scatterpolar": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scatterpolar"
|
|||
|
}
|
|||
|
],
|
|||
|
"scatterpolargl": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scatterpolargl"
|
|||
|
}
|
|||
|
],
|
|||
|
"scatterternary": [
|
|||
|
{
|
|||
|
"marker": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "scatterternary"
|
|||
|
}
|
|||
|
],
|
|||
|
"surface": [
|
|||
|
{
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"colorscale": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"type": "surface"
|
|||
|
}
|
|||
|
],
|
|||
|
"table": [
|
|||
|
{
|
|||
|
"cells": {
|
|||
|
"fill": {
|
|||
|
"color": "#EBF0F8"
|
|||
|
},
|
|||
|
"line": {
|
|||
|
"color": "white"
|
|||
|
}
|
|||
|
},
|
|||
|
"header": {
|
|||
|
"fill": {
|
|||
|
"color": "#C8D4E3"
|
|||
|
},
|
|||
|
"line": {
|
|||
|
"color": "white"
|
|||
|
}
|
|||
|
},
|
|||
|
"type": "table"
|
|||
|
}
|
|||
|
]
|
|||
|
},
|
|||
|
"layout": {
|
|||
|
"annotationdefaults": {
|
|||
|
"arrowcolor": "#2a3f5f",
|
|||
|
"arrowhead": 0,
|
|||
|
"arrowwidth": 1
|
|||
|
},
|
|||
|
"autotypenumbers": "strict",
|
|||
|
"coloraxis": {
|
|||
|
"colorbar": {
|
|||
|
"outlinewidth": 0,
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"colorscale": {
|
|||
|
"diverging": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#276419"
|
|||
|
]
|
|||
|
],
|
|||
|
"sequential": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
],
|
|||
|
"sequentialminus": [
|
|||
|
[
|
|||
|
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,
|
|||
|
"#f0f921"
|
|||
|
]
|
|||
|
]
|
|||
|
},
|
|||
|
"colorway": [
|
|||
|
"#636efa",
|
|||
|
"#EF553B",
|
|||
|
"#00cc96",
|
|||
|
"#ab63fa",
|
|||
|
"#FFA15A",
|
|||
|
"#19d3f3",
|
|||
|
"#FF6692",
|
|||
|
"#B6E880",
|
|||
|
"#FF97FF",
|
|||
|
"#FECB52"
|
|||
|
],
|
|||
|
"font": {
|
|||
|
"color": "#2a3f5f"
|
|||
|
},
|
|||
|
"geo": {
|
|||
|
"bgcolor": "white",
|
|||
|
"lakecolor": "white",
|
|||
|
"landcolor": "#E5ECF6",
|
|||
|
"showlakes": true,
|
|||
|
"showland": true,
|
|||
|
"subunitcolor": "white"
|
|||
|
},
|
|||
|
"hoverlabel": {
|
|||
|
"align": "left"
|
|||
|
},
|
|||
|
"hovermode": "closest",
|
|||
|
"mapbox": {
|
|||
|
"style": "light"
|
|||
|
},
|
|||
|
"paper_bgcolor": "white",
|
|||
|
"plot_bgcolor": "#E5ECF6",
|
|||
|
"polar": {
|
|||
|
"angularaxis": {
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"bgcolor": "#E5ECF6",
|
|||
|
"radialaxis": {
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"scene": {
|
|||
|
"xaxis": {
|
|||
|
"backgroundcolor": "#E5ECF6",
|
|||
|
"gridcolor": "white",
|
|||
|
"gridwidth": 2,
|
|||
|
"linecolor": "white",
|
|||
|
"showbackground": true,
|
|||
|
"ticks": "",
|
|||
|
"zerolinecolor": "white"
|
|||
|
},
|
|||
|
"yaxis": {
|
|||
|
"backgroundcolor": "#E5ECF6",
|
|||
|
"gridcolor": "white",
|
|||
|
"gridwidth": 2,
|
|||
|
"linecolor": "white",
|
|||
|
"showbackground": true,
|
|||
|
"ticks": "",
|
|||
|
"zerolinecolor": "white"
|
|||
|
},
|
|||
|
"zaxis": {
|
|||
|
"backgroundcolor": "#E5ECF6",
|
|||
|
"gridcolor": "white",
|
|||
|
"gridwidth": 2,
|
|||
|
"linecolor": "white",
|
|||
|
"showbackground": true,
|
|||
|
"ticks": "",
|
|||
|
"zerolinecolor": "white"
|
|||
|
}
|
|||
|
},
|
|||
|
"shapedefaults": {
|
|||
|
"line": {
|
|||
|
"color": "#2a3f5f"
|
|||
|
}
|
|||
|
},
|
|||
|
"ternary": {
|
|||
|
"aaxis": {
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"baxis": {
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": ""
|
|||
|
},
|
|||
|
"bgcolor": "#E5ECF6",
|
|||
|
"caxis": {
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": ""
|
|||
|
}
|
|||
|
},
|
|||
|
"title": {
|
|||
|
"x": 0.05
|
|||
|
},
|
|||
|
"xaxis": {
|
|||
|
"automargin": true,
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": "",
|
|||
|
"title": {
|
|||
|
"standoff": 15
|
|||
|
},
|
|||
|
"zerolinecolor": "white",
|
|||
|
"zerolinewidth": 2
|
|||
|
},
|
|||
|
"yaxis": {
|
|||
|
"automargin": true,
|
|||
|
"gridcolor": "white",
|
|||
|
"linecolor": "white",
|
|||
|
"ticks": "",
|
|||
|
"title": {
|
|||
|
"standoff": 15
|
|||
|
},
|
|||
|
"zerolinecolor": "white",
|
|||
|
"zerolinewidth": 2
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
"title": {
|
|||
|
"text": "Свечной график акций Yamana Gold Inc. за каждый год",
|
|||
|
"x": 0.5
|
|||
|
},
|
|||
|
"xaxis": {
|
|||
|
"gridcolor": "LightGray",
|
|||
|
"rangeslider": {
|
|||
|
"visible": false
|
|||
|
},
|
|||
|
"showgrid": true,
|
|||
|
"title": {
|
|||
|
"text": "Год"
|
|||
|
}
|
|||
|
},
|
|||
|
"yaxis": {
|
|||
|
"gridcolor": "LightGray",
|
|||
|
"showgrid": true,
|
|||
|
"title": {
|
|||
|
"text": "Цена ($)"
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import plotly.graph_objects as go\n",
|
|||
|
"\n",
|
|||
|
"# Считываем данные\n",
|
|||
|
"df = pd.read_csv(\".//static//csv//Stocks.csv\")\n",
|
|||
|
"\n",
|
|||
|
"# Преобразуем 'Date' в datetime формат\n",
|
|||
|
"df['Date'] = pd.to_datetime(df['Date'])\n",
|
|||
|
"\n",
|
|||
|
"# Устанавливаем 'Date' как индекс\n",
|
|||
|
"df.set_index('Date', inplace=True)\n",
|
|||
|
"\n",
|
|||
|
"# Ресемплируем данные по году\n",
|
|||
|
"df_yearly = df.resample('YE').agg({\n",
|
|||
|
" 'Open': 'first',\n",
|
|||
|
" 'High': 'max',\n",
|
|||
|
" 'Low': 'min',\n",
|
|||
|
" 'Close': 'last'\n",
|
|||
|
"})\n",
|
|||
|
"\n",
|
|||
|
"# Создаем список дат для каждой свечи\n",
|
|||
|
"df_yearly['Date'] = df_yearly.index\n",
|
|||
|
"\n",
|
|||
|
"# Создаем свечной график\n",
|
|||
|
"fig = go.Figure(data=[go.Candlestick(\n",
|
|||
|
" x=df_yearly['Date'],\n",
|
|||
|
" open=df_yearly['Open'],\n",
|
|||
|
" high=df_yearly['High'],\n",
|
|||
|
" low=df_yearly['Low'],\n",
|
|||
|
" close=df_yearly['Close'],\n",
|
|||
|
" name='Candlestick',\n",
|
|||
|
" increasing_line_color='green', # Увеличивающиеся свечи зелёные\n",
|
|||
|
" decreasing_line_color='red' # Уменьшающиеся свечи красные\n",
|
|||
|
")])\n",
|
|||
|
"\n",
|
|||
|
"# Обновляем метки и заголовок\n",
|
|||
|
"fig.update_layout(\n",
|
|||
|
" title='Свечной график акций Yamana Gold Inc. за каждый год',\n",
|
|||
|
" title_x=0.5, # Центруем заголовок\n",
|
|||
|
" xaxis_title='Год',\n",
|
|||
|
" yaxis_title='Цена ($)',\n",
|
|||
|
" xaxis_rangeslider_visible=False,\n",
|
|||
|
" plot_bgcolor='rgba(240, 240, 240, 0.95)', # Цвет фона графика\n",
|
|||
|
" xaxis=dict(showgrid=True, gridcolor='LightGray'), # Сетка по оси X\n",
|
|||
|
" yaxis=dict(showgrid=True, gridcolor='LightGray') # Сетка по оси Y\n",
|
|||
|
")\n",
|
|||
|
"\n",
|
|||
|
"\n",
|
|||
|
"# Показываем график\n",
|
|||
|
"fig.show()"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "markdown",
|
|||
|
"metadata": {},
|
|||
|
"source": [
|
|||
|
"#### График динамики объемов торгов акций Yamana Gold Inc. \n",
|
|||
|
"Данный график отображает динамику объемов торгов на акции компании, что позволяет сделать вывод о том, что на момент 2022 года объем продаж рос, следовательно у компании сейчас успешные времена, т.к. их акции пользуются популярностью"
|
|||
|
]
|
|||
|
},
|
|||
|
{
|
|||
|
"cell_type": "code",
|
|||
|
"execution_count": 14,
|
|||
|
"metadata": {},
|
|||
|
"outputs": [
|
|||
|
{
|
|||
|
"data": {
|
|||
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAABW4AAAKyCAYAAABFb0fEAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjkuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8hTgPZAAAACXBIWXMAAA9hAAAPYQGoP6dpAAEAAElEQVR4nOzdeXgTVdvH8V+60lLKWvalUJBNFgFRQAQFZFdA4VFRiiiooIAKAvoqIAoiPooL8LgCKqigghuyqSAiCihFEJCtZUd2CpSumfeP2tA0aZu0aTNNv5/r6tVk5szMPZM5M5M7Z85YDMMwBAAAAAAAAAAwDT9vBwAAAAAAAAAAsEfiFgAAAAAAAABMhsQtAAAAAAAAAJgMiVsAAAAAAAAAMBkStwAAAAAAAABgMiRuAQAAAAAAAMBkSNwCAAAAAAAAgMmQuAUAAAAAAAAAkyFxCwCAE+fOndPevXuVmprq7VAAAAAAAMUQiVsAACSlpKTopZdeUrNmzRQcHKyyZcuqXr16+v77770dGuAxH330keLi4mzv582bpyNHjngvIOSoY8eO6tixY67l1qxZI4vFojVr1hR4TDCnb775RjExMbb3S5cu1V9//eW9gOCSw4cPa968ebb3cXFxWrBggfcCKkI4nwEoLkjcAkAh+uyzz2SxWJz+XX311d4Or9hKSkpS586d9cwzz6hjx45avHixVq1apR9++EFt2rTxdniAx6xbt05PPvmk4uLitGLFCo0YMUJ+fjlfDn7yySeyWCx66623nI5/+OGHFRgYqK1btxZEyEXG119/rd69e6tSpUoKCgpSuXLldOONN+q///2v4uPjvR2epPTEhsVi0ebNm70dSr5ERkY6PY8+9NBD3g7Na7Zt26ZRo0Zpz549+vXXX/XQQw/pwoUL3g4LubBYLBoxYoRWrFihuLg4Pfnkk1q3bp23wyoS8nI+A4CiKMDbAQBAcfTUU0+pYcOGtvcvvPCCF6PB9OnT9dtvv2nFihUutW4DiqrHHntMHTt2VO3atSVJjz/+uKpUqZLj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jVrltq1a6dNmzbpqquuUrdu3VShQgVJ6V8QlyxZkut6/fDDD+revbtatmypiRMnys/PT3PnztXNN9+sdevWqXXr1nblL1y4oG+++UZ9+/a1DZs7d65KlCjh8AXLlXXL0KBBAz399NMyDEP79u3TK6+8oh49eujgwYO5rkP16tUdPsNly5bp448/dii7Z88e/ec//9FDDz2k6OhozZ07V/3799fy5cvVpUsXSdI///yjtm3bKiEhQSNHjlT58uU1f/583Xrrrfrss8/s1j2zOXPm2PaLCRMmOIx3db9+//33dfPNN6tnz5767bffVLZsWYd5bdy4UdHR0Xrsscf04IMP5rh99u/fr6VLl6p///6qXbu2/vnnH7311lvq0KGDduzYoapVqzqdLrt9Pr9SU1PtvrTnZO/evXrnnXdcnvdjjz2mBQsW6OGHH9by5cv17LPP6s4771S3bt106tQpt+rqggULlJycrEcffVRnzpzRSy+9pAEDBujmm2/WmjVrNG7cOO3du1dvvPGGxowZo/fff9827bx58xQWFqbHH39cYWFh+uGHH/Tss88qPj5eM2bMsFvO2bNn1a1bN/Xr108DBgzQZ599pnHjxqlJkybq3r27pPwdZ37++WedO3dOY8aMkb+/v8vb8oEHHtD8+fN1xx136IknntBvv/2madOmaefOnTkeWy5fvqxOnTrp4MGDGjlypKpWraoPP/xQP/zwg8vLdiYtLU1du3bVddddp5dfflmrV6/Wf//7X0VFRenhhx+2lcvoEqJ79+564IEHlJqaqnX
|
|||
|
"text/plain": [
|
|||
|
"<Figure size 1400x700 with 1 Axes>"
|
|||
|
]
|
|||
|
},
|
|||
|
"metadata": {},
|
|||
|
"output_type": "display_data"
|
|||
|
}
|
|||
|
],
|
|||
|
"source": [
|
|||
|
"import pandas as pd\n",
|
|||
|
"import matplotlib.pyplot as plt\n",
|
|||
|
"\n",
|
|||
|
"# Считываем данные\n",
|
|||
|
"df = pd.read_csv(\".//static//csv//Stocks.csv\")\n",
|
|||
|
"\n",
|
|||
|
"# Преобразуем колонку 'Date' в формат datetime\n",
|
|||
|
"df['Date'] = pd.to_datetime(df['Date'])\n",
|
|||
|
"\n",
|
|||
|
"# Устанавливаем дату в качестве индекса\n",
|
|||
|
"df.set_index('Date', inplace=True)\n",
|
|||
|
"\n",
|
|||
|
"# Рассчитываем 12-месячную скользящую среднюю для объемов продаж\n",
|
|||
|
"df['Volume_SMA'] = df['Volume'].rolling(window=60).mean()\n",
|
|||
|
"\n",
|
|||
|
"# Создаем график объемов продаж\n",
|
|||
|
"plt.figure(figsize=(14, 7))\n",
|
|||
|
"plt.plot(df.index, df['Volume'], label='Объем продаж', color='orange', alpha=0.5)\n",
|
|||
|
"plt.plot(df.index, df['Volume_SMA'], label='5-летняя скользящая средняя', color='blue', linewidth=2)\n",
|
|||
|
"\n",
|
|||
|
"# Настройки графика\n",
|
|||
|
"plt.title('Динамика объемов продаж акций Yamana Gold Inc. с 5-летней скользящей средней')\n",
|
|||
|
"plt.xlabel('Дата')\n",
|
|||
|
"plt.ylabel('Объем продаж')\n",
|
|||
|
"plt.legend()\n",
|
|||
|
"plt.grid()\n",
|
|||
|
"plt.xticks(rotation=45) # Поворачиваем метки по оси X для удобства\n",
|
|||
|
"plt.tight_layout() # Подгоняем график\n",
|
|||
|
"\n",
|
|||
|
"# Показать график\n",
|
|||
|
"plt.show()"
|
|||
|
]
|
|||
|
}
|
|||
|
],
|
|||
|
"metadata": {
|
|||
|
"kernelspec": {
|
|||
|
"display_name": "aimenv",
|
|||
|
"language": "python",
|
|||
|
"name": "python3"
|
|||
|
},
|
|||
|
"language_info": {
|
|||
|
"codemirror_mode": {
|
|||
|
"name": "ipython",
|
|||
|
"version": 3
|
|||
|
},
|
|||
|
"file_extension": ".py",
|
|||
|
"mimetype": "text/x-python",
|
|||
|
"name": "python",
|
|||
|
"nbconvert_exporter": "python",
|
|||
|
"pygments_lexer": "ipython3",
|
|||
|
"version": "3.12.5"
|
|||
|
}
|
|||
|
},
|
|||
|
"nbformat": 4,
|
|||
|
"nbformat_minor": 2
|
|||
|
}
|