
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
@master-chief/alpaca
Advanced tools
A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
From NPM:
> npm i @master-chief/alpaca
From GitHub:
> npm i 117/alpaca
import * as alpaca from "@master-chief/alpaca";
let client = new alpaca.Client({
credentials: {
key: "mykey",
secret: "mysecret",
},
paper: true,
rate_limit: true,
});
The following methods are available on the client.
await client.isAuthenticated();
await client.getAccount();
await client.getOrder({
order_id: "6187635d-04e5-485b-8a94-7ce398b2b81c",
});
await client.getOrders({
limit: 25,
status: "all",
});
await client.placeOrder({
symbol: "SPY",
qty: 1,
side: "buy",
type: "market",
time_in_force: "day",
});
await client.replaceOrder({
order_id: "69a3db8b-cc63-44da-a26a-e3cca9490308",
limit_price: 9.74,
});
await client.cancelOrder({
order_id: "69a3db8b-cc63-44da-a26a-e3cca9490308",
});
await client.cancelOrders();
await client.getPosition({ symbol: "SPY" });
await client.getPositions();
await client.closePosition({ symbol: "SPY" });
await client.closePositions();
await client.getAsset({ asset_id_or_symbol: "SPY" });
await client.getAssets({ status: "active" });
await client.getWatchlist({ uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128" });
await client.getWatchlists();
await client.createWatchlist({
name: "my watchlist",
symbols: ["SPY", "DIA", "EEM", "XLF"],
});
await client.updateWatchlist({
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
name: "new watchlist name",
symbols: ["TSLA", "AAPL"],
});
await client.addToWatchlist({
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
symbol: "F",
});
await client.removeFromWatchlist({
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
symbol: "F",
});
await client.deleteWatchlist({
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
});
await client.getCalendar({ start: new Date(), end: new Date() });
await client.getClock();
await client.getAccountConfigurations();
await client.updateAccountConfigurations({
no_shorting: true,
suspend_trade: true,
});
await client.getAccountActivities({
activity_type: "FILL",
});
await client.getPortfolioHistory({
period: "1D",
timeframe: "1Min",
});
await client.getBars({
symbols: ["SPY", "DIA", "XLF"],
});
await client.getLastTrade({
symbol: "SPY",
});
await client.getLastQuote({
symbol: "SPY",
});
Note: Each key is allowed only 1 simultaneous connection to each host.
import * as alpaca from "@master-chief/alpaca";
let stream = new alpaca.Stream({
credentials: {
key: "mykey",
secret: "mysecret",
},
host: alpaca.URL.WSS_MARKET_DATA,
});
The following events are available on the market data stream.
stream.on("authenticated", () => stream.subscribe(["AM.SPY"]));
stream.on("aggregate_minute", console.log);
stream.on("authenticated", () => stream.subscribe(["Q.SPY"]));
stream.on("quote", console.log);
stream.on("authenticated", () => stream.subscribe(["T.SPY"]));
stream.on("trade", console.log);
stream.on("authenticated", () => stream.subscribe(["T.SPY"]));
stream.on("trade", console.log);
The following events are available on the account stream.
stream.on("authenticated", () => stream.subscribe(["trade_updates"]));
stream.on("trade_updates", console.log);
stream.on("authenticated", () => stream.subscribe(["account_updates"]));
stream.on("account_updates", console.log);
Pull requests are encouraged. 😁
FAQs
A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.
The npm package @master-chief/alpaca receives a total of 125 weekly downloads. As such, @master-chief/alpaca popularity was classified as not popular.
We found that @master-chief/alpaca demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.