绘制股票K线图并过滤非交易时间
在进行股票数据分析或者交易策略制定的过程中,绘制K线图是非常重要的一步。而使用plotly库可以方便地绘制交互式K线图,并且结合pandas中的DataFrame可以轻松实现数据的预处理和过滤,以满足不同需求。
本文将介绍如何使用plotly和pandas绘制股票K线图,并且在此基础上对非交易时间进行过滤,保证绘制的K线图准确反映市场实际情况。
首先需要安装必要的库:
!pip install plotly pandas pandas_market_calendars
接着,加载所需的库:
import pandas as pd
import plotly.graph_objects as go
from pandas_market_calendars import get_calendar
我们这里使用了pandas_market_calendar
本文介绍了如何结合plotly、pandas和pandas_market_calendars库绘制股票K线图,并过滤非交易时间。通过读取股票交易数据,获取交易日历,利用pandas的loc函数筛选交易数据,最后用plotly绘制准确反映市场实际情况的交互式K线图。
订阅专栏 解锁全文
1278

被折叠的 条评论
为什么被折叠?



