alpaca-trade-api-js icon indicating copy to clipboard operation
alpaca-trade-api-js copied to clipboard

Convert project to Typescript

Open suddjian opened this issue 6 years ago • 19 comments
trafficstars

Typescript has many advantages relating to documentation and code correctness, even for non-ts users.

suddjian avatar Dec 05 '18 04:12 suddjian

Would love to see progress on this

anthonykrivonos avatar Aug 11 '19 06:08 anthonykrivonos

Any progress on the Typescript ?

b4git avatar Apr 06 '20 23:04 b4git

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 avatar Apr 21 '20 18:04 jeaber

@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.

ertw avatar Apr 23 '20 20:04 ertw

Would be super happy to see this!

zachschultz avatar May 02 '20 03:05 zachschultz

I volunteer as tribute. Give me a week.

117 avatar May 29 '20 01:05 117

Would be super happy to see this!

extwiii avatar May 31 '20 08:05 extwiii

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. 😄

117 avatar Jun 01 '20 06:06 117

Can we take a moment to talk about how this guy just did this in about 3 days, lol.

Ouch avatar Jun 01 '20 06:06 Ouch

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..

phantomodm avatar Jun 08 '20 17:06 phantomodm

@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.

KalebMills avatar Jun 18 '20 04:06 KalebMills

@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 🤔 ?

117 avatar Jun 19 '20 05:06 117

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

aqilc avatar Jul 19 '20 04:07 aqilc

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).

kn0ll avatar Jul 25 '20 18:07 kn0ll

+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.

eonil avatar May 08 '21 13:05 eonil

+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.

majorsauce avatar Aug 07 '21 19:08 majorsauce

@eonil @majorsauce while we wait for official... https://github.com/117/alpaca

117 avatar Aug 07 '21 21:08 117

+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.

kevinclarkadstech avatar Sep 15 '21 00:09 kevinclarkadstech

Hello guys, we introduced Typescript support recently, please update you package and try it!

noramehesz avatar Oct 27 '21 07:10 noramehesz