alpaca-trade-api-js
alpaca-trade-api-js copied to clipboard
Convert project to Typescript
Typescript has many advantages relating to documentation and code correctness, even for non-ts users.
Would love to see progress on this
Any progress on the Typescript ?
Only thing necessary is an official @types/alpaca-trade-api. I have to make my own for now. Super impressed with alpaca so far though.
@jeaber it sounds like you're writing out type definitions for the library? Let us know if you end up publishing those, as I'm also starting to play with this library.
I think the ideal solution here (other than just converting to TS) would be to get bu-yin and include those in the official library. When I have to use a library that is written in vanilla JS, I find it preferable to just be able to consume the type definitions directly, rather that via @types. I'm not actually sure how this is done though, and I imagine that either way (whether through DefinitelyTyped or included), it would require a process to make sure that the types stay in sync, which is why I think official buy-in from the library owner is needed.
Would be super happy to see this!
I volunteer as tribute. Give me a week.
Would be super happy to see this!
Almost done guys, a few more days of work and it'll be production ready. Spent all weekend writing it out. There is full coverage of the Alpaca REST API methods (even watchlists). I have yet to test it thoroughly and will be doing so while the market is open. I don't recommend you real-trade with it. I'm certain there are a few bugs, a known issue is I have to convert the date objects on methods with dates... to a format Alpaca likes.
You can find it here: https://github.com/117/alpaca-trade-api-ts
I also have not included Polygon's WebSocket because I feel Polygon API should be in it's own package. Which I'll make if it doesn't already exist, haven't checked. Or we can debate adding it there too (wouldn't take long).
Would really appreciate any assistance with it, if anyone has suggestions or finds a bug. I think we can iterate improvements faster than is possible upstream because I am pretty much always available to check PRs.
I'd also like to add that originally I attempted to convert this project to TypeScript from the upstream source but I decided it would be easier rewrite from the ground up. I also support a Client structure with my TypeScript package which allows you to trade multiple keys with the same node instance. This is something I personally wanted but haven't seen in any of the popular languages API wrappers for Alpaca.
Going to try and have it production-ready by end of week. Over and out. 😄
Can we take a moment to talk about how this guy just did this in about 3 days, lol.
Thanks Alpaca for these examples... I wrote the typescript version from the js version this weekend, initially in Angular framework, but browser crashing when ran.. I'm a dev in training, I'd like to compare the Alpaca vs to mine.. If anyone interested let me know.. Attempting to write a python version too..
@117 Hey man, I'd love to contribute to the project. Pulled it down and began using it today, looks great! Not sure what else needs doing, but I'd love to help out.
@117 Hey man, I'd love to contribute to the project. Pulled it down and began using it today, looks great! Not sure what else needs doing, but I'd love to help out.
An improvement that comes to mind is translated responses. For example when you request an account, right now the account.buying_power field is a string when really in most use cases we want this to be a number. Or perhaps adding helper methods such as getBuyingPower() to the interfaces 🤔 ?
I also wrote one for myself and if you want to check it out, it's here. Would personally like some help on docs :D
i'd be a little reluctant to use a client library that isn't offered officially.
why not just provide type definitions through DefinitelyTyped? above, someone worries about type definitions out of sync, but that is just the nature of DefinitelyTyped.
personally, i'd prefer types we have to keep up to date as a community, as opposed to a fork.
(obviously official types by from Alpaca would be the ideal scenario, but i'm assuming that is not in the cards).
+1 for this. Please consider providing an official type definitions. Type annotation and checking is essential for productivity to me. Supporting TypeScript does not harm any existing JavaScript users.
+1 for this. Official type definitions are a must-have for me for any current Node module. Please consider migrating or at least creating official type definitions (probably more work long term) for this.
@eonil @majorsauce while we wait for official... https://github.com/117/alpaca
+1 for this, I guess I will just use axios to directly call the apis and use my own types. Or use a competitor, even if I have to pay for the market data.
Update: I just went with AlphaVantage for anyone who is interested.
Hello guys, we introduced Typescript support recently, please update you package and try it!