Giter VIP home page Giter VIP logo

Comments (12)

happydasch avatar happydasch commented on June 14, 2024

Hi, it seems that your internet connection goes away maybe? It will stop working if there are connection errors. Also reconnection is not implemented, so this'll be most likely the case here?

You may check these config values:

  - ``account_poll_freq`` (default: ``10.0``): refresh frequency for account
    value/cash refresh
 - ``stream_timeout`` (default: ``10``): timeout for stream requests
 - ``poll_timeout`` (default: ``2``): timeout for poll requests

from btoandav20.

algoeng avatar algoeng commented on June 14, 2024

I am pretty sure it's not connection errors. This runs in a docker image on a AWS instance. Previously I ran code that directly interacted with Oanda streaming APIs and I know it is possible that the stream stop responding. But that was like once a week, and definitely not this often.
I think the only relevant timeout value is the stream_timeout. Are you suggesting I increase or decrease the stream_timeout? Would it even help since re-connection is not implemented?

from btoandav20.

happydasch avatar happydasch commented on June 14, 2024

you could try to increase the stream_timeout, but I doubt it will be an improvement. Alternatively you could restart backtrader every n hours. Sorry.

from btoandav20.

algoeng avatar algoeng commented on June 14, 2024

NP. Can we make this a feature request to implement re-connect?

from btoandav20.

happydasch avatar happydasch commented on June 14, 2024

I leave this issue open, but I am not really sure, when I will have the time to implement reconnection functionality. Maybe someone will provide a patch.

from btoandav20.

algoeng avatar algoeng commented on June 14, 2024

@happydasch I noticed that when I remove compression and just look at pure minute data, next() doesn't get called on candles with the same open and closed price (even if high and lows are different from the previous candle). Is this expected? And if so, is there a way we can force it to call next even with open close prices being the same?
This might cause next() on compression > 1 not get called when it doesn't have enough candles to form it.

from btoandav20.

happydasch avatar happydasch commented on June 14, 2024

Yes, no new price, then oanda does not stream a new price.

If you need this unchanged values, you need to create a feed in backtrader with the Filter fill_gaps .

from btoandav20.

maxsonic avatar maxsonic commented on June 14, 2024

Anyone see this issue happens again? I am not using backtrader, but seems like after some time, the streaming is not responding for more than 10 seconds. Then one needs to reconnect the stream to get the data again. This will be very unreliable for the data integrity.
I sent mail to Oanda, but with no reply for this issue.

from btoandav20.

booboothefool avatar booboothefool commented on June 14, 2024

This happens for me after about an hour pretty consistently. Eventually I'll get a timeout that looks like this.

Exception in thread Thread-2:
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 384, in _make_request
    six.raise_from(e, None)
  File "<string>", line 2, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 380, in _make_request
    httplib_response = conn.getresponse()
  File "/Users/a/opt/anaconda3/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/Users/a/opt/anaconda3/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/Users/a/opt/anaconda3/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/Users/a/opt/anaconda3/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 307, in recv_into
    raise timeout('The read operation timed out')
socket.timeout: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 638, in urlopen
    _stacktrace=sys.exc_info()[2])
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 367, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 686, in reraise
    raise value
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 600, in urlopen
    chunked=chunked)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 386, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 306, in _raise_timeout
    raise ReadTimeoutError(self, url, "Read timed out. (read timeout=%s)" % timeout_value)
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api-fxpractice.oanda.com', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/v20/__init__.py", line 306, in request
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api-fxpractice.oanda.com', port=443): Read timed out. (read timeout=2)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/btoandav20/stores/oandav20store.py", line 493, in _t_account
    response = self.oapi.account.summary(self.p.account)
  File "/usr/local/lib/python3.7/site-packages/v20/account.py", line 1516, in summary
    response = self.ctx.request(request)
  File "/usr/local/lib/python3.7/site-packages/v20/__init__.py", line 313, in request
    raise V20Timeout(url, "read")
v20.errors.V20Timeout: v20 REST request to https://api-fxpractice.oanda.com:443/v3/accounts/x/summary has timed out (read)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/a/opt/anaconda3/lib/python3.7/threading.py", line 926, in _bootstrap_inner
    self.run()
  File "/Users/a/opt/anaconda3/lib/python3.7/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.7/site-packages/btoandav20/stores/oandav20store.py", line 497, in _t_account
    print(e, response.get('errorMessage'))
  File "/usr/local/lib/python3.7/site-packages/v20/response.py", line 35, in get
    raise ResponseNoField(self, field)
v20.errors.ResponseNoField: 200 response for GET https://api-fxpractice.oanda.com:443/v3/x/summary does not have field 'errorMessage' (contains 'account', 'lastTransactionID')

from btoandav20.

leecallen35 avatar leecallen35 commented on June 14, 2024

I am having the same issue as reported by bootthefuel, but the line number is different. I will open a new thread (issues) for this.

Edit: Before opening a new issue, I will run this on AWS and simultaneously run continuous ping tests to ensure I am not losing my internet connection.

from btoandav20.

pablonosh avatar pablonosh commented on June 14, 2024

Having the exact same issue as above, @happydasch any pointers on a fix? what's weird is it looks like the streams reconnect, as I get the same error multiple times. but no data.

From the below output log it appears it does reconnect but from experience it seems most of the time it doesn't get another candle. What's odd is below I get a candle after a reconnect.

I'm aware this is demo account, but still get on live as well.

<-- 1h candle received after restart at 04:26
<--- at 04:32 timed out with:
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
<-- as no bar received between 05:00 and 05:29 my script restarts.

<-- signal received after restart at 05:29
<-- at 05:39 I get time out
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
<-- at 05:54 I get this twice
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
<-- at 05:56 I get it again
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
<-- at 06:34 I get it again
***** STORE NOTIF: v20 REST request to https://api-fxpractice.oanda.com:443/v3/instruments/AUD_USD/candles has timed out (read)
<-- 06:00 signal received without restart (this is rare)

from btoandav20.

happydasch avatar happydasch commented on June 14, 2024

please check the latest commit, this should fix your issues

from btoandav20.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.