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

Documentation for 'get_prices()' #27

Open
bolshoibooze opened this issue Jan 26, 2016 · 3 comments
Open

Documentation for 'get_prices()' #27

bolshoibooze opened this issue Jan 26, 2016 · 3 comments

Comments

@bolshoibooze
Copy link
Contributor

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!

@toloco
Copy link
Owner

toloco commented Jan 26, 2016

Thanks mate,
Do you mind to create a pull request? So your name will be there :)

Please add this as an example in the examples folder.

@bolshoibooze
Copy link
Contributor Author

Alright, will do so

@toloco
Copy link
Owner

toloco commented Jan 26, 2016

And any other sample is welcome too!!

Thanks a lot

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