I keep getting the below errors while testing the below code. I've a paper trading account with IB.
Not sure what exactly these errors are. Tried searching online but could not get any hint.
from ib.opt import Connection, message
from ib.ext.Contract import Contract as C
from ib.ext.Order import Order
import time
def make_contract(symbol,sec_type,exch,prim_exch,curr):
C.m_symbol=symbol
C.m_secType=sec_type
C.m_exch=exch
C.m_primaryExch=prim_exch
C.m_currency=curr
return C
def make_order(action,quantity,price=None):
if price is not None:
order=Order()
order.m_orderType = 'LMT'
order.m_totalQuantity = quantity
order.m_action = action
order.m_lmtprice = price
print(price)
else:
order=Order()
order.m_orderType = 'MKT'
order.m_totalQuantity = quantity
order.m_action = action
print('hi')
return order
def handleAll(msg):
print(msg)
cid = 103
conn = Connection.create(port=7497) #clietnID=888)
conn.connect()
conn.registerAll(handleAll)
oid = cid
cont = make_contract('AAPL','STK', 'SMART','SMART', 'USD')
offer = make_order('BUY', 1, 157)
conn.placeOrder(oid,cont,offer)
while 1:
time.sleep(1)