Open houmie opened 7 years ago
@houmie
Hi, please check the examples repo: https://github.com/hootnot/oandapyV20-examples
it has a candle-data application and different streaming examples
Also check the docs: http://oanda-api-v20.readthedocs.io/en/latest/oandapyV20.endpoints.html#module-oandapyV20.endpoints.instruments
Thanks for the pointers, apologies if I ask strange questions, as I'm new to the wrapper and trading in general.
I have followed your advice and have tried this:
api = oandapyV20.API(environment="practice", access_token=OANDA_ACCESS_TOKEN)
r = instruments.InstrumentsCandles(instrument="EUR_USD")
response = api.request(r)
prices = response.get("candles")
Problem is that I don't see the bid price on that list. Am I completely off with my approach or just don't see the wood for the trees?
You only see the mid prices with the granularity of S5 because these are the defaults. If you want something different you will need to specify it.
I've extended the candle-data example with the price parameter .
The params parameter simply accepts all the parameters as they are in the specs of OANDA's REST V20 docs, see developer.oanda.com/rest-live-v20
So if you pass:
params={'count': 2, 'price': 'B', 'granularity': 'M5'}
you will get the 'bid', pass 'BA' you get 'bid/ask', run the example:
python src/candle-data.py --count 1 --price MBA --i EUR_USD --gr M5 --nice
{
"candles": [
{
"complete": false,
"bid": {
"h": "1.06224",
"c": "1.06224",
"l": "1.06216",
"o": "1.06216"
},
"mid": {
"h": "1.06230",
"c": "1.06230",
"l": "1.06223",
"o": "1.06223"
},
"volume": 6,
"time": "2016-12-01T06:35:00.000000000Z",
"ask": {
"h": "1.06236",
"c": "1.06236",
"l": "1.06230",
"o": "1.06230"
}
}
],
"instrument": "EUR_USD",
"granularity": "M5"
}
Hi, how do you specify in the instruments.InstrumentsCandles() params the dailyalignment or the weeklyalignment? for the daily OHLC data?, or can I modify the UTC timezone for the daily data in some way?, im getting different data from the Oanda page and from the oandapyV20 when I retrieve the daily data.
Hi, you are posting in the oanda repo, but reading your post you seem to use oandapyV20.
Regarding oandapV20: every parameter you find in the docs under request parameters can be passed via the params dict. So, that also goes for the alignment parameters. https://developer.oanda.com/rest-live-v20/instrument-ep/
If you have questions regarding data differences, pls drop those at OANDA, maybe api@oanda.com
Hi,
I think there is a need for a cheat sheet to migrate the old to the new version.
e.g. how do I do get_prices now in V2?
Many Thanks, Houman