Exemplo n.º 1
0
 private void goButtonActionPerformed(
     java.awt.event.ActionEvent evt) { // GEN-FIRST:event_goButtonActionPerformed
   Contract contract = new Contract();
   contract.m_symbol = symbolInTextBox.getText().toUpperCase();
   contract.m_secType = "FUT";
   contract.m_exchange = exchangeTextBox.getText().toUpperCase();
   contract.m_includeExpired = true;
   contractInfos.setParams(this, contract);
   Thread ciThread = new Thread(contractInfos);
   ciThread.run();
   // Trader trader = Dispatcher.getTrader();
   // trader.setContractDetailsConnection(this);
   // Strategy strategy = new DownloaderStrategy(); // a dummy strategy, needed for the framework
   // trader.getAssistant().addStrategy(strategy); //Updates id for TWS
   // int requestId = strategy.getId();
   // trader.getAssistant().requestContractDetails(requestId, contract);
 } // GEN-LAST:event_goButtonActionPerformed
  void onOk() {
    m_rc = false;

    try {
      // set id
      m_id = Integer.parseInt(m_Id.getText());

      // set contract fields
      m_contract.m_conId = ParseInt(m_conId.getText(), 0);
      m_contract.m_symbol = m_symbol.getText();
      m_contract.m_secType = m_secType.getText();
      m_contract.m_expiry = m_expiry.getText();
      m_contract.m_strike = ParseDouble(m_strike.getText(), 0.0);
      m_contract.m_right = m_right.getText();
      m_contract.m_multiplier = m_multiplier.getText();
      m_contract.m_exchange = m_exchange.getText();
      m_contract.m_primaryExch = m_primaryExch.getText();
      m_contract.m_currency = m_currency.getText();
      m_contract.m_localSymbol = m_localSymbol.getText();
      m_contract.m_tradingClass = m_tradingClass.getText();
      try {
        int includeExpired = Integer.parseInt(m_includeExpired.getText());
        m_contract.m_includeExpired = (includeExpired == 1);
      } catch (NumberFormatException ex) {
        m_contract.m_includeExpired = false;
      }
      m_contract.m_secIdType = m_secIdType.getText();
      m_contract.m_secId = m_secId.getText();

      // set order fields
      m_order.m_action = m_action.getText();
      m_order.m_totalQuantity = Integer.parseInt(m_totalQuantity.getText());
      m_order.m_orderType = m_orderType.getText();
      m_order.m_lmtPrice = parseStringToMaxDouble(m_lmtPrice.getText());
      m_order.m_auxPrice = parseStringToMaxDouble(m_auxPrice.getText());
      m_order.m_goodAfterTime = m_goodAfterTime.getText();
      m_order.m_goodTillDate = m_goodTillDate.getText();

      m_order.m_faGroup = m_faGroup;
      m_order.m_faProfile = m_faProfile;
      m_order.m_faMethod = m_faMethod;
      m_order.m_faPercentage = m_faPercentage;

      // set historical data fields
      m_backfillEndTime = m_BackfillEndTime.getText();
      m_backfillDuration = m_BackfillDuration.getText();
      m_barSizeSetting = m_BarSizeSetting.getText();
      m_useRTH = Integer.parseInt(m_UseRTH.getText());
      m_whatToShow = m_WhatToShow.getText();
      m_formatDate = Integer.parseInt(m_FormatDate.getText());
      m_exerciseAction = Integer.parseInt(m_exerciseActionTextField.getText());
      m_exerciseQuantity = Integer.parseInt(m_exerciseQuantityTextField.getText());
      m_override = Integer.parseInt(m_overrideTextField.getText());
      ;

      // set market depth rows
      m_marketDepthRows = Integer.parseInt(m_marketDepthRowTextField.getText());
      m_genericTicks = m_genericTicksTextField.getText();
      m_snapshotMktData = m_snapshotMktDataTextField.isSelected();

      m_marketDataType = m_marketDataTypeCombo.getSelectedIndex() + 1;
    } catch (Exception e) {
      Main.inform(this, "Error - " + e);
      return;
    }

    m_rc = true;
    setVisible(false);
  }