¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

Get EUR quote - Simple Example


 

Heya Peeps,


I've recently signed up for the TWS API, and I'm trying to get myself up and running.?


My immediate goal is simply to get a FOREX market quote--note that FOREX data are free from IB, and require no subscription. For example, I would like a quote of the United States Dollar against the Japanese Yen (USD/YEN).


I'm stuck, on two points:

1. Where do in I place this request? In what routine? Main.cpp? TestCppClient.cpp? Do I create a separate .cpp file and include it? Do I modify a routine in TestCppClient.cpp?

2. Regarding FOREX, what method is used? I've browsed through all the function calls in ContractSamples.cpp, but see no sample request for FOREX.


Regarding #1, the docs say that a market request is of the form [Ref. 1]:

m_pClient->reqMktData(1001, ContractSamples::StockComboContract(), "", false, TagValueListSPtr());


..After instantiating the TestCppClient object with?

TestCppClient client;


..I found myself trying
client.m_pClient->reqMktData(1001, ContractSamples::StockComboContract(), "", false, TagValueListSPtr());


..but m_pClient is private. What is the proper usage of this command; or, more accurately, in what class or method is it correctly invoked?


Regarding #2 above...

In?void TestCppClient::tickDataOperation(),?I see a bunch of m_pClient->reqMktData commands, but nothing for FOREX.


I feel like I am very close, but the answer is eluding me.


Thanks for your help.


Sincerely,

Keith


---


Additional notes.


- I've installed TWS?

- I am logged in in "Paper Trading" mode.

- I have compiled?Main.cpp?in the Samples/ directory

- I've run the compiled executable ./Main

- The API places three limit orders for IBKR, at 10, 11, and 12.



Ref 1:

?






rholowczak
 

I've not done much with the C++ flavor of the API in version 9.72 (BETA).
One thing you will likely need for real-time data is to set up a separate thread to accept the market data messages (ticks).
Specifying an FX contract is relatively straight forward - just set the right properties of the contract object. Here are some examples (in Java, but for any programming language the logic is the same):

?




 

Thank you!