Closed pareeohnos closed 3 years ago
When I close a position, the trade disappears and then the app crashes
The trade should be closed, but shouldn't be deleted. The app should not crash
Relevant log section
INFO:werkzeug:127.0.0.1 - - [28/Sep/2021 00:06:44] "POST /trades/1/close HTTP/1.1" 200 - INFO:ibapi.client:SENDING placeOrder b'\x00\x00\x01:3\x00555\x000\x00AAPL\x00STK\x00\x000.0\x00\x00\x00SMART\x00\x00USD\x00\x00\x00\x00\x00SELL\x0075.0\x00MKT\x00\x00\x00\x00\x00\x00\x000\x00\x001\x000\x000\x000\x000\x000\x000\x000\x00\x000\x00\x00\x00\x00\x00\x00\x00\x000\x00\x00-1\x000\x00\x00\x000\x00\x00\x001\x001\x00\x000\x00\x00\x00\x00\x00\x000\x00\x00\x00\x00\x000\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x000\x00\x00\x000\x000\x00\x00\x000\x00\x000\x000\x000\x000\x00\x001.7976931348623157e+308\x001.7976931348623157e+308\x001.7976931348623157e+308\x001.7976931348623157e+308\x001.7976931348623157e+308\x000\x00\x00\x00\x001.7976931348623157e+308\x00\x00\x00\x00\x000\x000\x000\x00\x00' INFO:ibapi.client:REQUEST cancelOrder {'orderId': 554} INFO:ibapi.client:SENDING cancelOrder b'\x00\x00\x00\x084\x001\x00554\x00' INFO:ibapi.wrapper:ANSWER error {'reqId': 555, 'errorCode': 2168, 'errorString': "Warning: The 'EtradeOnly' order attribute is not supported."} ERROR:ibapi.wrapper:ERROR 555 2168 Warning: The 'EtradeOnly' order attribute is not supported. INFO:ibapi.wrapper:ANSWER error {'reqId': 555, 'errorCode': 2169, 'errorString': "Warning: The 'FirmQuoteOnly' order attribute is not supported."} ERROR:ibapi.wrapper:ERROR 555 2169 Warning: The 'FirmQuoteOnly' order attribute is not supported. INFO:werkzeug:127.0.0.1 - - [28/Sep/2021 00:06:44] "OPTIONS /trades/1 HTTP/1.1" 200 - INFO:werkzeug:127.0.0.1 - - [28/Sep/2021 00:06:44] "DELETE /trades/1 HTTP/1.1" 200 - INFO:ibapi.wrapper:ANSWER tickString {'reqId': 552, 'tickType': 48, 'value': '144.47;25.0000000000000000;1632751604613;177457.0000000000000000;144.5486743;false'} INFO:ibapi.wrapper:ANSWER tickString {'reqId': 552, 'tickType': 84, 'value': 'D'} INFO:ibapi.wrapper:ANSWER tickPrice {'reqId': 552, 'tickType': 4, 'price': 144.48, 'attrib': 2912071928656: CanAutoExecute: 0, PastLimit: 0, PreOpen: 0} INFO:werkzeug:127.0.0.1 - - [28/Sep/2021 00:06:44] "GET /socket.io/?EIO=4&transport=polling&t=Nmdb5A8&sid=JeWpuWKA8soLl8dyAAAA HTTP/1.1" 200 - INFO:ibapi.wrapper:ANSWER tickSize {'reqId': 552, 'tickType': 5, 'size': 20} INFO:ibapi.wrapper:ANSWER tickSize {'reqId': 552, 'tickType': 5, 'size': 20} INFO:ibapi.wrapper:ANSWER tickSize {'reqId': 552, 'tickType': 8, 'size': 176955} INFO:ibapi.wrapper:ANSWER orderStatus {'orderId': 554, 'status': 'Cancelled', 'filled': 0.0, 'remaining': 75.0, 'avgFillPrice': 0.0, 'permId': 718392687, 'parentId': 553, 'lastFillPrice': 0.0, 'clientId': 1, 'whyHeld': '', 'mktCapPrice': 0.0} INFO:ibapi.wrapper:ANSWER error {'reqId': 554, 'errorCode': 202, 'errorString': 'Order Canceled - reason:'} ERROR:ibapi.wrapper:ERROR 554 202 Order Canceled - reason: INFO:ibapi.client:disconnecting INFO:ibapi.wrapper:ANSWER connectionClosed {} Exception in thread Thread-12: Traceback (most recent call last): File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\threading.py", line 973, in _bootstrap_inner self.run() File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\threading.py", line 910, in run self._target(*self._args, **self._kwargs) File "C:\Users\pc_mo\PycharmProjects\ktrade\ktrade\providers\ib_provider.py", line 205, in ib_loop self.api.run() File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\ibapi\client.py", line 263, in run self.decoder.interpret(fields) File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\ibapi\decoder.py", line 1294, in interpret self.interpretWithSignature(fields, handleInfo) File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\ibapi\decoder.py", line 1275, in interpretWithSignature method(*args) File "C:\Users\pc_mo\PycharmProjects\ktrade\ktrade\providers\ib\api.py", line 277, in error trade_failed(trade, errorString) File "C:\Users\pc_mo\PycharmProjects\ktrade\ktrade\provider_actions.py", line 40, in trade_failed trade = Trade.find(session, trade.id) File "C:\Users\pc_mo\PycharmProjects\ktrade\ktrade\models.py", line 13, in find return session.query(cls).filter_by(id=id).one() File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\orm\query.py", line 2730, in one return self._iter().one() File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\engine\result.py", line 1373, in one return self._only_one_row(True, True, False) File "C:\Users\pc_mo\AppData\Local\Programs\Python\Python39\lib\site-packages\sqlalchemy\engine\result.py", line 562, in _only_one_row raise exc.NoResultFound( sqlalchemy.exc.NoResultFound: No row was found when one was required
What is the issue
When I close a position, the trade disappears and then the app crashes
What should happen
The trade should be closed, but shouldn't be deleted. The app should not crash
Other info
Relevant log section