Skip to content

Instantly share code, notes, and snippets.

@sen-saven
Last active August 24, 2017 14:29
Show Gist options
  • Select an option

  • Save sen-saven/d24647f0ac25275fe6a190ca9c2e2336 to your computer and use it in GitHub Desktop.

Select an option

Save sen-saven/d24647f0ac25275fe6a190ca9c2e2336 to your computer and use it in GitHub Desktop.
Interactive Brokers API webinar
from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.common import *
from ibapi.contract import *
class TestApp(EClient, EWrapper):
def __init__(self):
EClient.__init__(self, self)
def error(self, reqId:TickerId, errorCode:int, errorString:str):
print("Error", reqId, " ", errorCode, " ", errorString)
def contractDetails(self, reqId:int, contractDetails:ContractDetails):
print("Contract Details: ", reqId," ",contractDetails)
def main():
app = TestApp()
app.connect("127.0.0.1",7497,0)
contract = Contract()
contract.symbol = "AAPL"
contract.secType = "STK"
contract.exchange = "SMART"
contract.currency = "USD"
contract.primaryExchange = "NASDAQ"
app.reqContractDetails(10,contract)
app.run()
if __name__== "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment