VoltTable[] res = voltExecuteSQL();
// we do not need to retrieve settlement here
VoltTable trade = res[0];
assert trade.getRowCount() == 1;
VoltTableRow trade_row = trade.fetchRow(0);
is_cash[i] = (int)trade_row.getLong("T_IS_CASH");
is_market[i] = (int)trade_row.getLong("TT_IS_MRKT");
if (is_cash[i] == 1) {
voltQueueSQL(getCashTransaction, trade_ids[i]);
}
voltQueueSQL(getTradeHistory, trade_ids[i]);
voltExecuteSQL();
}
// results
result = trade_update_ret_template_frame1.clone(256);
for (int i = 0; i < max_trades; i++) {
result.addRow(is_cash[i], is_market[i]);
}
}
else if (frame_to_execute == 2) {
voltQueueSQL(getTrade2, acct_id, "CMPT", start_trade_dts, end_trade_dts);
VoltTable trades = voltExecuteSQL()[0];
result = trade_update_ret_template_frame2.clone(256);
int num_updated = 0;
for (int i = 0; i < trades.getRowCount(); i++) {
VoltTableRow trade_row = trades.fetchRow(i);
long trade_id = trade_row.getLong("T_ID");
int is_cash = (int)trade_row.getLong("T_IS_CASH");
if (num_updated < max_updates) {
voltQueueSQL(getCashType, trade_id);
VoltTable cash = voltExecuteSQL()[0];
assert cash.getRowCount() == 1;
String cash_type = cash.fetchRow(0).getString("SE_CASH_TYPE");
if (is_cash == 1) {
if (cash_type.equals("Cash Account")) {
cash_type = "Cash";
}
else {
cash_type = "Cash Account";
}
}
else {
if (cash_type.equals("Margin Account")) {
cash_type = "Margin";
}
else {
cash_type = "Margin Account";
}
}
voltQueueSQL(updateSettlement, cash_type, trade_id);
voltExecuteSQL();
num_updated++;
}
voltQueueSQL(getSettlement, trade_id);
if (is_cash == 1) {
voltQueueSQL(getCashTransaction, trade_id);
}
voltQueueSQL(getTradeHistory, trade_id);
voltExecuteSQL();
result.addRow(is_cash, trade_id);
}
}
else if (frame_to_execute == 3) {
voltQueueSQL(getTradeTradeTypeSecurity, symbol, "CMPT", start_trade_dts, end_trade_dts);
VoltTable trades = voltExecuteSQL()[0];
result = trade_update_ret_template_frame3.clone(128);
int num_updated = 0;
Pattern p = Pattern.compile(".* shares of .*");
for (int i = 0; i < trades.getRowCount(); i++) {
VoltTableRow trade_row = trades.fetchRow(i);
long trade_id = trade_row.getLong("T_ID");
int is_cash = (int)trade_row.getLong("T_IS_CASH");
String type_name = trade_row.getString("TT_NAME");
String s_name = trade_row.getString("S_NAME");
int quantity = (int)trade_row.getLong("T_QTY");
voltQueueSQL(getSettlement, trade_id);
voltExecuteSQL(); // don't need the result
if (is_cash == 1) {