From 3539c9f18019f5605dc5f65c779248c5611f3793 Mon Sep 17 00:00:00 2001 From: michaelbabyn Date: Thu, 25 Apr 2019 16:41:42 -0400 Subject: [PATCH] update candlestick charts doc in python to use candlestick trace. --- .../2015-06-30-candlestick-charts.html | 107 +++++++++++------- .../candlestick/candlestick-charts.ipynb | 91 ++++++++------- 2 files changed, 114 insertions(+), 84 deletions(-) diff --git a/_posts/python/financial/candlestick/2015-06-30-candlestick-charts.html b/_posts/python/financial/candlestick/2015-06-30-candlestick-charts.html index 1667529e229b..8f1b70d83fd7 100755 --- a/_posts/python/financial/candlestick/2015-06-30-candlestick-charts.html +++ b/_posts/python/financial/candlestick/2015-06-30-candlestick-charts.html @@ -10,12 +10,13 @@ has_thumbnail: true display_as: financial order: 2 -ipynb: ~notebook_demo/152 +ipynb: ~notebook_demo/275 layout: user-guide --- {% raw %}
-
+
+

New to Plotly?

Plotly's Python library is free and open source! Get started by downloading the client and reading the primer.
You can set up Plotly to work in online or offline mode, or in jupyter notebooks. @@ -27,14 +28,14 @@

Version Check
-
In [2]:
+
In [1]:
import plotly
 plotly.__version__
 
-
+
@@ -44,13 +45,13 @@

Version Check -
Out[2]:
+
Out[1]:
-
'3.4.1'
+
'3.8.1'

@@ -60,7 +61,8 @@

Version Check
-
+
+
@@ -98,7 +100,7 @@

Simple Candlestick with Pandas -
Out[1]:
+
Out[2]:
@@ -113,7 +115,8 @@

Simple Candlestick with Pandas
-
+
+
@@ -177,7 +180,8 @@

Candlestick without Rangeslider
-
+
+
@@ -185,7 +189,7 @@

Adding Customized Text and Annot

-
In [5]:
+
In [4]:
import plotly.plotly as py
@@ -196,7 +200,7 @@ 

Adding Customized Text and Annot df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv') -trace = go.Ohlc(x=df['Date'], +trace = go.Candlestick(x=df['Date'], open=df['AAPL.Open'], high=df['AAPL.High'], low=df['AAPL.Low'], @@ -220,7 +224,7 @@

Adding Customized Text and Annot py.iplot(fig, filename='aapl-recession-candlestick')

-
+
@@ -230,7 +234,7 @@

Adding Customized Text and Annot
-
Out[5]:
+
Out[4]:
@@ -245,7 +249,8 @@

Adding Customized Text and Annot

-
+
+ @@ -285,7 +292,7 @@

Custom Candlestick Colors -
Out[7]:
+
Out[5]:
@@ -300,7 +307,8 @@

Custom Candlestick Colors
-
+
+
@@ -308,7 +316,7 @@

Simple Example with datetime

-
In [8]:
+
In [6]:
import plotly.plotly as py
@@ -335,7 +343,7 @@ 

Simple Example with datetime py.iplot(data, filename='candlestick_datetime')

-
+
@@ -345,7 +353,7 @@

Simple Example with datetime
-
Out[8]:
+
Out[6]:
@@ -360,7 +368,8 @@

Simple Example with datetime

-
+
+

Dash Example

@@ -368,14 +377,14 @@

Dash Example&#

-
In [3]:
+
In [7]:
from IPython.display import IFrame
 IFrame(src= "https://dash-simple-apps.plotly.host/dash-candlestickplot/", width="100%", height="750px", frameBorder="0")
 
-
+
@@ -385,7 +394,7 @@

Dash Example&# +
+
+
-

Find the dash app source codehere.

+

Reference

For more information on candlestick attributes, see: https://plot.ly/python/reference/#candlestick

diff --git a/_posts/python/financial/candlestick/candlestick-charts.ipynb b/_posts/python/financial/candlestick/candlestick-charts.ipynb index afcde4ada4a2..8c395dd30d60 100755 --- a/_posts/python/financial/candlestick/candlestick-charts.ipynb +++ b/_posts/python/financial/candlestick/candlestick-charts.ipynb @@ -14,16 +14,16 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 1, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'3.4.1'" + "'3.8.1'" ] }, - "execution_count": 2, + "execution_count": 1, "metadata": {}, "output_type": "execute_result" } @@ -42,7 +42,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 2, "metadata": {}, "outputs": [ { @@ -51,10 +51,10 @@ "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 1, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -68,7 +68,7 @@ "\n", "df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n", "\n", - "trace = go.Ohlc(x=df['Date'],\n", + "trace = go.Candlestick(x=df['Date'],\n", " open=df['AAPL.Open'],\n", " high=df['AAPL.High'],\n", " low=df['AAPL.Low'],\n", @@ -86,19 +86,19 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "" + "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 4, + "execution_count": 3, "metadata": {}, "output_type": "execute_result" } @@ -112,7 +112,7 @@ "\n", "df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n", "\n", - "trace = go.Ohlc(x=df['Date'],\n", + "trace = go.Candlestick(x=df['Date'],\n", " open=df['AAPL.Open'],\n", " high=df['AAPL.High'],\n", " low=df['AAPL.Low'],\n", @@ -129,7 +129,7 @@ "data = [trace]\n", "\n", "fig = go.Figure(data=data,layout=layout)\n", - "py.iplot(fig, filename='simple_candlestick')" + "py.iplot(fig, filename='simple_candlestick_without_range_slider')" ] }, { @@ -141,7 +141,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -150,10 +150,10 @@ "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -167,7 +167,7 @@ "\n", "df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n", "\n", - "trace = go.Ohlc(x=df['Date'],\n", + "trace = go.Candlestick(x=df['Date'],\n", " open=df['AAPL.Open'],\n", " high=df['AAPL.High'],\n", " low=df['AAPL.Low'],\n", @@ -200,7 +200,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": {}, "outputs": [ { @@ -209,10 +209,10 @@ "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 7, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -226,13 +226,15 @@ "\n", "df = pd.read_csv('https://raw.githubusercontent.com/plotly/datasets/master/finance-charts-apple.csv')\n", "\n", - "trace = go.Ohlc(x=df['Date'],\n", - " open=df['AAPL.Open'],\n", - " high=df['AAPL.High'],\n", - " low=df['AAPL.Low'],\n", - " close=df['AAPL.Close'],\n", - " increasing=dict(line=dict(color= '#17BECF')),\n", - " decreasing=dict(line=dict(color= '#7F7F7F')))\n", + "trace = go.Candlestick(\n", + " x=df['Date'],\n", + " open=df['AAPL.Open'],\n", + " high=df['AAPL.High'],\n", + " low=df['AAPL.Low'],\n", + " close=df['AAPL.Close'],\n", + " increasing=dict(line=dict(color= '#17BECF')),\n", + " decreasing=dict(line=dict(color= '#7F7F7F'))\n", + ")\n", "data = [trace]\n", "py.iplot(data, filename='styled_candlestick')" ] @@ -246,7 +248,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -255,10 +257,10 @@ "" ], "text/plain": [ - "" + "" ] }, - "execution_count": 8, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -297,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -314,10 +316,10 @@ " " ], "text/plain": [ - "" + "" ] }, - "execution_count": 3, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -344,7 +346,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -376,16 +378,18 @@ "output_type": "stream", "text": [ "Collecting git+https://github.com/plotly/publisher.git\n", - " Cloning https://github.com/plotly/publisher.git to /private/var/folders/s5/vjqn03zs7nn8zs_fwzcf14r40000gn/T/pip-req-build-t03_xthe\n", + " Cloning https://github.com/plotly/publisher.git to /tmp/pip-req-build-x3rbgz9k\n", "Building wheels for collected packages: publisher\n", - " Building wheel for publisher (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25h Stored in directory: /private/var/folders/s5/vjqn03zs7nn8zs_fwzcf14r40000gn/T/pip-ephem-wheel-cache-bq2bpl5x/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", + " Running setup.py bdist_wheel for publisher ... \u001b[?25ldone\n", + "\u001b[?25h Stored in directory: /tmp/pip-ephem-wheel-cache-si2jei04/wheels/99/3e/a0/fbd22ba24cca72bdbaba53dbc23c1768755fb17b3af0f33966\n", "Successfully built publisher\n", "Installing collected packages: publisher\n", " Found existing installation: publisher 0.13\n", " Uninstalling publisher-0.13:\n", " Successfully uninstalled publisher-0.13\n", - "Successfully installed publisher-0.13\n" + "Successfully installed publisher-0.13\n", + "\u001b[33mYou are using pip version 10.0.1, however version 19.1 is available.\n", + "You should consider upgrading via the 'pip install --upgrade pip' command.\u001b[0m\n" ] } ], @@ -404,8 +408,15 @@ " title = 'Python Candlestick Charts | plotly',\n", " thumbnail='thumbnail/candlestick.jpg', language='python',\n", " page_type='example_index', has_thumbnail='true', display_as='financial', order=2,\n", - " ipynb= '~notebook_demo/152')" + " ipynb= '~notebook_demo/275')" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { @@ -425,7 +436,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.2" + "version": "3.6.5" } }, "nbformat": 4,