Closed developeralgo8888 closed 7 years ago
@developeralgo8888 I ran all examples with Python 2.7.12 and Python 3.5.2 on Ubuntu 16.04 (which I'm using myself): they all work now also on python 3.5. Though there were some compatibility issues in using print and iteritems, all examples work.
Since you were able to retrieve data with candle_data.py I guess your account.txt and token.txt are OK.
You probably have a point regarding the UnboundLocal and I will look into that to modify it. But the exception block is not run during normal operation so this is no issue.
So to figure out what is going on:
please run all examples as: python src/
I saw that your experience is from the weekend. Sometimes the V20-API is down during the weekend, maybe that was the main issue.
If you still have problems please give feedback of the packages you have installed by issueing a: pip list. Also provide me the details of the examle as you ran it with parameters included.
Same error even now. No difference . The way the exception is written in Python 3.5.2 seems to be the issue. its trying to get a value 'e' that has already been deleted
@developeralgo8888 The exception code does't matter for the time being. The issue is that the exception occurs while it shouldn't.
please run:
python src/concurrent_stream.py --i EUR_USD
Outputs something like:
write tick record ...2017-01-31 19:00:47.003585
write change ...2017-01-31 19:00:47.514047
write tick record ...2017-01-31 19:00:47.752446
write tick record ...2017-01-31 19:00:48.005047
write tick record ...2017-01-31 19:00:50.250680
write event ...2017-01-31 19:00:51.492924
write tick record ...2017-01-31 19:00:51.999591
you should find the prices in prices.txt and events in events.txt In case of errors I would like you to provide me a pip list
Below is the error i am getting " Definately something wrong"
dev@DEEPGPU:~/Downloads/ALGODEV/oandapyV20-examples-master# python src/concurrent_stream.py --i EUR_USD Definitely something wrong:
here is the pip list alabaster (0.7.9) anaconda-clean (1.0) anaconda-client (1.6.0) anaconda-navigator (1.3.2) argcomplete (1.0.0) astroid (1.4.9) astropy (1.3) atari-py (0.0.18) Babel (2.3.4) backports.shutil-get-terminal-size (1.0.0) beautifulsoup4 (4.5.3) bitarray (0.8.1) blaze (0.10.1) bokeh (0.12.4) boto (2.45.0) Bottleneck (1.2.0) box2d-py (2.3.1) cffi (1.9.1) chardet (2.3.0) chest (0.2.3) click (6.7) cloudpickle (0.2.2) clyent (1.2.2) colorama (0.3.7) conda (4.3.8) conda-build (2.1.1) conda-verify (2.0.0) configobj (5.0.6) contextlib2 (0.5.4) cryptography (1.7.1) cycler (0.10.0) Cython (0.25.2) cytoolz (0.8.2) dask (0.13.0) datashape (0.5.4) decorator (4.0.11) dill (0.2.5) docutils (0.13.1) dynd (0.7.3.dev1) et-xmlfile (1.0.1) fastcache (1.0.2) filelock (2.0.7) Flask (0.12) Flask-Cors (3.0.2) gevent (1.2.1) greenlet (0.4.11) gym (0.7.2, /root/Downloads/gym) h5py (2.6.0) HeapDict (1.0.0) idna (2.2) imageio (2.1.1) imagesize (0.7.1) ipykernel (4.5.2) ipython (5.1.0) ipython-genutils (0.1.0) ipywidgets (5.2.2) itsdangerous (0.24) jdcal (1.3) jedi (0.9.0) Jinja2 (2.9.4) jsonschema (2.5.1) jupyter (1.0.0) jupyter-client (4.4.0) jupyter-console (5.0.0) jupyter-core (4.2.1) Keras (1.2.1) lazy-object-proxy (1.2.2) llvmlite (0.15.0) locket (0.2.0) lxml (3.7.2) MarkupSafe (0.23) matplotlib (1.5.3) mistune (0.7.3) mock (2.0.0) mpmath (0.19) mujoco-py (0.5.7) multipledispatch (0.4.9) nb-anacondacloud (1.2.0) nb-conda (2.0.0) nb-conda-kernels (2.0.0) nbconvert (4.2.0) nbformat (4.2.0) nbpresent (3.0.2) networkx (1.11) nltk (3.2.2) nose (1.3.7) notebook (4.3.1) numba (0.30.1) numexpr (2.6.1) numpy (1.11.3) numpydoc (0.6.0) oandapyV20 (0.2.2) odo (0.5.0) olefile (0.44) openpyxl (2.4.1) pachi-py (0.0.21) pandas (0.19.2) pandas-datareader (0.2.1) partd (0.3.7) pathlib2 (2.2.0) patsy (0.4.1) pbr (1.10.0) pep8 (1.7.0) pexpect (4.2.1) pickleshare (0.7.4) Pillow (4.0.0) pip (9.0.1) pkginfo (1.4.1) ply (3.9) prompt-toolkit (1.0.9) protobuf (3.1.0.post1) psutil (5.0.1) ptyprocess (0.5.1) py (1.4.32) pyasn1 (0.1.9) PyBrain (0.3.3) pycosat (0.6.1) pycparser (2.17) pycrypto (2.6.1) pycurl (7.43.0) pyflakes (1.5.0) pyglet (1.2.4) Pygments (2.1.3) pylint (1.6.4) PyOpenGL (3.1.0) pyOpenSSL (16.2.0) pyparsing (2.1.4) pytest (3.0.5) python-dateutil (2.6.0) pytz (2016.10) PyYAML (3.12) pyzmq (16.0.2) QtAwesome (0.4.1) qtconsole (4.2.1) QtPy (1.2.0) redis (2.10.5) requests (2.12.4) requests-file (1.4.1) rope-py3k (0.9.4.post1) scikit-image (0.12.3) scikit-learn (0.18.1) scipy (0.18.1) seaborn (0.7.1) setuptools (27.2.0) simplegeneric (0.8.1) singledispatch (3.4.0.3) six (1.10.0) snowballstemmer (1.2.1) sockjs-tornado (1.0.3) Sphinx (1.5.1) spyder (3.1.0) SQLAlchemy (1.1.4) statsmodels (0.6.1) sympy (1.0) tables (3.3.0) tensorflow (0.12.1) terminado (0.6) Theano (0.9.0.dev5) toolz (0.8.2) tornado (4.4.2) traitlets (4.3.1) unicodecsv (0.14.1) urllib3 (1.20) urwid (1.3.1) urwid-geventloop (0.0.0.dev0) urwidtrees (1.0.1.1) wcwidth (0.1.7) Werkzeug (0.11.15) wheel (0.29.0) widgetsnbextension (1.2.6) wrapt (1.10.8) xlrd (1.0.0) XlsxWriter (0.9.6) xlwt (1.2.0)
packages seem OK (but I would suggest you to use virtualenv)
please run:
python src/candle-data.py --i EUR_USD --gran M5 --count 2 --nice
also
Got this ,
dev@DEEPGPU:~/Downloads/ALGODEV/oandapyV20-examples-master# python src/candle-data.py --i EUR_USD --gran M5 --count 2 --nice { "instrument": "EUR_USD", "candles": [ { "mid": { "h": "1.07888", "l": "1.07862", "o": "1.07865", "c": "1.07874" }, "time": "2017-01-31T18:25:00.000000000Z", "complete": true, "volume": 72 }, { "mid": { "h": "1.07892", "l": "1.07868", "o": "1.07871", "c": "1.07892" }, "time": "2017-01-31T18:30:00.000000000Z", "complete": false, "volume": 27 } ], "granularity": "M5" }
... account and token are proven OK
Before we started the conversation I've created a fix-unboundlocal branch with the exception fix. Currently the branch only contains the fix for 'concurrent_stream.py'. Please check it out and run it.
In my opinion it still should fail, but lets check that out.
account and token are ok since i am able to download data .
i only updated the concurrent_stream.py from the fix_un....... branch and i now get this error
dev@DEEPGPU:~/Downloads/ALGODEV/oandapyV20-examples-master# python src/concurrent_stream.py --i EUR_USD
Traceback (most recent call last):
File "src/concurrent_stream.py", line 228, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "src/concurrent_stream.py", line 230, in
please edit concurrent_stream.py and make line 230:
print("V20Error : {} {}".format(e.code, e.msg))
and try again
modified and got
dev@DEEPGPU:~/Downloads/ALGODEV/oandapyV20-examples-master# python src/concurrent_stream.py --i EUR_USD
Traceback (most recent call last):
File "src/concurrent_stream.py", line 228, in
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "src/concurrent_stream.py", line 230, in
V20Error : 401
That is an 'unauthorized' according to the docs of OANDA: http://developer.oanda.com/rest-live-v20/troubleshooting-errors/#401
Things you could do:
running this shellscript:
#!/bin/bash
# provide account and token in variables below
ACCT="..."
TOK="..."
curl \
-w "%{http_code}" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $TOK" \
"https://stream-fxpractice.oanda.com/v3/accounts/$ACCT/pricing/stream?instruments=EUR_USD"
should give you the 401 too. Normally it should give you the tick records. Please run it. It should fail.
i figured out what was causing the error. I do appreciate your help. thank you
Accounts for V1 have the format XXXXXXX
Accounts for V20 (V3) have BBB-XXX-ZZZZZZZ-YYY
and as you said to regenerate the API token again.
It works now
... yes ... for the candle_data the account is not needed, so that one worked. Well enjoy the examples. I will fix the Unbound.... try/except blocks.
getting this error when running several examples in stream.py , concurrent_Stream.py and others
i am running Python 3.5 on UBUNTU 16.04 . I have all the requirements install and working . It seems the error is being raised after the local variable has beeb deleted as in Python 3.X
dev@developer:~/Downloads/ALGODEV/oandapyV20-examples-master# python src/oanda_console.py Traceback (most recent call last): File "/home/anaconda3/lib/python3.5/site-packages/gevent/greenlet.py", line 536, in run result = self._run(*self.args, **self.kwargs) File "/dev/Downloads/ALGODEV/oandapyV20-examples-master/src/console/greenlets/accountdetails.py", line 24, in _run rv = self.api.request(r) File "/home/anaconda3/lib/python3.5/site-packages/oandapyV20/oandapyV20.py", line 306, in request request_args, headers=headers) File "/home/anaconda3/lib/python3.5/site-packages/oandapyV20/oandapyV20.py", line 243, in __request response.content.decode('utf-8')) oandapyV20.exceptions.V20Error Sun Jan 29 21:40:34 2017 <GAccountDetails at 0x7f0372cf8898> failed with V20Error
Traceback (most recent call last): File "/home/anaconda3/lib/python3.5/site-packages/gevent/greenlet.py", line 536, in run result = self._run(*self.args, self.kwargs) File "/dev/Downloads/ALGODEV/oandapyV20-examples-master/src/console/greenlets/stream.py", line 59, in _run raise e UnboundLocalError: local variable 'e' referenced before assignment**
in candle_data.py i am able to pull down the Data without any issues. The issues start when it goes through a try/except block
In concurrent_stream.py
def _run(self):
throws the above error
in stream.py the try/except block throws an error also