Giter Club home page Giter Club logo

fetch_oandata's Introduction

fetch_oandata

It fetches price data from Oanda using its python bindings for REST API v20.

Requirements

To use the fetcher, you need python 3 with packages v20 and pandas installed. They can be installed individually or by

pip install -r requirements.txt

Configuration

Configuration parameters for communicating with Oanda servers are stored in a config file. A sample config file may look like:

[DEFAULT]
hostname = api-fxpractice.oanda.com
port = 443
ssl = true
token = XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
datetime_format = RFC3339

where token is required to grant access to the REST API. See developer page of Oanda website to see how to sign up and get a free access token.

Examples

After preparing a config file, you can run fetcher to get price data. For instance,

python3 fetch_oandata.py EUR_USD 2020-04-05 2020-05-16 -g M30 -c /path/to/config -o /path/to/csv

fetches the price of EURO in USD within the given period with granularity of 30 minutes. The result is stored in the given CSV file. By default the mid price of the instrument is fetched. To obtain bid or ask prices, -p B or -p A can be added to the list of arguments, respectively. To see the supported granularity and a complete list of arguments, run

python3 fetch_oandata -h

If the given period is long and granularity is fine, i.e. historical price data contain lots of candle sticks, fetching them will sometimes get failed. To mitigate the problem, the period is split into several sub-intervals, each holding a fewer number of candle sticks. The number of those sub-intervals can be set by --split or -s. Adding -s 10 to the list of arguments above, for example, splits the period into 10 sub-intervals of roughly the same size and fetch the prices for each sub-interval individually before merging them together. If it is not set, it will be computed according to the given period and granularity.

Fetch of price data for each sub-interval can nevertheless fail for other reasons. In this case, the fetcher retries again. The number of attempts before reporting failure can be set via -r.

fetch_oandata's People

Contributors

hhatefi avatar

Watchers

James Cloos avatar

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.