You received a lot of valuable feedback, the task you are trying to take on is massive, it will be a nightmare to maintain as a single person over long periods of time, and will possibly be a massive waste of time. I had not heard about PureBasic until your post, so that I am sure there is nobody to help you. And the code ChatGPT generated will not get you anywhere either, But go ahead, if that is what you want to do.
HOWEVER this is not the group to look for help for a task that you have been advised against. We are exclusively focused on the API implementations that IBKR provides. You may not expose our 6,000++ members to the long struggle you are going to have, That will create too much noise and I will have to lock the topic.
So here my advise:
- Don't do it. Stay with one of the many IBKR API implementations (C++, C#, VB, Java, Python) or and independent implementation with a large enough existing community (ib_async., Ruby, ...)
- At the heart, all IBKR TWS API implementations simply serialize the requests your client makes into messages that are sent to TWS/IBGW via the socket and, in return, a deserialize messages from TWS/IBGW into callbacks. Follow Mark Collins's advice and read and understand the EClient (requests) and EDecoder (responses) classes for a language you are most familiar with. You would have to create the equivalent to those two classes in PureBasic if you want to connect at the socket level.
- The wire-line message protocol is not documented, subject to change without notice, and does change with every major TWS/IBGW release. But several of our members and the ib_insync/ib_async community do maintain their own implementations. It can be done.
- If that is the route you want to go, implement a program that simply connects to TWS/IBGW via the socket and handles the few very basic messages required for the "HELLO" phase. But there are will be many additiona? messages with complex objects zou would have to implement eventually even if you'd only use a subset of TWS API. But I have attached (once more) the basic message flow you would have to implement:
- Create a socket with TWS/IBGW
- Send the FIRST_CLIENT_MESSAGE
- Wait for and receive the FIRST_SERVER_MESSAGE
- Send the API_START_API_MESSAGE
- Wait for and receive the MANAGED_ACCOUNTS_MESSAGE and NEXT_VALID_ID_MESSAGE
- Plus be prepared for ERROR_MESSAGEs since they can occur at any time after API_START
- IBKR takes care of all the little details by providing you with TWS API implementations for various languages. Making and maintaining a wrapper around TWSlib.dll for PureBasic might be a much more manageable task as long as TWSlib.dll and their threading code plays nicely with PureBasic. You might have to make minor adjustments to method signatures over time, but you can stay on the same TWSlib.dll version for months if not years unless you need features of newer versions.
But using an existing TWS API implementation will be by far your most productive path. And the only path for our group to provide you with any ongoing help.
One last thought. Assuming PureBasic provides a rich set of WEB/REST API tools, (formerly called Client Portal API) might be the simplest path for you to interact with your IBKR account from PureBasic.
闯ü谤驳别苍
?
?
?
?
On Thu, Dec 5, 2024 at 11:12 AM, Tradiator wrote:
toggle quoted message
Show quoted text
I am sorry to be a bit stubborn but I prefer to start in Purebasic. Might change later eventually.
?
However I am struggling using the TWSlib.dll. I can connect to this lib but I am having problems to calling a function.
What I would like to know is if TWSlib is the best option or is it better to use the windows socket solution ?
I am not sure but it seems that the source code suppplied with TWS API of the other languages use the socket version ?
?
And I also have the impression that the socket version is more generic and makes the program independent of changes made by IB to TWSlib.
What do you think ?
?
Please help me, I really would like to start making TWSAPI calls and start working on the interesting part of the program.
?
?