Hi again
I am still unable to get the desired result from my current coding
Basic idea - grab an ordered subset of records from the database
For the first record - use only the prediction to be compared with the
following record's actual
For all the others - compare prediction (from prev record) with actual )from
current record) and do some maths
I seem to not be getting the predicted value correct?
Here is my coding
If you can see what could be wrong - let me know :)
Bob M
*********************************************
String Date5 = "";
int Time5 = 0;
try
{
rs = s.executeQuery("SELECT * FROM(SELECT * FROM xxxx WHERE TRADE_NO <>0
ORDER BY Trading_Date DESC,"
+ " Trading_Time DESC FETCH NEXT 103 ROWS ONLY) AS xxxx_Simulation
ORDER BY Trading_Date ASC, Trading_Time ASC");
int k = 0;
while (k < 100) {
rs.next();
// get class_current, predictions and profit from (k)th record
Date5 = rs.getString("Trading_Date");
Time5 = rs.getInt("Trading_Time");
class_current = rs.getString("class_current");
pred_test = rs.getString("Class_Predicted");
test_profit = rs.getDouble("Profit_Loss");
pred_test_curr = pred_test;
if (k < 1) {
pred_test_prev = pred_test_curr;
pred_test_curr = "";
class_current = "";
test_profit = 0;
}
if (k > 0) {
// 1) predicted and actual "UP"
// calculate pips won long
if((pred_test_prev.equals("Up")) && (class_current.equals("Up"))) {
pips_won_long = test_profit;
sum_pips_won_long = sum_pips_won_long + pips_won_long;
}
// 2) predicted "UP" and actual "DOWN"
// calculate pips lost long
if((pred_test_prev.equals("Up")) && (class_current.equals("Down"))) {
pips_lost_long = Math.abs(test_profit);
sum_pips_lost_long = sum_pips_lost_long + pips_lost_long;
}
// 3) predicted and actual "DOWN"
// calculate pips won short
if((pred_test_prev.equals("Down")) && (class_current.equals("Down"))) {
pips_won_short = test_profit;
sum_pips_won_short = sum_pips_won_short + pips_won_short;
}
// 4) predicted "DOWN" and actual "UP"
// calculate pips lost short
if((pred_test_prev.equals("Down")) && (class_current.equals("Up"))) {
pips_lost_short = Math.abs(test_profit);
sum_pips_lost_short = sum_pips_lost_short + pips_lost_short;
}
pred_test_prev = pred_test_curr;
pred_test_curr = "";
class_current = "";
test_profit = 0;
pips_won_long = 0;
pips_lost_long= 0;
pips_won_short = 0;
pips_lost_short = 0;
}
k++;
}
}
catch (SQLException e)
{
myConsole.getOut().println(e);
} // end of simulation - 100 simulation records
--
View this message in context:
http://apache-database.10148.n7.nabble.com/Processing-a-subset-of-records-correctly-again-tp145885.html
Sent from the Apache Derby Users mailing list archive at Nabble.com.