Oanda forex candle API built on top of oandapyV20
Project description
oanda-candles
Oanda forex candle API built on top of oandapyV20
Oanda Access Token
Using this package requires an access token to a user's Oanda brokerage account. This module only uses the token to request candle data, but such tokens can be used to make trades on the account. It is recommended that access tokens from a demo as opposed to a live accounts be used.
Demo account tokens can be generated by a signed in user here:
https://www.oanda.com/demo-account/tpa/personal_token
Quick Example
Supposing that token
is set to an Oanda access token, one could print
the opening bid price of the latest 100 trading hours for the Aussie like this:
from oanda_candles import CandleRequester, Pair, Gran
aud_usd = Pair("audusd")
requester = CandleRequester(token, aud_usd, Gran.H1)
candles = requester.request(count=100)
for candle in candles:
print(candle.bid.o)
Summary of Basic Usage
- A
CandleRequester
object is initialized with a token, forex pair, and granularity. - Its
request
method is called specifying starting time, ending time, and/or count of the candle range desired. - This returns a
CandleSequence
object containingCandle
objects as well as the pair and granularity. - Each
Candle
has threeOhlc
objects, one for Bid, Mid, and Ask prices. - The
Ohlc
objects have open, high, low, and closePrice
objects
Understanding Request Ranges
The CandleRequester.request()
has start
, end
, and count
optional parameters used to specify how many candles and from when.
parameter | valid types | valid range | default |
---|---|---|---|
start | TimeInt, datetime, None | epoch to now | -- |
end | TimeInt, datetime, None | epoch to now | now |
count | int, None | 1 to 5000 | 500 |
It does not make sense to set all three of these parameters, but you can specify any single one of them, or any two of them, or none of them. The behavior for when they are set or unset is shown in this table:
start | end | count | behavior |
---|---|---|---|
-- | -- | -- | Get latest 500 candles |
-- | -- | set | Get latest count candles |
-- | set | -- | Get last 500 candles up until the end time |
-- | set | set | Get last count candles up until the end time |
set | -- | -- | Get the first 500 candles from start time |
set | -- | set | Get the first count candles from start time |
set | set | -- | Get candles from start to end times |
set | set | set | ValueError (there might be a different count in the range) |
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for oanda_candles-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 59bb2c00e2e44c5531df219717686f9d32a10a2cb46458b18e6655a551c810e2 |
|
MD5 | d856fa688141b2e5c45db2b8a5459f7f |
|
BLAKE2b-256 | 2315b1b896876fcfec8865bc28b945f9d19c93ebbb6e11a373a86899b165e304 |