本文整理汇总了Java中com.ib.client.Execution类的典型用法代码示例。如果您正苦于以下问题:Java Execution类的具体用法?Java Execution怎么用?Java Execution使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Execution类属于com.ib.client包,在下文中一共展示了Execution类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: logExecution
import com.ib.client.Execution; //导入依赖的package包/类
private void logExecution(String string, Execution execution) {
if (string == null || execution == null) {
return;
}
log(Level.INFO,
"{0} #{8} {3} QTY={4} @ {5} CUMQTY={6} CURPOS={1} {7} at {2}",
new Object[]{
string,
currentPosition,
execution.m_time == null ? "" : execution.m_time.substring(10, execution.m_time.length()),
execution.m_side,
execution.m_shares,
execution.m_price,
execution.m_cumQty,
execution.m_acctNumber,
execution.m_orderId});
}
示例2: insertExecution
import com.ib.client.Execution; //导入依赖的package包/类
public void insertExecution(Contract contract, Execution execution) throws SQLException, ClassNotFoundException {
executeUpdate(
"REPLACE INTO `executions`"
+ " (m_execId, m_permId, m_conId, m_orderId, m_clientId, m_time,"
+ " m_acctNumber, m_exchange, m_side, m_shares, m_price,"
+ " m_liquidation, m_cumQty, m_avgPrice, exe_time_long)"
+ " VALUES("
+ SqlUtil.formatValues(
execution.m_execId,
execution.m_permId,
contract.m_conId,
execution.m_orderId,
execution.m_clientId,
execution.m_time,
execution.m_acctNumber,
execution.m_exchange,
execution.m_side,
execution.m_shares,
execution.m_price,
execution.m_liquidation,
execution.m_cumQty,
execution.m_avgPrice,
DateUtil.getTime(execution.m_time))
+ " );");
}
示例3: execDetails
import com.ib.client.Execution; //导入依赖的package包/类
@Override
public void execDetails(int reqId, Contract contract, Execution execution) {
try {
if (logger.isDebugEnabled())
logger.debug("execDetails: {} {} {}", new Object[] { reqId, Util.toString(contract), Util.toString(execution) });
OpenOrder openOrder = openOrdersById.get(execution.m_orderId);
DateTime dt = DateTimeFormat.forPattern("yyyyMMdd HH:mm:ss").parseDateTime(execution.m_time);
if (openOrder != null) {
int quantityChange = openOrder.isBuy() ? execution.m_shares : -execution.m_shares;
openOrder.update(quantityChange, execution.m_price, dt);
logExecution(openOrder, quantityChange);
} else {
logger.info("Execution does not match any open order {} {}", Util.toString(contract), Util.toString(execution));
}
} catch (Throwable t) {
// Do not allow exceptions come back to the socket -- it will cause
// disconnects
logger.error(t.getMessage(), t);
}
}
示例4: execDetails
import com.ib.client.Execution; //导入依赖的package包/类
@Override public void execDetails(int reqId, Contract contract, Execution execution) {
if (m_tradeReportHandler != null) {
int i = execution.m_execId.lastIndexOf( '.');
String tradeKey = execution.m_execId.substring( 0, i);
m_tradeReportHandler.tradeReport( tradeKey, new NewContract( contract), execution);
}
recEOM();
}
示例5: execDetails
import com.ib.client.Execution; //导入依赖的package包/类
@Override public void execDetails(int reqId, Contract contract, Execution execution) {
if (m_tradeReportHandler != null) {
int i = execution.execId().lastIndexOf( '.');
String tradeKey = execution.execId().substring( 0, i);
m_tradeReportHandler.tradeReport( tradeKey, contract, execution);
}
recEOM();
}
示例6: tradeReport
import com.ib.client.Execution; //导入依赖的package包/类
@Override public void tradeReport(String tradeKey, Contract contract, Execution trade) {
FullExec full = m_map.get( tradeKey);
if (full != null) {
full.m_trade = trade;
}
else {
full = new FullExec( contract, trade);
m_trades.add( full);
m_map.put( tradeKey, full);
}
m_model.fireTableDataChanged();
}
示例7: execDetails
import com.ib.client.Execution; //导入依赖的package包/类
@Override
public void execDetails(final int reqId, final Contract contract, final Execution execution) {
// new Thread(new Runnable() {
//
// @Override
// public void run() {
try {
TradingThread tradingThread = Main.getStrategy(contract);
if (tradingThread != null) {
// && contract.m_symbol.equals(tradingThread.getTradingSymbol())
// && contract.m_secType.equals(tradingThread.getSecurityType())) {
OrderRecord orderRecord;
if (tradingThread.addExecution(execution)) {
orderRecord = orderRecordMap.get(execution.m_orderId);
if (orderRecord != null) {
orderRecord.setBar(tradingThread.getPrimaryChart().getLast(), false);
orderRecord.setExecution(execution);
}
}
Main.tradingSchema.insertExecution(contract, execution);
tradingThread.insertWebExecution(execution);
}
} catch (Exception e) {
log(Level.SEVERE, null, e);
}
// }
// }).start();
super.execDetails(reqId, contract, execution);
}
示例8: executeOrder
import com.ib.client.Execution; //导入依赖的package包/类
private void executeOrder(OrderRecord orderRecord) {
if (!orderRecord.isSubmitted()) {
return;
}
Side side = orderRecord.getSide();
String orderType = orderRecord.getOrder().m_orderType;
long lastTickTime = getLastTickTime();
double lastPrice = getLastTickPrice();
if (orderType.contains("STP")
&& side.sign * lastPrice < side.sign * orderRecord.getOrder().m_auxPrice) {
return;
}
if (orderType.contains("LMT")
&& side.sign * lastPrice > side.sign * orderRecord.getOrder().m_lmtPrice) {
return;
}
orderRecord.setCommission(commission);
Execution execution = new Execution(
orderRecord.getOrderId(),
getThreadId(),
"" + orderRecord.getOrderId(),
"" + lastTickTime,
"",
contract.m_exchange,
side.executionSimpleName,
p_Default_Qty, lastPrice, 0, 0, p_Default_Qty, lastPrice);
if (addExecution(execution)) {
orderRecord.setBar(primaryChart.getLast(), false);
orderRecord.setExecution(execution);
}
}
示例9: reloadExecutions
import com.ib.client.Execution; //导入依赖的package包/类
private void reloadExecutions() throws Exception {
long reloadSince = tradingHours.getLastOpen().getTimeInMillis();
executions = Main.tradingSchema.getExecutions(
getThreadId(),
reloadedConId,
reloadSince);
for (Execution execution : executions) {
insertWebExecution(execution);
}
log(Level.INFO, "Reloaded executions: {0}", executions.size());
}
示例10: reloadOrders
import com.ib.client.Execution; //导入依赖的package包/类
private void reloadOrders() throws Exception {
long reloadSince = tradingHours.getLastOpen().getTimeInMillis();
if (currentPosition != 0) {
OrderRecord enterOrderRecord = createNewEnterOrderRecord();
OrderRecord exitOrderRecord = getLastExitOrderRecord();
Main.tradingSchema.getLastFilledOrder(
getThreadId(),
reloadedConId,
reloadSince,
enterOrderRecord);
Main.tradingSchema.getSubmittedOrder(
getThreadId(),
reloadedConId,
reloadSince,
exitOrderRecord);
for (Execution execution : executions) {
OrderRecord orderRecord = getOrderRecord(execution.m_orderId);
if (orderRecord != null) {
orderRecord.setExecution(execution, false);
}
}
}
}
示例11: getLastExecution
import com.ib.client.Execution; //导入依赖的package包/类
/**
*
* @return
*/
public Execution getLastExecution() {
if (executions.isEmpty()) {
return null;
}
return executions.get(executions.size() - 1);
}
示例12: isValidExecution
import com.ib.client.Execution; //导入依赖的package包/类
protected boolean isValidExecution(Execution execution) {
if (isBacktesting() || !Main.isAdvisorAccount()) {
return true;
}
if ((execution.m_shares > 0 && execution.m_acctNumber.contains("F"))
|| execution.m_clientId == 0) {
return true;
}
return false;
}
示例13: getLastExitOrderRecord
import com.ib.client.Execution; //导入依赖的package包/类
protected OrderRecord getLastExitOrderRecord() {//boolean needsPattern) {//, boolean notify) {
Trade lastTrade = getLastTrade();
if (lastTrade == null) {
lastTrade = createNewTrade();
}
OrderRecord exitOrder = lastTrade.getExitOrderRecord();
if (exitOrder == null
|| (!exitOrder.isSubmitted() && !exitOrder.isWorking())) {
exitOrder = createNewOrderRecord();
lastTrade.addExitOrderRecord(exitOrder, false);
}
if (lastTrade.getEnterOrderRecord() == null) {
lastTrade.addEnterOrderRecord(new OrderRecord(), false);
Execution execution = new Execution();
execution.m_side = getCurrentSide().toString();
lastTrade.getEnterOrderRecord().setExecution(execution, false);
}
// if (notify) {
// exitOrder.fireChanged();
// }
return exitOrder;
}
示例14: insertWebExecution
import com.ib.client.Execution; //导入依赖的package包/类
public void insertWebExecution(Execution execution) {
if (execution.m_shares < 0) {
return;
}
if (DateUtil.getTime(execution.m_time)
>= DateUtil.getMidnightTime(tradingHours.getTimeZone())) {
try {
Main.webSchema.insertWebExecution(contractId, execution);
} catch (Exception ex) {
log(Level.SEVERE, null, ex);
}
}
}
示例15: getExecutions
import com.ib.client.Execution; //导入依赖的package包/类
public List<Execution> getExecutions(int clientId, int conId, long since) throws SQLException, ParseException, ClassNotFoundException {
List<Execution> executions = new ArrayList<Execution>();
ResultSet resultSet = callProcedure("getExecutions",
conId, since, "");
while (resultSet.next()) {
Execution execution = new Execution();
execution.m_execId = resultSet.getString("m_execId");
execution.m_permId = resultSet.getInt("m_permId");
execution.m_clientId = resultSet.getInt("m_clientId");
execution.m_orderId = resultSet.getInt("m_orderId");
execution.m_time = DateUtil.getTimeStamp(
resultSet.getLong("exe_time_long"), "yyyyMMdd HH:mm:ss");
// execution.m_time = DateUtil.convertDateString(
// resultSet.getString("m_time"),
// "yyyy-MM-dd HH:mm:ss",
// "yyyyMMdd HH:mm:ss");
execution.m_acctNumber = resultSet.getString("m_acctNumber");
execution.m_exchange = resultSet.getString("m_exchange");
execution.m_side = resultSet.getString("m_side");
execution.m_shares = resultSet.getInt("m_shares");
execution.m_price = resultSet.getDouble("m_price");
execution.m_liquidation = resultSet.getInt("m_liquidation");
execution.m_cumQty = resultSet.getInt("m_cumQty");
execution.m_avgPrice = resultSet.getDouble("m_avgPrice");
executions.add(execution);
}
return executions;
}