示例#1
0
 private static void addGBComponent(
     IBGridBagPanel panel, Component comp, GridBagConstraints gbc, int weightx, int gridwidth) {
   gbc.weightx = weightx;
   gbc.gridwidth = gridwidth;
   panel.setConstraints(comp, gbc);
   panel.add(comp, gbc);
 }
示例#2
0
  public UnderCompDlg(UnderComp underComp, JDialog owner) {
    super(owner, true);

    m_underComp = underComp;

    // create button panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(m_btnOk);
    buttonPanel.add(m_btnReset);
    buttonPanel.add(m_btnCancel);

    // create action listeners
    m_btnOk.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onOk();
          }
        });
    m_btnReset.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onReset();
          }
        });
    m_btnCancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });

    java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weighty = 100;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridheight = 1;

    // create mid panel
    IBGridBagPanel midPanel = new IBGridBagPanel();
    midPanel.setBorder(BorderFactory.createTitledBorder("Under Comp"));
    addGBComponent(
        midPanel, new JLabel("Contract Id"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(midPanel, m_txtConId, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(midPanel, new JLabel("Delta"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(midPanel, m_txtDelta, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(midPanel, new JLabel("Price"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(midPanel, m_txtPrice, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    m_txtConId.setText(Integer.toString(m_underComp.m_conId));
    m_txtDelta.setText(Double.toString(m_underComp.m_delta));
    m_txtPrice.setText(Double.toString(m_underComp.m_price));

    // create dlg box
    getContentPane().add(midPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);
    setTitle("Delta Neutral");
    pack();
  }
  public OrderDlg(SampleFrame owner) {
    super(owner, true);

    m_parent = owner;
    setTitle("Sample");

    java.awt.GridBagConstraints gbc = new java.awt.GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weighty = 100;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.gridheight = 1;
    // create id panel
    IBGridBagPanel pId = new IBGridBagPanel();
    pId.setBorder(BorderFactory.createTitledBorder("Message Id"));

    addGBComponent(pId, new JLabel("Id"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pId, m_Id, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create contract panel
    IBGridBagPanel pContractDetails = new IBGridBagPanel();
    pContractDetails.setBorder(BorderFactory.createTitledBorder("Contract Info"));
    addGBComponent(
        pContractDetails, new JLabel("Contract Id"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_conId, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Symbol"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_symbol, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails,
        new JLabel("Security Type"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_secType, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Expiry"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_expiry, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Strike"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_strike, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Put/Call"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_right, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails,
        new JLabel("Option Multiplier"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_multiplier, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Exchange"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_exchange, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails,
        new JLabel("Primary Exchange"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_primaryExch, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Currency"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_currency, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Local Symbol"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_localSymbol, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails,
        new JLabel("Trading Class"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_tradingClass, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails,
        new JLabel("Include Expired"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(
        pContractDetails, m_includeExpired, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Sec Id Type"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_secIdType, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pContractDetails, new JLabel("Sec Id"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pContractDetails, m_secId, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create order panel
    IBGridBagPanel pOrderDetails = new IBGridBagPanel();
    pOrderDetails.setBorder(BorderFactory.createTitledBorder("Order Info"));
    addGBComponent(
        pOrderDetails, new JLabel("Action"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_action, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails,
        new JLabel("Total Order Size"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_totalQuantity, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails, new JLabel("Order Type"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_orderType, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails,
        new JLabel("Lmt Price / Option Price / Volatility"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_lmtPrice, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails,
        new JLabel("Aux Price / Underlying Price"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_auxPrice, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails, new JLabel("Good After Time"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_goodAfterTime, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOrderDetails, new JLabel("Good Till Date"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pOrderDetails, m_goodTillDate, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create marketDepth panel
    IBGridBagPanel pMarketDepth = new IBGridBagPanel();
    pMarketDepth.setBorder(BorderFactory.createTitledBorder("Market Depth"));
    addGBComponent(
        pMarketDepth, new JLabel("Number of Rows"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(
        pMarketDepth, m_marketDepthRowTextField, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create marketData panel
    IBGridBagPanel pMarketData = new IBGridBagPanel();
    pMarketData.setBorder(BorderFactory.createTitledBorder("Market Data"));
    addGBComponent(
        pMarketData, new JLabel("Generic Tick Tags"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(
        pMarketData, m_genericTicksTextField, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pMarketData, m_snapshotMktDataTextField, gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);

    // create options exercise panel
    IBGridBagPanel pOptionsExercise = new IBGridBagPanel();
    pOptionsExercise.setBorder(BorderFactory.createTitledBorder("Options Exercise"));
    addGBComponent(
        pOptionsExercise,
        new JLabel("Action (1 or 2)"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(
        pOptionsExercise, m_exerciseActionTextField, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pOptionsExercise,
        new JLabel("Number of Contracts"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(
        pOptionsExercise,
        m_exerciseQuantityTextField,
        gbc,
        COL2_WIDTH,
        GridBagConstraints.REMAINDER);
    addGBComponent(
        pOptionsExercise,
        new JLabel("Override (0 or 1)"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(
        pOptionsExercise, m_overrideTextField, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create historical data panel
    IBGridBagPanel pBackfill = new IBGridBagPanel();
    pBackfill.setBorder(BorderFactory.createTitledBorder("Historical Data Query"));
    GregorianCalendar gc = new GregorianCalendar();
    gc.setTimeZone(TimeZone.getTimeZone("GMT"));
    String dateTime =
        ""
            + gc.get(Calendar.YEAR)
            + pad(gc.get(Calendar.MONTH) + 1)
            + pad(gc.get(Calendar.DAY_OF_MONTH))
            + " "
            + pad(gc.get(Calendar.HOUR_OF_DAY))
            + ":"
            + pad(gc.get(Calendar.MINUTE))
            + ":"
            + pad(gc.get(Calendar.SECOND))
            + " "
            + gc.getTimeZone().getDisplayName(false, TimeZone.SHORT);

    m_BackfillEndTime.setText(dateTime);
    addGBComponent(
        pBackfill, new JLabel("End Date/Time"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_BackfillEndTime, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(pBackfill, new JLabel("Duration"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_BackfillDuration, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pBackfill,
        new JLabel("Bar Size Setting (1 to 11)"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_BarSizeSetting, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pBackfill, new JLabel("What to Show"), gbc, COL1_WIDTH, GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_WhatToShow, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pBackfill,
        new JLabel("Regular Trading Hours (1 or 0)"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_UseRTH, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);
    addGBComponent(
        pBackfill,
        new JLabel("Date Format Style (1 or 2)"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(pBackfill, m_FormatDate, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create marketDataType panel
    IBGridBagPanel pMarketDataType = new IBGridBagPanel();
    pMarketDataType.setBorder(BorderFactory.createTitledBorder("Market Data Type"));
    addGBComponent(
        pMarketDataType,
        new JLabel("Market Data Type"),
        gbc,
        COL1_WIDTH,
        GridBagConstraints.RELATIVE);
    addGBComponent(
        pMarketDataType, m_marketDataTypeCombo, gbc, COL2_WIDTH, GridBagConstraints.REMAINDER);

    // create mid Panel
    JPanel pMidPanel = new JPanel();
    pMidPanel.setLayout(new BoxLayout(pMidPanel, BoxLayout.Y_AXIS));
    pMidPanel.add(pContractDetails, BorderLayout.CENTER);
    pMidPanel.add(pOrderDetails, BorderLayout.CENTER);
    pMidPanel.add(pMarketDepth, BorderLayout.CENTER);
    pMidPanel.add(pMarketData, BorderLayout.CENTER);
    pMidPanel.add(pOptionsExercise, BorderLayout.CENTER);
    pMidPanel.add(pBackfill, BorderLayout.CENTER);
    pMidPanel.add(pMarketDataType, BorderLayout.CENTER);

    // create order button panel
    JPanel pOrderButtonPanel = new JPanel();
    pOrderButtonPanel.add(m_sharesAlloc);
    pOrderButtonPanel.add(m_comboLegs);
    pOrderButtonPanel.add(m_btnUnderComp);
    pOrderButtonPanel.add(m_btnAlgoParams);
    pOrderButtonPanel.add(m_btnSmartComboRoutingParams);

    pMidPanel.add(pOrderButtonPanel, BorderLayout.CENTER);

    // create button panel
    JPanel buttonPanel = new JPanel();
    buttonPanel.add(m_ok);
    buttonPanel.add(m_cancel);

    // create action listeners
    m_sharesAlloc.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onSharesAlloc();
          }
        });

    m_comboLegs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onAddComboLegs();
          }
        });
    m_btnUnderComp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onBtnUnderComp();
          }
        });
    m_btnAlgoParams.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onBtnAlgoParams();
          }
        });
    m_btnSmartComboRoutingParams.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onBtnSmartComboRoutingParams();
          }
        });
    m_ok.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onOk();
          }
        });
    m_cancel.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            onCancel();
          }
        });

    // create top panel
    JPanel topPanel = new JPanel();
    topPanel.setLayout(new BoxLayout(topPanel, BoxLayout.Y_AXIS));
    topPanel.add(pId);
    topPanel.add(pMidPanel);

    // create dlg box
    getContentPane().add(topPanel, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    JScrollPane scroller = new JScrollPane(topPanel);
    this.add(scroller, BorderLayout.CENTER);

    pack();
  }