Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added import for Price class and error handler to price and transacti… #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Context {
this.headers['Authorization'] = "Bearer " + this.token;
}

request(method, path, body, streamChunkHandler, responseHandler) {
request(method, path, body, streamChunkHandler, responseHandler, errorHandler) {
let headers = JSON.parse(JSON.stringify(this.headers));

let postData = "";
Expand Down Expand Up @@ -164,7 +164,11 @@ class Context {
{
req.write(postData);
}

if(errorHandler){
req.on('error', (error) => {
errorHandler(error);
})
}
req.end();
}
}
Expand Down
7 changes: 5 additions & 2 deletions src/pricing.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ var Property = require('./base').Property;
var Field = require('./base').Field;

var pricing_common = require('./pricing_common');
var Price = pricing_common.Price;
Copy link

@joaocosta joaocosta May 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to http://developer.oanda.com/rest-live-v20/pricing-ep/, this should be ClientPrice, not Price.

Note that the price stream endpoint returns the time field which class ClientPrice supports, but class Price does not.

In other words, the correct fix for this problem is at #16

var order = require('./order');
var instrument = require('./instrument');

Expand Down Expand Up @@ -567,7 +568,8 @@ class EntitySpec {
accountID,
queryParams,
streamChunkHandler,
responseHandler
responseHandler,
errorHandler
)
{
if (!responseHandler)
Expand Down Expand Up @@ -665,7 +667,8 @@ class EntitySpec {
path,
body,
generateStreamParser(streamChunkHandler),
handleResponse
handleResponse,
errorHandler
);
}

Expand Down
6 changes: 4 additions & 2 deletions src/transaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -8099,7 +8099,8 @@ class EntitySpec {
stream(
accountID,
streamChunkHandler,
responseHandler
responseHandler,
errorHandler
)
{
if (!responseHandler)
Expand Down Expand Up @@ -8189,7 +8190,8 @@ class EntitySpec {
path,
body,
generateStreamParser(streamChunkHandler),
handleResponse
handleResponse,
errorHandler
);
}

Expand Down