Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Term Entry] Python Plotly- graph_objects .Candlestick() #5819

Merged
merged 21 commits into from
Dec 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
3d161b7
New file has been added.
SaviDahegaonkar Aug 6, 2024
5a211ba
Update user-input.md
cigar-galaxy82 Sep 8, 2024
38a6c7b
Merge branch 'main' into main
cigar-galaxy82 Sep 8, 2024
5923e4e
Update user-input.md
cigar-galaxy82 Sep 8, 2024
3e57a05
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Oct 16, 2024
7fd94ae
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Oct 17, 2024
ba4692a
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Oct 17, 2024
ea09cd7
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Nov 19, 2024
8ef7979
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Dec 2, 2024
4c5cfc5
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Dec 3, 2024
80df0b6
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Dec 7, 2024
fbcbbfb
Merge branch 'Codecademy:main' into main
SaviDahegaonkar Dec 13, 2024
6e15a39
File has been modified.
SaviDahegaonkar Dec 14, 2024
0a07c63
Image has been added successfully.
SaviDahegaonkar Dec 16, 2024
36d5068
Update content/plotly/concepts/graph-objects/terms/candlestick/candle…
SaviDahegaonkar Dec 18, 2024
dbbc967
Update content/plotly/concepts/graph-objects/terms/candlestick/candle…
SaviDahegaonkar Dec 18, 2024
45b8036
Update content/plotly/concepts/graph-objects/terms/candlestick/candle…
SaviDahegaonkar Dec 18, 2024
04565b4
Made the changes to the file.
SaviDahegaonkar Dec 18, 2024
14664c0
Changes implemeted.
SaviDahegaonkar Dec 20, 2024
9762b03
Update candlestick.md
mamtawardhani Dec 21, 2024
0e9e70b
Merge branch 'main' into graphcandle
mamtawardhani Dec 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
---
Title: '.Candlestick()'
Description: 'Creates candlestick charts to visualize financial data, showing open, high, low, and close values over time.'
Subjects:
- 'Data Science'
- 'Data Visualization'
Tags:
- 'Data'
- 'Finance'
- 'Plotly'
- 'Graphs'
- 'Data Visualization'
CatalogContent:
- 'learn-python-3'
- 'paths/data-visualization'
---

The **`.Candlestick()`** method in Plotly's [`graph_objects`](https://www.codecademy.com/resources/docs/plotly/graph-objects) module is used to create candlestick charts, widely used for visualizing financial data. A candlestick chart displays four key data points for a specific time period:

1. **Open**: The starting value of the asset.
2. **High**: The highest value achieved during the time period.
3. **Low**: The lowest value during the period.
4. **Close**: The final value of the asset.

Candlestick charts are commonly used to identify trends and patterns in stock prices and forex, helping analysts and traders visualize market behavior and make informed decisions.

## Syntax

```pseudo
import plotly.graph_objects as go

go.Candlestick(x=None, open=None, high=None, low=None, close=None, increasing=None, ...)
```

- `x`: Represents the x-axis values, typically dates or time intervals for the candlestick chart.
- `open`: Represents the opening price of the asset for each time period.
- `high`: Represents the highest price of the asset for each time period.
- `low`: Represents the lowest price of the asset for each time period.
- `close`: Represents the closing price of the asset for each time period.
- `increasing`: Customizes the appearance of candles in cases where the closing price is higher than the opening price. The line color, width, or other styles can be defined.

> **Note**: The ellipsis (`...`) indicates that additional optional parameters can be specified to customize the candlestick chart further.

## Example

The following code example creates a candlestick chart using Plotly's `.candlestick()` method. The x-axis represents dates or time periods, and the y-axis displays the opening, highest, lowest, and closing prices for each time period.

```py
import plotly.graph_objects as go

# Sample data
dates = ['2024-12-01', '2024-12-02', '2024-12-03']
open_prices = [100, 105, 110]
high_prices = [110, 115, 120]
low_prices = [95, 100, 105]
close_prices = [105, 110, 115]

# Create the figure
fig = go.Figure(data=[go.Candlestick(
# Dates or time periods for the x-axis.
x=dates,
# Opening prices for each date.
open=open_prices,
# Highest prices for each date.
high=high_prices,
# Lowest prices for each date.
low=low_prices,
# Closing prices for each date.
close=close_prices
)])

# Customize layout
fig.update_layout(
title='Sample Candlestick Chart',
xaxis_title='Date',
yaxis_title='Price',
xaxis_rangeslider_visible=False
)

# Display the figure
fig.show()
```

This example generates an interactive candlestick chart that displays the price movements over specific dates.

The above code generates the following output:

![Candlestick example Plotly](https://raw.githubusercontent.com/Codecademy/docs/main/media/candlestick-example.png)
Binary file added media/candlestick-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading