Introduction to Candlestick Bars in Market Data for Algo Programmers

In this video, we introduce you to Candlestick Bars, a store of Historic Market Data, how to access that data via Pythons Lists and how pointers work in lists.

The following code in Python will work with CloudQuant’s backtesting simulation environment to see the bar data.


 # Python Code to retreive information about the symbol and the daily bars market data.
 print self.symbol
 print
 print "Open 1 day ago",daily_bars.open[-1]
 print "High 1 day ago",daily_bars.high[-1]
 print "Low 1 day ago",daily_bars.low[-1]
 print "Close 1 day ago",daily_bars.close[-1]
 print "Volume 1 day ago",daily_bars.volume[-1]
 print
 print "Close 1 day ago",daily_bars.close[-1]
 print "Close 2 days ago",daily_bars.close[-2]
 print "Close 3 days ago",daily_bars.close[-3]
 print "Close 4 days ago",daily_bars.close[-4]
 print "Close 5 days ago",daily_bars.close[-5]
 print
 print "Close for all fetched bars",daily_bars.close[:]
 print
 print "Average Volume for all fetched bars",sum(daily_bars.volume)/len(daily_bars.volume)
 print
 print "Average Volume for most recent 10 bars",sum(daily_bars.volume[-10:])/len(daily_bars.volume[-10:])
 print
 print "Average Volume for 10 bars before that",sum(daily_bars.volume[-20:-10])/len(daily_bars.volume[-20:-10])
 print

Output for symbol Google.

GOOG

Open   1 day ago 1042.68005371
High   1 day ago 1044.07995605
Low    1 day ago 1015.65002441
Close  1 day ago 1021.65997314
Volume 1 day ago 2459426

Close  1 day  ago 1021.65997314
Close  2 days ago 1047.41003418
Close  3 days ago 1054.20996094
Close  4 days ago 1040.60998535
Close  5 days ago 1035.95996094

Close for all fetched bars [ 1025.5         1025.57995605  1032.47998047  1025.90002441  1033.32995605
  1039.84997559  1031.26000977  1028.06994629  1025.75        1026.
  1020.90997314  1032.5         1019.09002686  1018.38000488  1034.48999023
  1035.95996094  1040.60998535  1054.20996094  1047.41003418  1021.65997314]

Average Volume for all fetched bars 1131964

Average Volume for most recent 10 bars 1194879

Average Volume for 10 bars before that 1069049