def ori_vs_adj_trade_NVDA():
    dayStartNVDA = '20070910' # Start day
    dayEndNVDA = '20070911' # End day
    
    parentddir1 = os.path.abspath(os.path.join(os.path.dirname(__file__), os.path.pardir))
    parentddir2 = os.path.abspath(os.path.join(parentddir1, os.path.pardir))

    oriTradeStartNVDA = TAQTradesReader(os.path.join(parentddir2, 'R/trades/'+dayStartNVDA+'/NVDA_trades.binRT'))
    oriTradeEndNVDA = TAQTradesReader(os.path.join(parentddir2, 'R/trades/'+dayEndNVDA+'/NVDA_trades.binRT'))
    
    oriPriceNVDA = [] # List to store price
    oriShareNVDA = [] # List to store number of shares
    timeList = [] # List to store time stamp
    
    # Append data to each of the lists
    for i in range(oriTradeStartNVDA.getN()):
        oriPriceNVDA.append(oriTradeStartNVDA.getPrice(i))
        oriShareNVDA.append(oriTradeStartNVDA.getSize(i))
        timeList.append(1189396800000 + oriTradeStartNVDA.getTimestamp(i))
    
        
    for i in range(oriTradeEndNVDA.getN()):
        oriPriceNVDA.append(oriTradeEndNVDA.getPrice(i))
        oriShareNVDA.append(oriTradeEndNVDA.getSize(i))
        timeList.append(1189483200000 + oriTradeEndNVDA.getTimestamp(i))
    
    # convert data format to datetime
    dateTimeList = []
    for timeStamp in timeList:
        dateTimeList.append(datetime.fromtimestamp(timeStamp/1000))
    
    adjTradeStartNVDA = BinReader(os.path.join(os.getcwd(), 'adjusted_trades/NVDA_trades.gz'), '>QIIf', 100)
    ts0, _, size0, p0 = adjTradeStartNVDA.next()
    
    ts = []
    ts.append(ts0)
    share = []
    share.append(size0)
    price = []
    price.append(p0)
    
    while adjTradeStartNVDA.hasNext():
        t, i, s, p = adjTradeStartNVDA.next()
        ts.append(t)
        share.append(s)
        price.append(p)
    
    sIdx = binarySearch(ts, 0, len(ts)-1, timeList[0]) # find the start index
    eIdx = binarySearch(ts, 0, len(ts)-1, timeList[-1])  # find the end index
    
    pList = price[sIdx:eIdx+1]
    sList = share[sIdx:eIdx+1]
    
    adjTradeStartNVDA.close() # close bin reader
      
    plt.figure(figsize=(9,6))
    ax = plt.gca()
    xfmt = mdates.DateFormatter('%m-%d %H:%M')
    ax.xaxis.set_major_formatter(xfmt)
    plt.plot(dateTimeList[:-5], oriPriceNVDA[:-5], ls = 'None', marker = 'o', ms = 5, color = 'y', label = 'original')
    plt.plot(dateTimeList[:-5], pList, ls = 'None', marker = 'x', ms = 2 , color = 'black', label = 'adjusted')
    plt.xticks([datetime.strptime('2007-09-10 10:00:00', '%Y-%m-%d %H:%M:%S'), 
                datetime.strptime('2007-09-10 15:00:00', '%Y-%m-%d %H:%M:%S'),
                datetime.strptime('2007-09-11 09:30:00', '%Y-%m-%d %H:%M:%S'), 
                datetime.strptime('2007-09-11 15:00:00', '%Y-%m-%d %H:%M:%S')])
    plt.title('Original NVDA Trade Price VS Adjusted NVDA Trade Price')
    plt.xlabel('Time')
    plt.ylabel('Price')
    plt.legend()
    plt.show()
     
    plt.figure(figsize=(9,6))
    ax = plt.gca()
    xfmt = mdates.DateFormatter('%m-%d %H:%M')
    ax.xaxis.set_major_formatter(xfmt)
    plt.plot(dateTimeList[:-5], oriShareNVDA[:-5], ls = 'None', marker = 'o', ms = 5, color = 'y', label = 'original')
    plt.plot(dateTimeList[:-5], sList, ls = 'None', marker = 'x', ms = 2 , color = 'black', label = 'adjusted')
    plt.xticks([datetime.strptime('2007-09-10 10:00:00', '%Y-%m-%d %H:%M:%S'), 
                datetime.strptime('2007-09-10 15:00:00', '%Y-%m-%d %H:%M:%S'),
                datetime.strptime('2007-09-11 09:30:00', '%Y-%m-%d %H:%M:%S'), 
                datetime.strptime('2007-09-11 15:00:00', '%Y-%m-%d %H:%M:%S')])
    plt.ylim(0,10000)
    plt.title('Original NVDA Trade Share VS Adjusted NVDA Trade Share')
    plt.xlabel('Time')
    plt.ylabel('Number of Shares')
    plt.legend()
    plt.show()
    def test1(self):
        fileName = 'D:/TAQClean/trades/20070620/IBM_trades.binRT'
        reader = TAQTradesReader( fileName )
        print( reader.getN() )

        print( reader.getTimestamp(1) )