Keyboard Shortcuts
Likes
Search
Find stock with ISIN given (VBA)
¿ªÔÆÌåÓýHello, ? I finally found the time to check out this method but I haven?t been successful yet. ? Below you can see the code I used to get the stock information with the ISIN given. ? Unfortunately I always receive the error message ¡°Argument is not optional¡±. ? I tried many variations but I haven?t been able to find out which argument is missing. ? Does someone have an idea which argument is missing? ? Sub stockSearch() ? Set ObjTWSControl.m_contractInfo = ObjTWSControl.m_TWSControl.createContract() ? With ObjTWSControl.m_contractInfo ?????????????? ????????????????.symbol = "" ??????????????? .secType = "STK" ??????????????? .secId = "DE000A0Z2ZZ5" ??????????????? .secIdType = "ISIN" ??????????????? .lastTradeDateOrContractMonth = "" ??????????????? .strike = "" ??????????????? .right = "" ??????????????? .primaryExchange = "IBIS" ??????????????? .exchange = "IBIS" ??????????????? .currency = "EUR" ??????????????? .localSymbol = "" ??????????????? .marketName = "" ??????????????? .tradingClass = "" ??????????????? .conId = "" ??????????????? .minTick = "" ??????????????? .priceMagnifier = "" ??????????????? .multiplier = "" ??????????????? .orderTypes = "" ??????????????? .validExchanges = "" ? End With ? Call ObjTWSControl.m_TWSControl.reqContractDetails(id, ObjTWSControl.m_contractInfo) ? End Sub ? ? ? ? Von: [email protected] <[email protected]> Im Auftrag von corneliu maftuleac ? Actually I was referring to python api from ib_insync. Dim contract As Contract = New Contract() contract.SecIdType = "ISIN" contract.SecId = "US03076KAA60"
|
¿ªÔÆÌåÓýFirst, you absolutely need to understand how to use the Object Browser, which enables you to examine all the API classes, and their methods and properties in great detail. ? Also when you're typing your VBA code, you get a lot of Intelli-something which is a great help to knowing whether you're entering the right parameters etc. ? You then end up with something like the code below (note however that there's no point including all the lines that just set an empty string, I've just left them there because you had put them in). I've no idea whether this will actually work, I've never used ISINs, but at least it should be the right syntax. ? Also note that primaryExchange is only used when exchange="SMART", so you should remove the line that sets it. ? Actually I made the same request using the VB Sample app in C:\Projects1\tws-api\samples\VB\VB_API_Sample (which is extremely useful for checking out this sort of thing, if very clumsy). It returns the contract details with no problem. ? ? Sub stockSearch() ? Dim lContractInfo As TWSLib.ComContract Set lContractInfo = ObjTWSControl.createContract() ? With lContractInfo ?????????????? ????????????????.Symbol = "" ??????????????? .SecType = "STK" ??????????????? .secId = "DE000A0Z2ZZ5" ??????????????? .secIdType = "ISIN" ??????????????? .lastTradeDateOrContractMonth = "" ??????????????? .Strike = "" ??????????????? .Right = "" ??????????????? .primaryExchange = "IBIS" ??????????????? .exchange = "IBIS" ??????????????? .currency = "EUR" ??????????????? .localSymbol = "" ??????????????? .marketName = "" ??????????????? .tradingClass = "" ??????????????? .conId = "" ??????????????? .minTick = "" ??????????????? .priceMagnifier = "" ??????????????? .multiplier = "" ??????????????? .orderTypes = "" ??????????????? .validExchanges = "" ? End With ? Call ObjTWSControl.reqContractDetailsEx(id, lContractInfo) ? End Sub ? ? ? ? From: [email protected] <[email protected]> On Behalf Of ApiMadness
Sent: 07 January 2021 22:48 To: [email protected] Subject: Re: [TWS API] Find stock with ISIN given (VBA) ? Hello, ? I finally found the time to check out this method but I haven?t been successful yet. ? Below you can see the code I used to get the stock information with the ISIN given. ? Unfortunately I always receive the error message ¡°Argument is not optional¡±. ? I tried many variations but I haven?t been able to find out which argument is missing. ? Does someone have an idea which argument is missing? ? Sub stockSearch() ? Set ObjTWSControl.m_contractInfo = ObjTWSControl.m_TWSControl.createContract() ? With ObjTWSControl.m_contractInfo ?????????????? ????????????????.symbol = "" ??????????????? .secType = "STK" ??????????????? .secId = "DE000A0Z2ZZ5" ??????????????? .secIdType = "ISIN" ??????????????? .lastTradeDateOrContractMonth = "" ??????????????? .strike = "" ??????????????? .right = "" ??????????????? .primaryExchange = "IBIS" ??????????????? .exchange = "IBIS" ??????????????? .currency = "EUR" ??????????????? .localSymbol = "" ??????????????? .marketName = "" ??????????????? .tradingClass = "" ??????????????? .conId = "" ??????????????? .minTick = "" ??????????????? .priceMagnifier = "" ??????????????? .multiplier = "" ??????????????? .orderTypes = "" ??????????????? .validExchanges = "" ? End With ? Call ObjTWSControl.m_TWSControl.reqContractDetails(id, ObjTWSControl.m_contractInfo) ? End Sub ? ? ? ? Von: [email protected] <[email protected]> Im Auftrag von corneliu maftuleac ? Actually I was referring to python api from ib_insync. Dim contract As Contract = New Contract() contract.SecIdType = "ISIN" contract.SecId = "US03076KAA60"
|