forked from lynxbroker/API-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
28 lines (23 loc) · 983 Bytes
/
Copy pathMain.java
File metadata and controls
28 lines (23 loc) · 983 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (C) 2019 LYNX B.V. All rights reserved.
import com.ib.client.Contract;
public class Main {
public static void main(String[] args){
// Init twsConnection Object, see TWSConnection.java file
TWSConnection twsConnection = new TWSConnection();
twsConnection.makeConnection();
// Define Contract details
Contract example_contract = new Contract();
example_contract.localSymbol("USD.CAD");
example_contract.secType("CASH");
example_contract.currency("CAD");
example_contract.exchange("IDEALPRO");
// Define Order details
Order example_order = new Order();
example_order.action("BUY");
example_order.orderType("LMT");
example_order.totalQuantity(10);
example_order.lmtPrice(1.34);
// Send the order request to the API
TWSConnection.INSTANCE.client.placeOrder(1, example_contract, example_order);
}
}