¿ªÔÆÌåÓý

ctrl + shift + ? for shortcuts
© 2025 Groups.io

odd error in IB trading account


Stuart Cracraft
 

¿ªÔÆÌåÓý

Hi,

I funded some money into the trading account AND picked 5 tickers to buy.

When I tried it, some (2) traded in okay for Monday¡¯s open at 630am.

MCRB and PRTY were successful at geting queued.

But the other three (ABML, ALPP, and DMGGF failed with this):

OpenOrder. ID: 57 ALPP STK @ SMART : BUY MKT 367.0 Inactive
OrderStatus. Id:??57 , Status:??Inactive , Filled:??0.0 , Remaining:??367.0 , LastFillPrice:??0.0
Error:??57???201???Order rejected - reason:Not allowed to open a position: no trading permission
OpenOrder. ID: 57 ALPP STK @ SMART : BUY MKT 367.0 Inactive


The code doing the submits is below and I¡¯m thinking that because it is hardwired to NASDAQ (contract.primaryExchange) but for example ALPP is OTC and same for ABML and DMGGF) but MCRB and PRTY are Nasdaq and NYSE) though why it would trade the NYSE one I don¡¯t know.

Is there code which is a little more forgiving for the market? And simply does the needful rather than just rejecting a trade?

Thoughts?

#!/usr/local/bin/python3

import sys

from ibapi.client import EClient
from ibapi.wrapper import EWrapper
from ibapi.contract import Contract
from ibapi.order import *
from threading import Timer

class TestApp(EWrapper, EClient):
? ? def __init__(self):
? ? ? ? EClient.__init__(self, self)

? ? def error(self, reqId , errorCode, errorString):
? ? ? ? print("Error: ", reqId, " ", errorCode, " ", errorString)

? ? def nextValidId(self, orderId ):
? ? ? ? self.nextOrderId = orderId
? ? ? ? self.start()

? ? def orderStatus(self, orderId , status, filled, remaining, avgFillPrice, permId, parentId, lastF
illPrice, clientId, whyHeld, mktCapPrice):
? ? ? ? print("OrderStatus. Id: ", orderId, ", Status: ", status, ", Filled: ", filled, ", Remaining
: ", remaining, ", LastFillPrice: ", lastFillPrice)

? ? def openOrder(self, orderId, contract, order, orderState):
? ? ? ? print("OpenOrder. ID:", orderId, contract.symbol, contract.secType, "@", contract.exchange,?
":", order.action, order.orderType, order.totalQuantity, orderState.status)

? ? def execDetails(self, reqId, contract, execution):
? ? ? ? print("ExecDetails. ", reqId, contract.symbol, contract.secType, contract.currency, executio
n.execId,
? ? ? ? ? ? ? execution.orderId, execution.shares, execution.lastLiquidity)

? ? def start(self):
? ? ? ? contract = Contract()
? ? ? ? contract.secType = "STK"
? ? ? ? contract.exchange = "SMART"
? ? ? ? contract.currency = "USD"
? ? ? ? contract.primaryExchange = "NASDAQ"

? ? ? ? order = Order()

? ? ? ? order.action = sys.argv[1]
? ? ? ? order.totalQuantity = sys.argv[2]
? ? ? ? contract.symbol = sys.argv[3]

?? ? ? ?

? ? ? ? print("Your command: ",sys.argv[0],sys.argv[1],sys.argv[2],sys.argv[3])

? ? ? ??

? ? ? ? order.orderType = "MKT"

? ? ? ? self.placeOrder(self.nextOrderId, contract, order)

? ? def stop(self):
? ? ? ? self.done = True
? ? ? ? self.disconnect()

def main():
? ? app = TestApp()
? ? app.nextOrderId = 0
? ? app.connect("127.0.0.1", 7497, 9)

? ? Timer(3, app.stop).start()
? ? app.run()

if __name__ == "__main__":
? ? main()

Join [email protected] to automatically receive all group messages.