torreyleonard / algotrader Goto Github PK
View Code? Open in Web Editor NEWSimple algorithmic stock and option trading for Node.js.
Home Page: https://www.npmjs.com/package/algotrader
License: Apache License 2.0
Simple algorithmic stock and option trading for Node.js.
Home Page: https://www.npmjs.com/package/algotrader
License: Apache License 2.0
Javascript package for the API is available here:
Hello, since this project looks abandoned I can suggest trying Mida
https://github.com/Reiryoku-Technologies/Mida
I would like to keep an active community regarding algorithmic trading with Node.js
Thank you!
Error: connect ETIMEDOUT
Started happening this week, anyone facing same issue?
API documentation could be found here: http://developer.oanda.com/
Looks like now to get the data from a stock you also need to be logged in. I was getting a 401 when trying to do it without any auth param.
Modified the static getByUrl
to accept the user and added the header with the user.getAuthToken
Looks like Robinhood has changed their API, and I'm getting this issues:
"This version of Robinhood is no longer supported. Please update your app or use Robinhood for Web to log in to your account."
Looks like there's a fix in for it, any chance we can merge: Gillinghammer-patch-2 ?
Hi, do you know if I should use the same installation steps for a React app? This has been my experience:
I really like your work, thank you for making it available.
ERROR in ./node_modules/algotrader/objects/broker/robinhood/User.js
Module not found: Error: Can't resolve 'fs' in 'C:\AndroidAppDev\xcharts-react-webview\node_modules\algotrader\objects\broker\robinhood'
@ ./node_modules/algotrader/objects/broker/robinhood/User.js 19:9-22
Hi,
I am getting following error while using given example in the package. Please help how to fix it.
using node v12.13.0.
c:\test\node examples\highest-open-interest.js
C:\test\node_modules\algotrader2\examples\highest-open-interest.js:28
Scheduler.onMarketOpen(5 * 60000, open).catch(error => console.error(error)); // Run every day on market open
^
TypeError: Scheduler.onMarketOpen is not a function
at Object. (C:\test\node_modules\algotrader2\examples\highest-open-interest.js:28:11)
at Module._compile (internal/modules/cjs/loader.js:956:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
at Module.load (internal/modules/cjs/loader.js:812:32)
at Function.Module._load (internal/modules/cjs/loader.js:724:14)
at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
at internal/main/run_main_module.js:17:11
Hey bro,
Can you help with one Indian broker (Angel Broking) and i can add more.
Or in near future if we want to implement the same.
I believe the Robin hood api has change and the User class with isAuthenticated method is not working any more. We are using it with GQL and getting Library Error:"this version of robinhood is no longer supported ...."
Any solution?
I'm trying to authenticate my Robinhood user programmatically, so I can issue trades programmatically, using the following recommended code:
const myUser = new User(credentials.username, credentials.password, options);
myUser.authenticate()
.then(() => {
// User was authenticated
console.log("Algotrader User Authenticated...");
})
.catch(error => {
console.log("Authentication Error: " + error);
});
But I'm getting the following error printed to the console when I run the app.js file:
Can anyone shed some light on this issue please? Thanks in advance!
I'm getting an error after following the documentation. Either I missed something, or this is an unexpected error.
(node:186620) UnhandledPromiseRejectionWarning: Error: Robinhood responded with code 404: not found | Not Found
The requested URL /accounts/null/positions/ was not found on this server.
Here is my code:
myUser.getPortfolio()
.then(myPortfolio => {
let myTeslaShares = myPortfolio.getQuantity("TSLA");
let bestDayEver = myPortfolio.getPurchaseDate("SHLD");
let mySymbols = myPortfolio.getSymbols();
let myMoneyMakers = myPortfolio.getQuantityGreaterThan(50);
})
.catch(error => {
console.log("getPortfolio Failed!", error);
})
where myUser is an authenticated Robinhood.User
Thanks for digging out the API for RH options trading! I can place a limit order to buy options algorithmically. However I was hoping you could provide an example to add a stop loss to my options order. I think it can be enabled by adding to the legs
option here:
Here is an example of how I can buy qty
contracts of instrument x
under account a
for ask price p
:
{
"quantity":qty,
"direction":"debit",
"type":"limit",
"price": p,
"account":a,
"time_in_force":"gfd",
"trigger":"immediate",
"legs":
[
{"side":"buy","option":instrument,"position_effect":"open","ratio_quantity":"1"}
],
"override_day_trade_checks":False,
"override_dtbp_checks":False,
"ref_id":ref_id}
How would I amend to this JSON statement to add a stop loss at price q
, where q < p
?
Should be a simple fix. Instrument#getQuote() now needs a user to be supplied to it, but Portfolio#getStockValue() does not provide nor take one.
Running into an issue that happened recently, so I am wondering if something changed in the Robinhood API.
const instrument = await Instrument.getBySymbol(symbol);
// works fine & returns the instrument from Robinhood
// But now when I use that generated instrument to get the Quote I have a 401 response from Robinhood
const stockQuote = await instrument.getQuote();
// Error: Robinhood responded with code 401
LibraryError: "This version of Robinhood is no longer supported. Please update your app or use Robinhood for Web to log in to your account."
Is this a known issue right now?
Robinhood is responding with status code 500 (server error) when submitting an option order.
Thanks for your help. I tried to place an option order but was not successful. I'm new to javascript so I'm sure I did something wrong. Could you take a look at the code below and let me know what I'm doing wrong?
myUser.authenticate()
.then(() => {
// User was authenticated
// First, we'll get the instrument and tradable expiration dates for SPY.
Instrument.getBySymbol("SPY").then(ins => {
OptionInstrument.getExpirations(myUser, ins).then(option => {
// Next, we'll fetch an option chain for the upcoming expiration date.
OptionInstrument.getChain(myUser, ins, option[0], "put").then(optionChain => {
console.log(optionChain[4]);
// An array of OptionInstruments will be returned. See the example below.
// You'll then want to find the specific OptionInstrument that you want to trade.
// In this example, we'll buy using the first element in the array.
let order = new OptionOrder(null, myUser, optionChain[4], "credit", "gtc", "buy", "market", 1);
order.submit().then(res => {
// Order was submitted, the response will be parsed as a completed OptionOrder.
console.log("Order submitted");
console.log(res);
});
})
})
});
})
.catch(error => {
// Either the request failed, or Robinhood responded with an error.
// (Ex: you don't have internet access or your user credentials were incorrect)
})
I get the following error message
OptionInstrument {
url: 'https://api.robinhood.com',
tradability: 'tradable',
strikePrice: 260,
state: 'active',
type: 'put',
symbol: 'SPY',
minTicks: { cutoff_price: '0.00', below_tick: '0.01', above_tick: '0.01' },
instrumentURL: 'https://api.robinhood.com/options/instruments/487f72f2-b797-4016-8ff7-8dd172029808/',
ids:
{ chain: 'c277b118-58d9-4060-8dc5-a3b5898955cb',
option: '487f72f2-b797-4016-8ff7-8dd172029808' },
dates:
{ expiration: 2019-03-04T00:00:00.000Z,
created: 2019-01-25T03:08:09.376Z,
updated: 2019-01-25T03:08:09.376Z } }
(node:25477) UnhandledPromiseRejectionWarning: Error: Robinhood responded with code 500 | <h1>Server Error (500)</h1>
> Please report all unexpected errors on GitHub: https://git.io/vpYYL
at Function.handleResponse (/home/briansp/node_modules/algotrader/objects/broker/robinhood/Robinhood.js:23:11)
at Request.request.post [as _callback] (/home/briansp/node_modules/algotrader/objects/broker/robinhood/OptionOrder.js:98:22)
at Request.self.callback (/home/briansp/node_modules/request/request.js:185:22)
at emitTwo (events.js:126:13)
at Request.emit (events.js:214:7)
at Request.<anonymous> (/home/briansp/node_modules/request/request.js:1161:10)
at emitOne (events.js:116:13)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/briansp/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
(node:25477) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:25477) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Server error 500 is the same error message I'm getting from the python api. If I change "gtc" to "GTC" as shown in the example in readme, I get 400 error along with the following error message.
(node:25697) UnhandledPromiseRejectionWarning: Error: Robinhood responded with code 400.
{
"time_in_force": [
"\"GTC\" is not a valid choice."
]
}
Any ideas? I'd like to get the option order placement working using this API before trying to get the python API working. Any help would be appreciated.
Thanks!
Originally posted by @briansp2020 in #12 (comment)
Request to add the broker tastyworks. cheers
wanna check if this library durable to retrieve binance buy and sell and apply with strategy?
has auth broken? I haven't looked into it I was just made aware all my trades are failing.
this is the error message:
node:64416) UnhandledPromiseRejectionWarning: Error:
The requested URL /api-token-auth/ was not found on this server.
thanks
I realize your Options support is in progress. In your documentation for OptionInstrument's method getBySymbol() you acknowledge that
"As there is no apparent way to query Robinhood options by symbol, all instruments will be downloaded and filtered. This will take a while on first run. After, set 'cache' to true."
"Take a while on first run" was quite the understatement in my case! I let it run for about 16 hours, downloading data from Robinhood, and then it crashed because it ran out of memory on the heap.
There's a ton of data. I hacked the code to stringify the data and write to a file stream (to fix the memory issue) ... but the resultant file has so much text that my computer hangs just trying to open it.
Maybe I need to set some parameters to the /options/instruments/ endpoint, or a different endpoint completely that would allow a more targetted request by symbol. I'll keep investigating. Any thoughts you have on this would be appreciated. =)
const d = algotrader.Data;
const chains = d.Yahoo.getOptionsChain('spy');
Failed to load https://query2.finance.yahoo.com/v7/finance/options/spy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Has Yahoo stopped allowing CORS requests or is this something on my end?
I see a device token needs to be passed in. Can you put me in the right direction as to how I'm supposed to generate one?
When trying to get the user historicals, the getHistoricals method is missing the account number in the qs object
qs: { account_number: _this.account, ......
Create a websocket to collect data from MT5 data?
Thank you.
hello! Do you have a timeline for TDameritrade support with backtesting and papertrading support? Is this being developed for commercial use or contributors?
Hi Team,
i would suggest to add a parameter period for the function getFinancials(symbol) to be able to retrieve the annual data as well or to add a new function for it?
regards
Jan
Finally getting back around to this repo and I really want to give some love back. I think this is the best on the market right now. Ideally, Robinhood will support this venture!
Quality of life:
New features:
Robinhood
API integrations:
Hi,
Currently, trying to use the IEX.getLogo()
method, but I'm getting a forbidden issue due to no token given to the API.
Is there a way where I can pass in the token as a property within IEX?
Thanks
Would you be open to a rewrite using axios
?
Would you be open to using TypeScript for this project? I'd love to wrap this package and start adding types for intellisense and typeahead for objects.
Would you be open to TypeScript if I configured a build system for it?
Robinhood now supports orders for fractional shares for most equities. Is this possible in algotrader or will it be possible in the future?
Hi
This is a request.
Can you please add support for Upstox API trading?
I'm attempting to sign into Robinhood using algotracker's methods. I.E. I'm doing this:
const User = robinhood.User;
const myUser = new User("username", "password", "token");
myUser.authenticate()
.then(() => {
// User was authenticated
console.log("User authenticated...")
})
.catch(error => {
// Either the request failed, or Robinhood responded with an error.
// (Ex: you don't have internet access or your user credentials were incorrect)
});
However, I'm getting the following error:
Robinhood responded with code 401: unauthorized.
This at one point did download a number of objects from Robinhood when placing a call to:
const option = await Instrument.getBySymbol(optionSignal.Ticker);
Your guess is as good as mine - better if you get it right.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.