qsforex icon indicating copy to clipboard operation
qsforex copied to clipboard

execution error when running for some time.

Open leolle opened this issue 7 years ago • 3 comments

2016-08-22 20:01:33,803 - qsforex.trading.trading - INFO - Received new order event: Type: ORDER, Instrument: GBPUSD, Units: 2000, Order Type: market, Side: buy Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(_self.__args, *_self.__kwargs) File "trading/roc.py", line 45, in trade execution.execute_order(event) File "/home/weiwu/.virtualenvs/qsforex/local/lib/python2.7/site-packages/qsforex/execution/execution.py", line 73, in execute_order response = self.conn.getresponse().read().decode("utf-8").replace("\n","").replace("\t","") File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse response.begin() File "/usr/lib/python2.7/httplib.py", line 415, in begin version, status, reason = self._read_status() File "/usr/lib/python2.7/httplib.py", line 379, in _read_status raise BadStatusLine(line) BadStatusLine: ''

2016-08-22 21:15:34,320 - qsforex.trading.trading - INFO - Received new order event: Type: ORDER, Instrument: GBPUSD, Units: 2000, Order Type: market, Side: sell Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(_self.__args, *_self.__kwargs) File "trading/roc.py", line 45, in trade execution.execute_order(event) File "/home/weiwu/.virtualenvs/qsforex/local/lib/python2.7/site-packages/qsforex/execution/execution.py", line 71, in execute_order params, headers File "/usr/lib/python2.7/httplib.py", line 979, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request self.putrequest(method, url, **skips) File "/usr/lib/python2.7/httplib.py", line 877, in putrequest raise CannotSendRequest() CannotSendRequest

After this error the trade thread is dead, the program will only show price streaming debug log into the console. how to solve this? thank you.

leolle avatar Aug 29 '16 22:08 leolle

Hi Leolle,

Some discussion on Michael’s blog suggested that that error comes up if a position is held a long time (infrequent ticks) and here in Australia I used to observe it after about half an hour when running the demo strategy against the Euro outside the main EUR trading session.

The solution suggested in the blog was in execution/execution.py to change the last few lines: response = self.conn.getresponse().read().decode("utf-8").replace("\n","").replace("\t","") self.logger.debug(response) ... by adding a line to make it: response = self.conn.getresponse().read().decode("utf-8").replace("\n","").replace("\t","") self.logger.debug(response) self.conn.close() After this change I was able to run QSForex outside the main EUR trading session for several hours without a problem.

I don’t recall if I’ve put in a pull request with this change as I don’t think Michael has been doing updates to QSForex (understandably as there is a lot of work happening on QSTrader at the moment.

Hope that lets you run for longer.

Cheers, Dieter.

From: leolle Sent: Tuesday, August 30, 2016 8:14 AM To: mhallsmoore/qsforex Subject: [mhallsmoore/qsforex] execution error when running for some time. (#53)

2016-08-22 20:01:33,803 - qsforex.trading.trading - INFO - Received new order event: Type: ORDER, Instrument: GBPUSD, Units: 2000, Order Type: market, Side: buy Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(self.__args, *self.__kwargs) File "trading/roc.py", line 45, in trade execution.execute_order(event) File "/home/weiwu/.virtualenvs/qsforex/local/lib/python2.7/site-packages/qsforex/execution/execution.py", line 73, in execute_order response = self.conn.getresponse().read().decode("utf-8").replace("\n","").replace("\t","") File "/usr/lib/python2.7/httplib.py", line 1051, in getresponse response.begin() File "/usr/lib/python2.7/httplib.py", line 415, in begin version, status, reason = self._read_status() File "/usr/lib/python2.7/httplib.py", line 379, in _read_status raise BadStatusLine(line) BadStatusLine: ''

2016-08-22 21:15:34,320 - qsforex.trading.trading - INFO - Received new order event: Type: ORDER, Instrument: GBPUSD, Units: 2000, Order Type: market, Side: sell Exception in thread Thread-1: Traceback (most recent call last): File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner self.run() File "/usr/lib/python2.7/threading.py", line 763, in run self.__target(self.__args, _self.__kwargs) File "trading/roc.py", line 45, in trade execution.execute_order(event) File "/home/weiwu/.virtualenvs/qsforex/local/lib/python2.7/site-packages/qsforex/execution/execution.py", line 71, in execute_order params, headers File "/usr/lib/python2.7/httplib.py", line 979, in request self._send_request(method, url, body, headers) File "/usr/lib/python2.7/httplib.py", line 1007, in _send_request self.putrequest(method, url, *_skips) File "/usr/lib/python2.7/httplib.py", line 877, in putrequest raise CannotSendRequest() CannotSendRequest

After this error the trade thread is dead, the program will only show price streaming debug log into the console. how to solve this? thank you.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

dieterjansen avatar Aug 29 '16 23:08 dieterjansen

Thank you Dieter. I am trying your suggestion. I am modifying like this and hoping it running well.

    try:
        response = self.conn.getresponse().read().decode("utf-8").replace("\n","").replace("\t","")
    except :
        print ("error here")
        self.conn.close()
    self.logger.debug(response)

leolle avatar Aug 30 '16 01:08 leolle

@dieterjansen the order execution program is down after running for 3 hours.

leolle avatar Aug 30 '16 03:08 leolle