thanks in advance to anyone looking to enlighten me here a little bit since I have been struggling for a solid couple of hours :-(
def pullQueue(eventQueue, barLength):
# Setting start and End times for extractions
startExtract = dt.time(8, 00, 00, 0)
endExtract = dt.time(22, 00, 00, 0)
while dt.datetime.now().time() > startExtract and dt.datetime.now().time() < endExtract:
try:
event = eventQueue.get(False)
except Queue.Empty:
pass
else:
if event is not None:
if event.type == 'TICK':
global ts
ts.append(pd.Series([event.ask], index=[event.time]))
time.sleep(heartbeat)
The above function (an indentation error occurs when copying into Stackoverflow - please simply ignore) pulls a custom object (event) out of a Queue object - if the event is a tick event, it is meant to append the ask variable and the corresponding timestamp (as an index value) to a pandas Series object (see last nested if statement in function).
However, it simply doesn't work, when I try to access the Series ts - it always logs the 'old' Series excluding the appended values. Originally when I tried to build this function I used this link(stackoverflow question) as guidance. I also constructed the nested if statement (below) on a standalone basis and it did work - any ideas?
if event.type == 'TICK':
global ts
ts.append(pd.Series([event.ask], index=[event.time]))
Artem asked a valid question here - I am using threading - see below:
evalThread = threading.Thread(target=pullQueue,args=(eventQueue, barLength))
evalThread.start()