Code Monkey home page Code Monkey logo

pyoanda's People

Contributors

bitdeli-chef avatar bolshoibooze avatar tavurth avatar toloco avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyoanda's Issues

Request exception handling

The client __call catches AssertionError and raises a BadRequest instead. However most (or all?) methods that call __call themselves are trying to catch AssertionError, which will never actually be raised because __call already handles it.

The end result is that all of the "except AssertionError" blocks are never triggered and the exception is propagated instead of being caught, which is probably not intentional (I suspect that the custom BadRequest exception was implemented later).

However, I think it is actually useful to propagate the exceptions to that client code can handle them appropriately, instead of just returning a bool on an error, so I lean more towards removing all of those try/catch blocks entirely and changing the __call and __call_stream methods to raise something that allows users to determine the underlying problem and decide what they want to do.

Order.check() price validation

Order.check() currently verifies that the price is an integer or float; however floats suffer from inaccuracies due to floating point arithmetic. Generally I'm using decimal/cdecimal for safer calculations and it seems like allowing more values that look like numbers as well, e.g. by permitting anything that can be cast to a float or some other similar check.

Client: "The account ID provided is invalid"

Just followed instructions from README

Traceback (most recent call last):
File "oanda.py", line 54, in
access_token=API_TOKEN
File "/usr/local/lib/python2.7/site-packages/pyoanda/client.py", line 23, in init
if not self.get_credentials():
File "/usr/local/lib/python2.7/site-packages/pyoanda/client.py", line 36, in get_credentials
response = self._Client__call(uri=url)
File "/usr/local/lib/python2.7/site-packages/pyoanda/client.py", line 73, in __call
raise BadRequest(msg)
pyoanda.exceptions.BadRequest: OCode-404: The account ID provided is invalid

get_instrument_history missing 'includeFirst' param

missing 'includeFirst' param for get_instrument_history call

includeFirst: Optional A boolean field which may be set to “true” or “false”. If it is set to “true”, the candlestick covered by the start timestamp will be returned. If it is set to “false”, this candlestick will not be returned. This field exists so clients may easily ensure that they can poll for all candles more recent than their last received candle.

The default for includeFirst is “true” if the includeFirst parameter is not specified.

example fetch.ipynb not working

Example notebook pyoanda/examples/fetch.ipynb
produces error when trying to view on github, also same error when trying to downloand and view in Jupyter.

Documentation for 'get_prices()'

I spent a couple of hours trying to figure out stuff, so here's my simple usage example that you can add to the 'README' and 'readthedocs' 👍

     # get prices for a list of instruments
     pair_list = ['AUD_JPY','EUR_JPY','GBP_JPY','AUD_USD']
     c.get_prices(instruments=','.join(pair_list),stream=False)

     #json response::
     {u'prices': [{u'ask': 81.551,
         u'bid': 81.53,
         u'instrument': u'AUD_JPY',
         u'time': u'2016-01-26T07:39:56.525788Z'},
        {u'ask': 127.975,
         u'bid': 127.957,
         u'instrument': u'EUR_JPY',
         u'time': u'2016-01-26T07:39:55.712253Z'},
        {u'ask': 167.269,
         u'bid': 167.239,
         u'instrument': u'GBP_JPY',
         u'time': u'2016-01-26T07:39:58.333404Z'},
        {u'ask': 0.69277,
        u'bid': 0.6926,
        u'instrument': u'AUD_USD',
        u'time': u'2016-01-26T07:39:50.358020Z'}]}


     # simplistic way of extracting data from the json response::
     dataset = c.get_prices(instruments=','.join(pair_list),stream=False)

     aud_jpy = [d for d in dataset['prices'] if d['instrument']=='AUD_JPY']
     bid = [d['bid'] for d in aud_jpy][-1]
     ask = [d['ask'] for d in aud_jpy][-1]
     time = [d['time'] for d in aud_jpy][-1]

cheers!

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.