2013年9月14日土曜日

Open a chart from IClient

Open a chart from IClient
IClientからチャートを開く。

Note: Available with JForex-API 2.7.1
注意:JForex-API 2.7.1として有効。
Consider opening multiple charts - for each instrument in an array instrArr:
複数チャートを開く場合を検討 - instrArr配列の中でfor each命令ループを使用。
for(Instrument instrument : instrArr){
    IFeedDescriptor feedDescriptor = new TicksFeedDescriptor(instrument);
    feedDescriptor.setOfferSide(OfferSide.BID);// need to set due to platform requirements
    IChart chart = client.openChart(feedDescriptor);
    final IClientGUI clientGUI = client.getClientGUI(chart);
    SwingUtilities.invokeLater(new Runnable() {
        public void run() {
            ChartFrame frame = new ChartFrame(clientGUI, client.getSubscribedInstruments());
            chartFrameMap.put(clientGUI.getChart(), frame);
            //Handle manual close - we need to call IClient.closeChart for strategy to know that the chart is no more there
            frame.addWindowListener(new WindowAdapter(){
                public void windowClosing(WindowEvent e) {
                    LOGGER.info("Chart manually closed, removing the chart from the strategy context");
                    client.closeChart(clientGUI.getChart());
                    chartFrameMap.remove(clientGUI.getChart());
                    if(chartFrameMap.isEmpty()){
                        LOGGER.info("All charts closed, stopping the program");
                        System.exit(0);
                    }
                }
            });
        }
    });
}

0 件のコメント:

コメントを投稿