GithubHelp home page GithubHelp logo

knicola / tdameritradejs Goto Github PK

View Code? Open in Web Editor NEW
38.0 6.0 17.0 1.78 MB

TD Ameritrade Library for Node.js

License: MIT License

JavaScript 98.14% Handlebars 1.86%
tdameritrade stocks trading finance api-client ws-client nodejs

tdameritradejs's People

Contributors

dependabot[bot] avatar kevinsherman avatar kjanoudi avatar knicola avatar ryanblenis avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tdameritradejs's Issues

Returned data is the HTTP response vs the body

Good job with this module.

There is an issue with the HTTP function returns. They return the complete HTTP response vs the body and the other functions expect the operate with the body.

For example;
const accounts = await api.getAccounts()
api.getOrders(accounts[0].accountId).then( ... )

accounts cannot be used like it is shown in the next line. It needs to be accounts.data[0]....

This is also the same issue with userPrincipals. It either needs to be returned with properties containing the body data, or the streamer functions need to reference the data property.

User guide

Hello. Any chance you can put together a brief user guide? I'm able to get to the point where I receive the 'code' in the callback URL, but I'm not 100% sure what to do with it :) and/or how the access token/refresh token is persisted and used. Great work by the way!

Load Valid Tokens from file

Hello,
Awesome library, love it.

I have a question.

Once I get the token, and save it to a file (as you mention in the comments)

td.on('token', token => {
    // use this to know when a new access token is
    // issued or to save the token to a file.
    console.log(token)
})

How do I load the tokens (from the file) to the library, when the server restarts. So that I don't have to login using the link again, as I already have valid tokens saved in a file.

Thank you so much.

Scripts cannot run when installed as a node module

scripts/authorize.js is not structured to run when installed as a node module to be integrated into another app.

Certs are expected to be in the root of the module. This is not ideal for an application.

How to get Futures quotes faster than 1 minue

This could be a TD API limitation. Is there a way to pass frequency into the streamer for the futures contracts? Right now, it updates every minute. Can it be every 5 seconds, etc?

Add auth methods

Need to add methods for oauth authentication and token refresh:

  • .authenticate() to request an access token
  • .refreshToken() to request a new access token

Self signed cert generation update

Suggested Openssl command in the readme didn't yield the expected results on macOS and Chrome browser.

This worked well:
openssl req -x509 -out selfsigned.crt -keyout selfsigned.key \ -newkey rsa:2048 -nodes -sha256 \ -subj '/CN=localhost' -extensions EXT -config <( \ printf "[dn]\nCN=localhost\n[req]\ndistinguished_name = dn\n[EXT]\nsubjectAltName=DNS:localhost\nkeyUsage=digitalSignature\nextendedKeyUsage=serverAuth")

refreshAccessToken gets new refreshToken

In src/client/resources/tokens.js there is a refreshAccessToken function. The function is intended to use an unexpired refreshToken to refresh an expired accessToken. In the function the parameter 'access_type' is being set to 'offline'. Per the documentation, "Set to offline to receive a refresh token on an authorization_code grant type request. Do not set to offline on a refresh_token grant type request."

My understanding is that this should only be set to offline when requesting the initial tokens (with the 'code' from the redirectURI).

When tested with 'offline' - this it returns both a refresh and access token.
When tested without 'offline' - this ONLY returns an access token (leaving the unexpired refreshToken still valid).

I will put together a PR for this change.

Unable to login on node.js

Hi, I am having trouble getting the login flow to work on node.js.
I copied the sample code you shared in a comment on issue #19, using a locally generated certificate/private key + API_KEY. Everything compiles and runs.
When the login() routine is invoked, it opens up my default web browser to the TD Ameritrade login page and 1. asks for my account credentials and 2. asks if I want to grant my app permission to access to my account. After a successful auth / grant, the browser is redirected to my REDIRECT_URI (e.g. https://localhost/?code=.....) but the node.js app just sits there. I tried closing the browser tab and the entire browser, but the node.js app just sits there, apparently not receiving back what it needs from the browser.
What am I missing here?

Please note I am using Windows 10, I am not sure if this matters for how your library handles this login process. The redirect also appears to be changing my REDIRECT_URI from HTTP to HTTPS so it fails to actually load my local app. Not sure if either of these factors are relevant here but I thought I'd mention both.

Thanks in advance, I'm looking forward to resolving these issues and working with this library.

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.