Opublikowano:
Aktualizacja:
Wykresy świecowe są jednymi z najbardziej popularnych form wizualizacji danych rynkowych. W Pythonie można importować gotową bibliotekę “plotly”, umożliwiającą rysowanie wykresów świecowych.
Importujemy dane historyczne (tak jak w części 1), następnie wybieramy dla przykładu ostatnich tysiąc świeczek. Dodatkowo usunięto jeszcze kolumnę z wolumenem.
import pandas as pd
import plotly.graph_objects as go
df=pd.read_csv('/content/drive/My Drive/dane_historyczne/dax.csv')
df2=df.drop(['Wolumen'], axis=1)
df2=df2[-1000:]
df2
W praktyce stosowanie daty jako argument jest niewygodne. Dodatkowo pojawiają się luki na wykresie, jeśli rynek był zamknięty. Możemy również posługiwać się numerem indeksu wiersza.
Aby stworzyć nowy wykres świecowy należy wpisać poniższe komendy:
fig = go.Figure(data=[go.Candlestick(x=df3['Data'],
open=df3['Otwarcie'],
high=df3['Najwyzszy'],
low=df3['Najnizszy'],
close=df3['Zamkniecie'])])
fig.show()
Wyświetli nam się wykres świecowy. Na dole wykresu znajduje się suwak, dzięki któremu można powiększyć fragment wykresu.
W praktyce stosowanie daty jako argument jest niewygodne. Dodatkowo pojawiają się luki na wykresie, jeśli rynek był zamknięty. Możemy również posługiwać się numerem indeksu wiersza.
fig = go.Figure(data=[go.Candlestick(x=df2.index,
open=df2['Otwarcie'],
high=df2['Najwyzszy'],
low=df2['Najnizszy'],
close=df2['Zamkniecie'])])
fig.show()
© 2025 All Rights Reserved.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |
Kopiowanie wszystkich kodów tylko dla użytkowników PREMIUM.