I have a test algorithm just to test my API connection and orders.
I run the python module and make a connection (I receive a notification from IBKR to accept incoming connection and I accept) but the problem is the order doesn't show up nor come through.
from ib.opt import Connection, message
from ib.ext.Contract import Contract
from ib.ext.Order import Order
def make_contract(symbol, sec_type, exch, prim_exch, curr):
Contract.m_symbol = symbol
Contract.m_secType = sec_type
Contract.m_exchange = exch
Contract.m_primaryExch = prim_exch
Contract.m_currency = curr
return Contract
def make_order(order_type, action, quantity):
order = Order()
order.m_orderType = order_type
order.m_totalQuantity = quantity
order.m_action = action
return order
def main():
conn = Connection.create(port=**** , clientId=***)
conn.connect()
oid = 200
cont = make_contract('TSLA', 'STK' , 'SMART' , 'SMART' , 'USD')
offer = make_order('MKT' , 100 , 'BUY')
conn.placeOrder (oid , cont , offer)
conn.disconnect()
main()