¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Requesting Time and Sales Option Data


 

I am trying to request historical tick data, and compare the last traded to the see if it filled at the bid or ask for all option contracts on an underlying for a full day. I am not sure if anyone knows if this is possible? The code I have now which I am testing on a regular underlying trying to pull tick data? (which returns "None" not sure whats wrong with it.)

this is what I am looking to do with all option contracts at the end of a trading day:?


My test code (not working):
import pandas as pd
import numpy as np
import datetime
import time
import ibapi
from ibapi.client import Contract
from ibapi.client import EClient
from ibapi.wrapper import EWrapper


class IBapi(EWrapper, EClient):
def __init__(self):
EClient.__init__(self, self)

def run_loop():
app.run()

app = IBapi()
app.connect('127.0.0.1', 4002, 2)

time.sleep(1)

apple_contract = Contract()
apple_contract.symbol = 'AAPL'
apple_contract.secType = 'STK'
apple_contract.exchange = 'SMART'
apple_contract.currency = 'USD'

ticks = app.reqHistoricalTicks(1, apple_contract, '', "20201231 09:30:00:000", 100, 'LAST', 1, True, [])
print(ticks)

time.sleep(10)
app.disconnect()


Nick
 

Historical time stamps don't have the resolution to reliably determine trades at bid/ask.

Using live data my preliminary research suggests the order of arrival might allow you to determine trades at bid/ask but you will have to verify if it is good enough for your strategy.

On 1/3/2021 3:26 AM, dominikprocyk@... wrote:
I am trying to request historical tick data, and compare the last traded to the see if it filled at the bid or ask for all option contracts on an underlying for a full day. I am not sure if anyone knows if this is possible? The code I have now which I am testing on a regular underlying trying to pull tick data? (which returns "None" not sure whats wrong with it.)

this is what I am looking to do with all option contracts at the end of a trading day:


 

Interesting, thank you, do you know if there¡¯s a way to export the time and sales data from TWS?