项目作者: sakiyama

项目描述 :
Node.js adapter for Oanda's v1 REST and streaming API
高级语言: JavaScript
项目地址: git://github.com/sakiyama/oanda.git
创建时间: 2017-06-28T05:02:50Z
项目社区:https://github.com/sakiyama/oanda

开源协议:

下载


oanda

This is a work in progress that I’m making in my spare time. I cant’t guarantee that any of it is fast, stable, or even working. There is no OAuth implementation, so you must already have an access token in order to use the API

This library is a NodeJS wrapper for the Oanda REST API. It provides a simple abstraction layer for making requests and retrieving responses from the API.

This library targets v1 api. v3 is not supported in japan OMG.

Example request

  1. var oanda = require('./oanda/')({
  2. key: '99999999999999999999999999999999-99999999999999999999999999999999'
  3. type: 'practice' // 'real' or 'sandbox'
  4. });
  5. oanda.api.accounts(function(err,accounts){
  6. var account = accounts[0];
  7. account.candles({
  8. instrument : "USD_JPY",
  9. count : 1,
  10. },function(err,candles){
  11. console.log(err, candles);
  12. });
  13. account.ticks({
  14. instruments : "USD_JPY",
  15. },function(err,tick){
  16. // streaming
  17. console.log(err,tick);
  18. });
  19. account.transactions(function(err, transactions) {
  20. console.log(err, transactions);
  21. });
  22. account.events(function(err, transaction) {
  23. // streaming
  24. console.log(err,transaction);
  25. });
  26. account.order.market({
  27. instrument : 'USD_JPY',
  28. units:-1
  29. },function(err,res){
  30. console.log(err,res);
  31. });
  32. account.order.limit({
  33. instrument : 'USD_JPY',
  34. units:1,
  35. price : 110,
  36. expiry : Date.now() + 3600000
  37. },function(err,res){
  38. console.log(err,res);
  39. });
  40. account.orders(function(err, orders) {
  41. if(!orders || !orders[0]){
  42. return;
  43. }
  44. orders[0].update({
  45. units : 1
  46. });
  47. });
  48. account.orders({
  49. instrument : "USD_JPY"
  50. }, function(err, orders) {
  51. console.log(err, orders);
  52. });
  53. account.trades(function(err, trades) {
  54. if(!trades || !trades[0]){
  55. return;
  56. }
  57. trades[0].update({
  58. stopLoss : 109
  59. });
  60. });
  61. account.positions(function(err, positions) {
  62. console.log(err, positions);
  63. });
  64. account.position("USD_JPY", function(err, position) {
  65. console.log(err, position);
  66. });
  67. });