コード例 #1
0
ファイル: IBTrader.java プロジェクト: klon/jtrade
  public static void main(String[] args) {
    Trader trader = new IBTrader("localhost:4000", 22);

    Configurable.configure("jtrade.trader.IBTrader#ACCOUNT_CODE", "DU66791");

    try {
      // Symbol s = SymbolFactory.getESFutureSymbol(new DateTime());
      Symbol s = SymbolFactory.getSymbol("AAPL-SMART-USD-STOCK");

      trader.connect();
      Thread.sleep(2000);

      try {
        trader.placeOrder(s, 1, "testref1");
      } catch (Exception e) {
        e.printStackTrace();
      }
      Thread.sleep(2000);

      try {
        trader.placeOrder(s, -1, "testref2");
      } catch (Exception e) {
        e.printStackTrace();
      }
      Thread.sleep(2000);

      trader.cancelOrder(s, null);

    } catch (Exception e) {
      e.printStackTrace();
    } finally {
      trader.disconnect();
    }
  }
コード例 #2
0
ファイル: TestDummyTrader.java プロジェクト: klon/jtrade
  @BeforeClass
  public void setUp() {
    symbol = new Symbol("ABB-SFB-SEK-STOCK");
    date = new DateTime(2013, 1, 2, 0, 0, 0, 0);
    double[] opens = {5.0, 6.0, 7.0, 8.0};
    double[] highs = {7.0, 8.0, 9.0, 10.0};
    double[] lows = {4.0, 5.0, 6.0, 7.0};
    double[] closes = {5.0, 6.0, 7.0, 8.0};
    double[] waps = {5.0, 6.0, 7.0, 8.0};
    int[] volumes = {10, 20, 30, 40, 50};
    int[] trades = {1, 1, 1, 1, 1};
    marketFeed =
        new MockBarMarketFeed(symbol, 60, date, opens, highs, lows, closes, waps, volumes, trades);

    Configurable.configure("jtrade.trader.DummyTrader#EXECUTION_DELAY_MILLIS", 0);
  }