Last active
August 24, 2017 14:29
-
-
Save sen-saven/d24647f0ac25275fe6a190ca9c2e2336 to your computer and use it in GitHub Desktop.
Interactive Brokers API webinar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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