I want to get the last sold tick price ( option 4 of tickPrice() callback function but it does not seem to work ..please help!!! THANKS
( once you see the code the question is why callPrice() call back is not executed automatically when last price is there?
------------------skeleton code and execution results:
private float symbolLastPrice = 0;
private boolean finishedTickPrice = false;
Contract con1 = new Contract();
con1.m_symbol = "TNA"
con1.m_secType = "STK";
con1.m_currency = "USD";
con1.m_exchange = "SMART";
int tickerId = 5888;
debug("Ready to call getMktdata for: " + symb[jj]);
TWSSocket.reqMktData(tickerId, con1, "", true);
/*
Loop to check if call back tickPrice() has the value
if tickPrice is executed then finishedTickPrice will be
true which will end the loop
*/
while (!finishedTickPrice) {
debug(" in while loop Time: " + currentTime());
PL.justSleepDangit(1000); // just sleep and waiting
}
debug("The tick value is: " + symbolLastPrice);
----------------------- tickPrice() code -------------------------
public void tickPrice(int tickerId, int field, double price, int canAutoExecute) {
finishedTickPrice = true;
if (field == 4) {
symbolLastPrice = (float)price;
debug("Wow I have the price, symbolLastPrice is : " + symbolLastPrice);
}
}
---------------- RESULTS with the while loop
vacctPL.log: Ready to call getMktdata for: TNA
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
I had to kill it...
---------------- RESULTS without the while loop
vacctPL.log: Ready to call getMktdata for: TNA
vacctPL.log: Wow I have the price, symbolLastPrice is : 44.14
( once you see the code the question is why callPrice() call back is not executed automatically when last price is there?
------------------skeleton code and execution results:
private float symbolLastPrice = 0;
private boolean finishedTickPrice = false;
Contract con1 = new Contract();
con1.m_symbol = "TNA"
con1.m_secType = "STK";
con1.m_currency = "USD";
con1.m_exchange = "SMART";
int tickerId = 5888;
debug("Ready to call getMktdata for: " + symb[jj]);
TWSSocket.reqMktData(tickerId, con1, "", true);
/*
Loop to check if call back tickPrice() has the value
if tickPrice is executed then finishedTickPrice will be
true which will end the loop
*/
while (!finishedTickPrice) {
debug(" in while loop Time: " + currentTime());
PL.justSleepDangit(1000); // just sleep and waiting
}
debug("The tick value is: " + symbolLastPrice);
----------------------- tickPrice() code -------------------------
public void tickPrice(int tickerId, int field, double price, int canAutoExecute) {
finishedTickPrice = true;
if (field == 4) {
symbolLastPrice = (float)price;
debug("Wow I have the price, symbolLastPrice is : " + symbolLastPrice);
}
}
---------------- RESULTS with the while loop
vacctPL.log: Ready to call getMktdata for: TNA
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
vacctPL.log: in while loop Time: 17:21
I had to kill it...
---------------- RESULTS without the while loop
vacctPL.log: Ready to call getMktdata for: TNA
vacctPL.log: Wow I have the price, symbolLastPrice is : 44.14