Giter Site home page Giter Site logo

v20-javascript-samples's Introduction

v20-javascript-samples

This repo contains a suite of Javascript (node) sample code that demonstrates the use of OANDA's v20 REST API along with OANDA's v20 bindings for Javascript. The samples are limited in scope, and will only be expanded based on demand. The intent of this repo is to provide some high-level examples which show how to use the Javascript bindings.

Configuration

Using OANDA's v20 REST API requires configuration that is used to set up connections and interact with the endpoints. This configuration includes hostnames, ports, tokens and account information.

The configuration is stored in a .yaml file with the format described in etc/v20.conf, and resembles the following:

hostname: api-fxpractice.oanda.com
streaming_hostname: stream-fxpractice.oanda.com
port: 443
ssl: true
token: e6ab562b039325f12a026c6fdb7b71bb-b3d8721445817159410f01514acd19hbc
username: user
accounts:
- 101-001-100000-001
- 101-001-100000-002
active_account: 101-001-100000-001

To use the configuration, each sample script must be run with the --config option that points to a valid config file. The default location of the config file is etc/v20.conf. To change the default location of the configuration file, the V20_CONF environment variable can be set. For example:

user@host: ~/v20-javascript-samples$ export V20_CONF=/home/user/v20.conf
user@host: ~/v20-javascript-samples$ node src/account_details.js

Sample Code

Following is a listing of the sample code provided.

Source File Description Example
src/account/details.js Fetch details for the configured Account user@host ~/v20-javascript-samples$ node src/account/details.js
src/order/market.js Create a Market Order in the configured Account user@host ~/v20-javascript-samples$ node src/order/market.js --instrument EUR/USD --units 100
src/transaction/stream.js Create an Account Transaction stream user@host ~/v20-javascript-samples$ node src/transaction/stream.js
src/pricing/stream.js Create an Account Pricing stream user@host ~/v20-javascript-samples$ node src/pricing/stream.js

v20-javascript-samples's People

Contributors

dmpettyp 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.