Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

execution error when running for some time. #53

Open
leolle opened this issue Aug 29, 2016 · 3 comments
Open

execution error when running for some time. #53

leolle opened this issue Aug 29, 2016 · 3 comments

Comments

@leolle
Copy link

leolle commented Aug 29, 2016

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.

@dieterjansen
Copy link

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.

@leolle
Copy link
Author

leolle commented Aug 30, 2016

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
Copy link
Author

leolle commented Aug 30, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants