Last active
October 15, 2016 11:22
-
-
Save ranaroussi/84103aaa8695a5642ebb1da2707cad40 to your computer and use it in GitHub Desktop.
using ezIBpy to create a bracket order for AAPL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import ezibpy | |
import time | |
# initialize ezIBpy | |
ibConn = ezibpy.ezIBpy() | |
ibConn.connect(clientId=100, host="localhost", port=4001) | |
# create a contract | |
contract = ibConn.createStockContract("AAPL") | |
# submit a bracket order (entry=0 = MKT order) | |
order = ibConn.createBracketOrder(contract, quantity=100, entry=0, target=120., stop=116.) | |
# let order fill | |
time.sleep(3) | |
# see the positions | |
print("Positions") | |
print(ibConn.positions) | |
# disconnect | |
ibConn.disconnect() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment