New Forum

Visit the new forum at

Sunday, August 26, 2012


Want to watch a replay of the day?

Using the tick data from one could take each data line and print it on the screen at the time the trade was initiated.

Given the smallest interval is a second, in my version of the program below, I divide the second up by however many orders are placed, and then equally spread them throughout the second. Unfortunately, outside of regular trading hours certain seconds have no data. These gaps aren't accounted for in the program below. So going from 15:00:37 to 15:00:49, assuming no data in between, only takes 1 second rather than the 12 seconds it should take. But, given this type of program would generally be used to replay a trading day, I don't think these outside hours matter too much. I'll leave that for a future iteration.

The goal is to ultimately allow for replays at various speeds (1x, 2x, 5x the regular trading day), print the quotes on a graph and allow for sim trading through virtual order tracking. Lots more could be added, such as visual backtesting, but I'll save that for when I get some more of the basics done...

Here's the code:
import string
from time import sleep

f = open('gx120823/ES-2012-09.txt', 'r')

time_data = []
price_data = []
volume_data = []
oldtimeInfo = '15:00:00'

for line in f:
    line_split = string.split(line,',')
    timeInfo = '%s' % str(line_split[3])
    if oldtimeInfo == timeInfo:
        time_data = time_data + [str(line_split[3])]
        price_data = price_data + [float(line_split[4])]
        volume_data = volume_data + [int(line_split[5])]
    if oldtimeInfo != timeInfo:
        sleep_time = float(len(time_data))
        #print 'sleep_time is ', sleep_time
        j = 0
        for i in time_data:
            print i, '|', price_data[j], '|', volume_data[j]
            j = j + 1
            #print float(1/sleep_time)
        time_data = [str(line_split[3])]
        price_data = [float(line_split[4])]
        volume_data = [int(line_split[5])]
    oldtimeInfo = timeInfo

No comments:

Post a Comment