Keyboard Shortcuts
Likes
Search
Re: Purebasic and TWS
开云体育@TRadiator ? This is in response to your post earlier today. Your statements are quoted in blue, followed by my replies. ? “I am sorry to be a bit stubborn but I prefer to start in Purebasic. Might change later eventually.” ? Well, all the advice you’ve received so far is DON’T. And that’s good advice. I think you should take it. Having said that, I’ll try to provide some responses to your statements that might help. ? “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 ?” ? What do you mean when you say you can connect to TWSLib.dll? Do you mean you can reference the library, instantiate a TWS object and successfully call the eConnect() method? If so, that’s actually quite encouraging. If PureBasic can properly deal with ActiveX technology, then you should be able to use it quite successfully. ? What do you mean by ‘the windows socket solution’? I presume you mean the CSharpAPI.dll library? ?Every API implementation, no matter what language, use a socket connection to communicate with TWS/Gateway: there is no other way to communicate. Every API sends the same message in response to an API call. The TWSLib.dll (also known as the ActiveX API) is basically just a wrapper around CSharpAPI.dll. This wrapper uses Microsoft’s ActiveX technology to enable it to be used in environments that ‘speak’ ActiveX, such as Excel and other Office apps, Delphi, even Visual Basic 6. This version of the API is in some respects easier to program with than the CSharpAPI.dll, but it also has quite a few ‘gotchas’ that make it rather confusing. ? So assuming that PureBasic is a fully fledged ActiveX host, you should be able to use the full power of the API fairly straightforwardly, once you’ve got over the initial confusion. ? The other day I sent you a link to two sample programs written in Visual Basic .Net and C#, both using the CSharpAPI. As it happens, I also have a version that uses the ActiveX API. It does exactly the same things as the other two, but uses TWSLib.dll rather than CSharpAPI.dll. I’ve now uploaded that sample to the same location (see the SimpleTWSActiveXDemo folder, or SimpleTWSActiveXDemo.zip which is easier to download): ? (). ? Hopefully you’ll be able to use that code as a basis for something in PureBasic. I imagine the main differences will be in how you reference the project, the syntax for handling events, and of course the UI creation which would no doubt be quite an effort to port. I’d suggest starting with a much reduced version that has a button to connect/disconnect and handles the connectAck and errMsg events. Once that’s working you can build up with the reqMktData call and the tickPrice and tickSize events, etc. ? I should add that this version is also not using the latest API, but it works perfectly well. It doesn’t include the change from Double type to Decimal type for sizes, but that won’t matter for the moment (unless you want to trade crypto-currency contracts). I’ll try to get round to bringing these samples up-to-date? at some point. ? If you get stuck, email me privately (you can do this using the Reply to Sender facility). I’ll do what I can to help, but only if it looks like there’s a chance it can be made to work. ? ? “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 ?” ? No, not really. The ActiveX API provides pretty much exactly the same capabilities as the CSharpAPI.dll (I think there are a couple of things that IBKR haven’t been able to provide for technical reasons, but I can’t remember what they are without going and looking – certainly not things that you’re likely to need any time soon). Changes to TWSLib always affect the client program one way or another. ? “Please help me, I really would like to start making TWSAPI calls and start working on the interesting part of the program.” ? ??????????????? I’ll try!... ? ? Richard ? |