从Pandas DataFrame绘制OLHCV,颜色蜡烛和体积作为水平线

时间:2019-10-22 06:31:41

标签: python python-3.x pandas matplotlib candlestick-chart

我有一个如下数据框:

        Symbol            DateTime      open      high       low     close   volume
0    BANKNIFTY 2019-09-09 09:15:00  27266.20  27266.20  27063.20  27115.00  19200.0
1    BANKNIFTY 2019-09-09 09:16:00  27112.85  27118.90  27096.10  27101.95   6820.0
2    BANKNIFTY 2019-09-09 09:17:00  27105.00  27142.35  27105.00  27135.95      0.0
3    BANKNIFTY 2019-09-09 09:18:00  27130.55  27140.00  27106.95  27113.00  12560.0
4    BANKNIFTY 2019-09-09 09:19:00  27113.55  27113.55  27077.00  27090.55      0.0
5    BANKNIFTY 2019-09-09 09:20:00  27083.05  27083.05  27039.15  27071.85  21260.0
6    BANKNIFTY 2019-09-09 09:21:00  27079.00  27099.00  27070.55  27080.00   2720.0
7    BANKNIFTY 2019-09-09 09:22:00  27082.45  27091.60  27071.05  27088.65      0.0
8    BANKNIFTY 2019-09-09 09:23:00  27086.65  27099.40  27081.20  27088.70      0.0
9    BANKNIFTY 2019-09-09 09:24:00  27085.45  27094.00  27079.95  27084.90      0.0
10   BANKNIFTY 2019-09-09 09:25:00  27084.90  27084.90  27070.00  27074.85      0.0
11   BANKNIFTY 2019-09-09 09:26:00  27074.85  27080.00  27070.00  27074.00      0.0
12   BANKNIFTY 2019-09-09 09:27:00  27073.05  27075.00  27065.70  27066.05      0.0
13   BANKNIFTY 2019-09-09 09:28:00  27066.05  27086.65  27062.00  27084.90      0.0
14   BANKNIFTY 2019-09-09 09:29:00  27085.45  27108.80  27080.05  27101.25      0.0
15   BANKNIFTY 2019-09-09 09:30:00  27100.00  27100.85  27076.00  27079.50   2900.0
16   BANKNIFTY 2019-09-09 09:31:00  27079.00  27114.00  27079.00  27113.95   3900.0
17   BANKNIFTY 2019-09-09 09:32:00  27110.00  27118.95  27102.70  27103.30      0.0

我想在以下条件下使用matplotlib在OLHCV中绘制数据:

  
      
  1. 关闭>打开,然后蜡烛颜色=绿色
  2.   
  3. 关闭的地方<打开然后的蜡烛颜色=红色
  4.   
  5. 如果体积为非零,则蜡烛颜色=蓝色
  6.   
  7. 将容积蜡烛(仅适用于非零容积值)绘制为水平线,从右侧到当前蜡烛收盘价,并在该行顶部写入容积值
  8.   

任何帮助...

样本输出将类似于: Output

0 个答案:

没有答案