Hi all, I have the following code:
?? ????
??????? public void tickPrice(int tickerId, int field, double price, TickAttrib attrib) {
?? ???????? System.out.println(price);
?? ???? }
?? ???? private EReaderSignal signal = new EJavaSignal();
?? ???? private EClientSocket client = new EClientSocket(this, signal);
?? ????
?? ???? client.eConnect("127.0.0.1", 7496, 2);
?? ???? Thread.sleep(3000);
?????? ?
?????? ?
?????? ?
??????? reader = new EReader(client, signal);? ?
??????? reader.start();
?????? ?
??????? new Thread(() -> {
??????????? while (client.isConnected()) {
??????????????? signal.waitForSignal();
??????????????? try {
??????????????????? reader.processMsgs();
??????????????? } catch (Exception e) {
??????????????????? System.out.println("Exception: "+e.getMessage());
??????????????? }
??????????? }
??????? }).start();
?????? ?
?????? ?
??????? Contract contract = new Contract();
??????? contract.symbol("IGC");
??????? contract.secType("STK");
?????? ?
??????? Vector<TagValue> mktDataOptions = new Vector<TagValue>();
??????? client.reqCurrentTime();
??????? client.reqMktData(nextOrderID, contract, null, false, false, mktDataOptions);
???????
??????? Thread.sleep(1000);
??????? client.eDisconnect();
I would like to know what's going wrong here. When I run the program it successfully gives me the current time but it does nothing regarding the call to reqMktData(). I believe that calling reqMktData() should automatically cause the tickPrice() method to print out the current price. Am I correct in believing that this is automatic upon calling reqMktData()? Or am I missing an extra step somewhere?
I am doing this outside of market hours but I don't believe that is my problem.
I have searched around this site and can't find anything suggesting that my code shouldn't work.
Thank you for any help.