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

oanda-vue

v0.1.0

Published

An Oanda API wrapper for Vue.js

Downloads

2

Readme

oanda-vue

oanda-vue is an Oanda API wrapper that allows you to easily call the Oanda API from your Vue app.

Installation

npm i --save oanda-vue

Usage

You must have/create an account with Oanda and sign up for an API key. Make note of your API key and the account ID of the account that you want to trade with.

In your main.js file:

import Oanda from 'oanda-vue'

Vue.use(Oanda, {
  credentials: {
    key: creds.key, // Your Oanda API key
    acntId: creds.acntId // Your Oanda account ID
  }
})

Then, from within your components you can call the API as follows:

this.$myAccounts()
this.$getCandlesticks('EUR_USD', 13, 0, 'M4')

// A more realistic example:

methods: {
  async getCandles () {
    let res = await this.$getCandlesticks('EUR_USD', 13, 0, 'M4')
    // plot the returned data on a graph...
  }
}

Available Methods

Get a list of your accounts:
this.$myAccounts()

// Example response:

accounts: Array(2)
  0: {id: "999-999-9999999-999", mt4AccountID: 1234567, tags: Array(1)}
  1: {id: "999-999-9999999-998", tags: Array(0)}
Get candlestick data:
this.$getCandlesticks('currency_pair', from, to, 'granularity')

// With actual arguments:

this.$getCandlesticks('EUR_USD', 10, 0, 'D')

// Example response:

candles: Array(8)
  0: {complete: true, volume: 135477, time: "2018-09-30T21:00:00.000000000Z", bid: {…}, ask: {…}}
  1: {complete: true, volume: 152349, time: "2018-10-01T21:00:00.000000000Z", bid: {…}, ask: {…}}
  2: {complete: true, volume: 184437, time: "2018-10-02T21:00:00.000000000Z", bid: {…}, ask: {…}}
  ...

The first argument currency_pair should be expressed as a string in the following format: 'CUR1_CUR2'. For example, 'EUR_USD', or 'EUR_GBP'.

The next two arguments define the period that the candlestick data should cover. Both from and to are integers and they represent the number of days to subtract from today. For example, if you want candlestick data covering the past week, from would be 7 and to would be 0.

The last argument granularity determines the period that each individual candlestick should cover. It should be expressed as a string and available options are at http://developer.oanda.com/rest-live-v20/instrument-df/.

The example above will retrieve full day candlesticks for the past 10 days.

Get the latest ask/bid prices:
this.$getLatestPrice('currency_pair')

// Example response for 'EUR_USD':

{lastBid: "1.15275", lastAsk: "1.15287", recordedAt: "2018-10-10T13:43:29-05:00"}
Get account balance:
this.$accountBalance()

// Example response:

{balance: "0.0085"}
Get open positions:
this.$getOpenPositions()

Contributing

This project currently only covers a few of the available Oanda API endpoints. Feel free to submit pull requests to add new methods that cover additional Oanda API endpoints.

License

MIT