Open mozeryansky opened 9 months ago
👀
raw is not present in v7. do you mind just casting this for now?
No problem, I'm not blocked, just wanted to report the bug.
im struggling to find time to finish v7 😢
Np. Do you know why alpaca-ts
is necessary considering the alpaca-trade-api-js
contains types definitions? But also why are the types mapped behind a non-typed function?
https://github.com/alpacahq/alpaca-trade-api-js/blob/master/lib/alpaca-trade-api.js#L148:
getBarsV2(symbol, options, config = this.configuration) { // <--- not typed
return dataV2.getBars(symbol, options, config); // <-- typed, but not accessible...
}
VSCode tells me '@alpacahq/alpaca-trade-api'
is 258.5k (gzipped: 79.8k), while '@master-chief/alpaca'
is 111.3k (gzipped 28.8k). So I do prefer the slimmer version.
code quality and extensibility
v7 is pretty sweet. check out the src in #113
Ok, I can try to use it from now on, but when I tried installing it using npm i git@github.com:alpacahq/alpaca-ts.git#v7
, vscode says:
"Cannot find module '@master-chief/alpaca-ts' or its corresponding type declarations."
My package.json shows:
"@master-chief/alpaca-ts": "github:alpacahq/alpaca-ts#v7",
I see the package and files in node_modules, and I'm importing like:
import { AlpacaClient } from '@master-chief/alpaca-ts'
Did I install it correctly?
Oh, specifying the path to index worked:
import { Client } from '@master-chief/alpaca-ts/src/index'
However, I'm using OAuth, and it doesn't look like you support access_token auth yet. If you can add that, then I'll use it from now on.
Last comment on this. I've edited the files myself:
In Client.ts
I updated ClientOptions
and the constructor
:
interface ClientOptions {
paper: boolean;
credentials: {
key: string;
secret: string;
} | {
access_token: string;
};
}
export class Client {
...
constructor(
options?: ClientOptions,
HttpRequest: HttpRequestConstructor = AxiosHttpRequest
) {
const { paper, credentials } = options ?? {};
if (!credentials) {
throw new Error("No!")
}
// base request object for all requests
// changes based on paper/live mode and/or data endpoints
this.baseHttpRequest = new HttpRequest({
BASE:
paper === true || paper === undefined
? "https://paper-api.alpaca.markets"
: "https://api.alpaca.markets",
HEADERS: ('access_token' in credentials)
? {
"Authorization": `Bearer ${credentials.access_token}`
} : {
"APCA-API-KEY-ID": credentials.key,
"APCA-API-SECRET-KEY": credentials.secret,
},
});
}
...
And I was able to get the bars, including the vm property!
Description
I'm using
getBars()
which returnsPageOfBars
containingBar[]
, andRawPageOfBars
containingRawBar[]
.Using typescript, I'm unable to access
vw
andn
as it's not typed, andS
is undefined.The API returns:
However, Bar is:
and RawBar:
Expected
Type interface should match what the API returns. Also, I would expect raw to give an
any
orobject
type as that's truly raw. I don't see a purpose ofraw
otherwise, reference:Reproduction