stock-lstm/d1_showCand.py
2024-08-04 19:05:34 +08:00

45 lines
1.1 KiB
Python

# import requirement libraries and tools
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import torch
import torch.optim as optim
import yfinance as yf
import torch.nn as nn
import torch.functional as F
import plotly.graph_objects as go
from tqdm.notebook import tqdm
from torchsummary import summary
from sklearn.preprocessing import MinMaxScaler
from torch.utils.data import TensorDataset, DataLoader
df = pd.read_csv("./datasets/sh.600000.csv")
# Create a trace for the candlestick chart
candlestick_trace = go.Candlestick(
x=df.index,
open=df['open'],
high=df['high'],
low=df['low'],
close=df['close'],
name='Candlestick'
)
# Create the layout
layout = go.Layout(
title='GOOG Candlestick Chart',
xaxis=dict(title='date'),
yaxis=dict(title='price', rangemode='normal')
)
# Create the figure and add the candlestick trace and layout
fig = go.Figure(data=[candlestick_trace], layout=layout)
# Update the layout of the figure
fig.update_layout(xaxis_rangeslider_visible=False)
# Show the figure
fig.show()