-
Notifications
You must be signed in to change notification settings - Fork 42
v7 #113
Conversation
I am excited |
@iukea1 the endpoints are done i just need to do all the typings |
You are the man! I am working on a NextJS project and I am excited to use the typescript equivalent of the Alpaca API |
By any chance did you get to work on this? I am just trying to figure out if I should use the other alpaca library for js. Just I am trying to be a good boy and only use typescript (I am a noob when it comes to JS and typescript) |
@iukea1 I wish I had the time, I keep trying but the days slip by. 😵💫 If you use v6 for now it's a small lift to switch over to v7. All of the types will have the same fields. |
@117 Love what you are doing here. Is there any chance to get the current state of v7 as a pre-alpha release so that I can paper trade cryptos while waiting for the work to progress? |
@DaviDevMod good idea! ill put in work on this today. pre-alpha would make this release easier |
@bennycode oops. added in client.v2
.getStocksBars({ symbols: "SPY", timeframe: "1Min" })
.then(({ bars }) => {
console.log(bars);
});
// {
// SPY: [
// {
// t: '2023-08-08T08:00:00Z',
// o: 449.85,
// h: 449.96,
// l: 449.82,
// c: 449.83,
// v: 4226,
// n: 30,
// vw: 449.834134
// },
// ... |
Great, one step further! 💪 I noticed that {
"body": {
"message": "endpoint not found."
},
"request": {
"method": "GET",
"url": "/v2/positions"
},
"status": 404,
"statusText": "Not Found",
"url": "https://data.alpaca.markets/v2/positions"
} I guess the base URL here has to be |
chore(package.json): update version to 7.0.12-alpha chore(package-lock.json): update version to 7.0.12-alpha refactor(positions): rename getAllOpenPositions to getPositions feat(stocks): add temporary hack for customBase
@bennycode what was happening is the fixed that with a temporary hack, ill revisit a more robust solution for handling the multiple possible base urls. the following is working for me:
client.v2
.getStocksBars({ symbols: "SPY", timeframe: "1Min" })
.then(({ bars }) => {
console.log(bars);
});
client.v2.getPositions().then((positions) => {
console.log(positions);
}); |
I changed from |
Im juggling work and this, ill keep doing a bit each day until its ready. Glad that works for now :)
|
I appreciate your help very much! 👍 I am the creator of a Coinbase API for Node.js and know how much work it is to maintain a stable and current SDK. I just tested Update: Actually the |
Back to this today. Will fix that. |
fix: Import changes in BaseHttpRequest.ts fix: URL changes in crypto.ts fix: Version update in package.json feat: Added prewrap function in prewrap.ts fix: Import changes in request.ts
I refactored methods like |
latest published |
fix: Update import path bump: Update package version
Just tested |
Today I have been using It would be great if there was a union type for if (asset.class === 'crypto') {
console.log(asset.min_order_size);
} Crypto Example{
"attributes": [],
"class": "crypto",
"easy_to_borrow": false,
"exchange": "CRYPTO",
"fractionable": true,
"id": "19c466e7-e8f7-43e0-a8c5-f17ec9f5de8d",
"maintenance_margin_requirement": 100,
"marginable": false,
"min_order_size": "0.015559358",
"min_trade_increment": "0.000000001",
"name": "Litecoin / US Dollar",
"price_increment": "0.005",
"shortable": false,
"status": "active",
"symbol": "LTC/USD",
"tradable": true
} Stock Example{
"attributes": [],
"class": "us_equity",
"easy_to_borrow": true,
"exchange": "NYSE",
"fractionable": true,
"id": "78856c3d-67c8-43bc-8cd4-e95b686cf741",
"maintenance_margin_requirement": 30,
"marginable": true,
"name": "Shopify Inc. Class A subordinate voting shares",
"shortable": true,
"status": "active",
"symbol": "SHOP",
"tradable": true
} |
busy ): |
Hi, is it abandoned? I need to remove raw functions from entities for memory optimization. Can I upgrade to this version from v6, or is it unfinished for production? |
Damn you actually became active for once? If you need help I can take over. |
I'm using a combination of SDK v6 and SDK v7 to overcome any limitations. This method involves including both references in the "dependencies": {
"@master-chief/alpaca-ts": "^7.0.15-alpha",
"alpaca-legacy": "npm:@master-chief/alpaca@^6.3.20"
} Afterwards, both SDKs can be used in parallel like this: import { Client } from "@master-chief/alpaca-ts";
import {
AlpacaClient as LegacyClient
// @ts-ignore:next-line
} from "alpaca-legacy";
const client = new Client(...);
const legacyClient = new LegacyClient(...); |
brutal lol |
@bennycode do you like the approach/pattern of v7? |
Yes, I am very happy with v7! My application is quite sophisticated. If you'd like, I can provide feedback to one of your product managers. I am using the legacy client only for placing orders and for connecting to |
@bennycode i have a new repo for this underway, spent the last 8 hours going through the docs line by line lol. this one is handwritten not codegen using api spec. will post here after i clean it up everything other than broker api is included. i copied ALL of the endpoints over, market data, crypto included. no-lifing this for the next 48 hrs. just needs to be done once and for all |
@bennycode https://github.com/alpacahq/typescript-sdk almost done. v7 can be considered abandoned. The new repo is comprehensive, covers all endpoints (minus broker api), and all streams. |
🦙 Alpaca Trading SDK v7 (work in progress)
Note
Although this is a breaking change, the deprecated v6 will remain accessible through NPM if you are unable to make the necessary modifications to your code at this time.
Why v7?
I'm updating the Alpaca Trading SDK to include the latest endpoints for both crypto and stocks. To simplify future modifications, types have been consolidated alongside a reduction in the total number of files, lowering the overall code complexity.
Example
Contributing
I hope that these updates will improve your overall experience with the Alpaca Trading SDK. If you have any feedback or suggestions, please let me know! Feel free to PR v7 branch.