title: Plot intraday candlestick with python
body: <p>I started to create a program for fun that plot intraday candlestick but I struggle with it. If someone can help me with it.</p>
  
  <pre><code>import numpy as np
  import pandas as pd
  
  def main(filename):
      df = pd.read_csv(filename, sep = ',', parse_dates = ['DateTime'])
  
      del df['Tid']
      del df['Dealable']
      del df['Pair']
      del df['Ask']
  
      df = df.set_index(['DateTime'])
  
      df.index = pd.to_datetime(df.index, unit='s')
  
      # group every 1 minutes and create OHLC
      data = df.resample('1Min').ohlc()
  
      # groupe our ohlc data
      ohlc_data = data.reset_index()
      ohlc_data['DateTime'] = ohlc_data['DateTime'].apply(mdates.date2num)
  
      plt.close('all')
      fig = plt.figure()
      ax = plt.subplot2grid((1,1), (0,0))
      ax.xaxis_date()
      ax.xaxis.set_major_formatter(mdates.DateFormatter('%y-%m-%d %H:%M:%S'))
      plt.xticks(rotation=45)
      plt.xlabel("Date")
      plt.ylabel("Price")
      plt.title("EURUSD")
      candlestick_ohlc(ax, ohlc_data.values, width=.6, colorup='#53c156', colordown='#ff1717')
      plt.show()
  
  if __name__ == "__main__":
      main("EUR_USD.csv")
  </code></pre>
  
  <p>The EUR_USD.csv file of form:
  Tid,Dealable,Pair,DateTime,Bid,Ask
  5803730773,D,EUR/USD,2017-04-09 17:00:04.343000000,1.058550,1.059050
  5803730842,D,EUR/USD,2017-04-09 17:00:38.593000000,1.058660,1.058960
  5803730879,D,EUR/USD,2017-04-09 17:00:39.343000000,1.058680,1.058980
  5803730894,D,EUR/USD,2017-04-09 17:00:41.593000000,1.058710,1.058970
  5803731109,D,EUR/USD,2017-04-09 17:01:47.843000000,1.058680,1.058980</p>