npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cloud9trader/oanda-adapter

v2.3.4

Published

Node.js adapter for OANDA's v20 REST and streaming API.

Downloads

20

Readme

@cloud9trader/oanda-adapter

Node.js adapter for OANDA's v20 REST and streaming API, from Cloud9Trader.

  • Provides a single interface for requesting data and streaming prices and account updates.

  • Smooths over polling and streaming endpoints for account updates and pricing for consistent subscriber methods.

  • Handles streaming connection loss and heartbeat timeout and retires connection.

  • Manages multiple price subscriptions and changes to the subscribed instrument list over a single long polling request.

  • Rate limits REST requests according to OANDA limit with automatic queuing for delayed execution and warning logs.

  • Returns instances from OANDA's definitions library at https://github.com/oanda/v20-javascript for editor code hinting and content assist.

  • OANDA endpoints return data specific to your account. Retrieves default account ID so client does not need to specify.

See also OANDA's v20 REST API documentation for reference.

API Compatibility

This is compatible with OANDA's v20 APIs. If your account ID contains only digits (eg. 2534253), you have a v1 account - please use version 1.0.0 of this module.

Installation

npm install @cloud9trader/oanda-adapter

API Overview

const OANDAAdapter = require("@cloud9trader/oanda-adapter")

const client = new OANDAAdapter({
    // 'live' or 'practice'
    environment: "live",
    // Generate your API access token in the 'Manage API Access' section of 'My Account' on OANDA's website
    accessToken: "<token>"
})

startAccountPolling(listener[, context]);

Starts polling for account changes and subscribes for incoming updates.

client.startAccountPolling(({changes: AccountChanges, state: AccountChangesState, lastTransactionID: string}) => {
    // ...
})

subscribeTransactions(listener, context)

Subscribes to the transaction feed.

getInstruments(accountId?, callback)

List instruments available to an account. Pass null as accountId to use default. callback is called with the following arguments:

  • error
  • Array[Instrument] Array of available instruments

subscribePrice(accountId?, instrument, listener[, context]);

Subscribes to rates stream for a single instrument. Use getInstruments() to retrieve list of available instruments. A single streaming request will be managed as you subscribe to various instruments. If null is passed as accountId, the default account will be fetched. Optionally pass a context for the listener to be bound to.

client.subscribePrice(null, "EUR_USD", (ClientPrice) => {
    // ...
})

getAccounts(callback)

List accounts for a user. callback is called with the following arguments:

  • error
  • Array[AccountProperties] Array of accounts available under current access

getDefaultAccountId(callback)

Gets the default account ID. callback is called with the following arguments:

  • error
  • accountId

getAccount(accountId, callback)

Get account information. callback is called with the following arguments:

  • error
  • Account Object representing account information

getPrice(accountId?, instrument, callback)

Gets the current price of an instrument. If null is passed as accountId, the default account will be fetched. instrument can be an array to retrieve multiple prices. callback is called with the following arguments:

  • error
  • ClientPrice or Array[ClientPrice] Object representing current price, or array containing them.

getCandles(accountId?, instrument, from, to, interval, callback)

Get interval bars for instrument between time range. If null is passed as accountId, the default account will be fetched. interval is one of [S5, S10, S15, S30, M1, M2, M4, M5, M10, M15, M30, H1, H2, H3, H4, H6, H8, H12, D, W, M]. from and to can be dates or ISO strings. callback is called with the following arguments:

  • error
  • Array[Candlestick] Array of candles with bid, mid and ask ohlc and volume.

getOpenPositions(accountId?, callback)

getOpenTrades(accountId?, callback)

getOrders(accountId?, callback)

createMarketOrder(accountId, order, callback)

kill()

Aborts any open events or rates streaming connections and removes all event listeners

client.kill()

Upcoming

Implementations for trading coming in next releases.

Author

By Cloud9Trader. Simple, powerful platform for algorithmic trading.