mirror of
https://github.com/dupenf/stock-lstm.git
synced 2024-11-25 16:22:36 +08:00
45 lines
1.1 KiB
Python
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() |