Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@master-chief/alpaca

Package Overview
Dependencies
Maintainers
1
Versions
86
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@master-chief/alpaca - npm Package Compare versions

Comparing version 1.0.6 to 1.0.7

.github/workflows/continuous-integration.yml

21

dist/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var client_1 = require("./lib/client");
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
Object.defineProperty(exports, "Client", {
enumerable: true,
get: function () {
return client_1.Client;
},
});
var stream_1 = require("./lib/stream");
Object.defineProperty(exports, "Stream", { enumerable: true, get: function () { return stream_1.Stream; } });
Object.defineProperty(exports, "Stream", {
enumerable: true,
get: function () {
return stream_1.Stream;
},
});
var url_1 = require("./lib/url");
Object.defineProperty(exports, "URL", { enumerable: true, get: function () { return url_1.URL; } });
Object.defineProperty(exports, "URL", {
enumerable: true,
get: function () {
return url_1.URL;
},
});

409

dist/lib/client.js
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -13,144 +15,271 @@ exports.Client = void 0;

class Client {
constructor(params) {
this.params = params;
this.limiter = new limiter_1.RateLimiter(199, 'minute');
constructor(params) {
this.params = params;
this.limiter = new limiter_1.RateLimiter(199, "minute");
}
async isAuthenticated() {
try {
await this.getAccount();
return true;
} catch {
return false;
}
async isAuthenticated() {
try {
await this.getAccount();
return true;
}
catch {
return false;
}
}
getAccount() {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
"account"
);
}
getOrder(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`orders/${
params.order_id || params.client_order_id
}?${qs_1.default.stringify({
nested: params.nested,
})}`
);
}
getOrders(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`orders?${qs_1.default.stringify(params)}`
);
}
placeOrder(params) {
return this.request(
http_method_enum_1.default.POST,
url_1.URL.REST_ACCOUNT,
`orders`,
params
);
}
replaceOrder(params) {
return this.request(
http_method_enum_1.default.PATCH,
url_1.URL.REST_ACCOUNT,
`orders/${params.order_id}`,
params
);
}
cancelOrder(params) {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`orders/${params.order_id}`
);
}
cancelOrders() {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`orders`
);
}
getPosition(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`positions/${params.symbol}`
);
}
getPositions() {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`positions`
);
}
closePosition(params) {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`positions/${params.symbol}`
);
}
closePositions() {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`positions`
);
}
getAsset(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`assets/${params.asset_id_or_symbol}`
);
}
getAssets(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`assets?${qs_1.default.stringify(params)}`
);
}
getWatchlist(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`watchlists/${params.uuid}`
);
}
getWatchlists() {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`watchlists`
);
}
createWatchlist(params) {
return this.request(
http_method_enum_1.default.POST,
url_1.URL.REST_ACCOUNT,
`watchlists`,
params
);
}
updateWatchlist(params) {
return this.request(
http_method_enum_1.default.PUT,
url_1.URL.REST_ACCOUNT,
`watchlists/${params.uuid}`,
params
);
}
addToWatchlist(params) {
return this.request(
http_method_enum_1.default.POST,
url_1.URL.REST_ACCOUNT,
`watchlists/${params.uuid}`,
params
);
}
removeFromWatchlist(params) {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`watchlists/${params.uuid}/${params.symbol}`
);
}
deleteWatchlist(params) {
return this.request(
http_method_enum_1.default.DELETE,
url_1.URL.REST_ACCOUNT,
`watchlists/${params.uuid}`
);
}
getCalendar(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`calendar?${qs_1.default.stringify(params)}`
);
}
getClock() {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`clock`
);
}
getAccountConfigurations() {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`account/configurations`
);
}
updateAccountConfigurations(params) {
return this.request(
http_method_enum_1.default.PATCH,
url_1.URL.REST_ACCOUNT,
`account/configurations`,
params
);
}
getAccountActivities(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`account/activities/${params.activity_type}?${qs_1.default.stringify(
params
)}`
);
}
getPortfolioHistory(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_ACCOUNT,
`account/portfolio/history?${qs_1.default.stringify(params)}`
);
}
getBars(params) {
var transformed = {};
// join the symbols into a comma-delimited string
transformed = params;
transformed["symbols"] = params.symbols.join(",");
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_MARKET_DATA,
`bars/${params.timeframe}?${qs_1.default.stringify(params)}`
);
}
getLastTrade(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_MARKET_DATA,
`last/stocks/${params.symbol}`
);
}
getLastQuote(params) {
return this.request(
http_method_enum_1.default.GET,
url_1.URL.REST_MARKET_DATA,
`last_quote/stocks/${params.symbol}`
);
}
request(method, url, endpoint, data) {
// modify the base url if paper is true
if (this.params.paper && url == url_1.URL.REST_ACCOUNT) {
url = url_1.URL.REST_ACCOUNT.replace("api.", "paper-api.");
}
getAccount() {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, 'account');
}
getOrder(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `orders/${params.order_id || params.client_order_id}?${qs_1.default.stringify({
nested: params.nested,
})}`);
}
getOrders(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `orders?${qs_1.default.stringify(params)}`);
}
placeOrder(params) {
return this.request(http_method_enum_1.default.POST, url_1.URL.REST_ACCOUNT, `orders`, params);
}
replaceOrder(params) {
return this.request(http_method_enum_1.default.PATCH, url_1.URL.REST_ACCOUNT, `orders/${params.order_id}`, params);
}
cancelOrder(params) {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `orders/${params.order_id}`);
}
cancelOrders() {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `orders`);
}
getPosition(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `positions/${params.symbol}`);
}
getPositions() {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `positions`);
}
closePosition(params) {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `positions/${params.symbol}`);
}
closePositions() {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `positions`);
}
getAsset(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `assets/${params.asset_id_or_symbol}`);
}
getAssets(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `assets?${qs_1.default.stringify(params)}`);
}
getWatchlist(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `watchlists/${params.uuid}`);
}
getWatchlists() {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `watchlists`);
}
createWatchlist(params) {
return this.request(http_method_enum_1.default.POST, url_1.URL.REST_ACCOUNT, `watchlists`, params);
}
updateWatchlist(params) {
return this.request(http_method_enum_1.default.PUT, url_1.URL.REST_ACCOUNT, `watchlists/${params.uuid}`, params);
}
addToWatchlist(params) {
return this.request(http_method_enum_1.default.POST, url_1.URL.REST_ACCOUNT, `watchlists/${params.uuid}`, params);
}
removeFromWatchlist(params) {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `watchlists/${params.uuid}/${params.symbol}`);
}
deleteWatchlist(params) {
return this.request(http_method_enum_1.default.DELETE, url_1.URL.REST_ACCOUNT, `watchlists/${params.uuid}`);
}
getCalendar(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `calendar?${qs_1.default.stringify(params)}`);
}
getClock() {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `clock`);
}
getAccountConfigurations() {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `account/configurations`);
}
updateAccountConfigurations(params) {
return this.request(http_method_enum_1.default.PATCH, url_1.URL.REST_ACCOUNT, `account/configurations`, params);
}
getAccountActivities(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `account/activities/${params.activity_type}?${qs_1.default.stringify(params)}`);
}
getPortfolioHistory(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_ACCOUNT, `account/portfolio/history?${qs_1.default.stringify(params)}`);
}
getBars(params) {
var transformed = {};
// join the symbols into a comma-delimited string
transformed = params;
transformed['symbols'] = params.symbols.join(',');
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_MARKET_DATA, `bars/${params.timeframe}?${qs_1.default.stringify(params)}`);
}
getLastTrade(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_MARKET_DATA, `last/stocks/${params.symbol}`);
}
getLastQuote(params) {
return this.request(http_method_enum_1.default.GET, url_1.URL.REST_MARKET_DATA, `last_quote/stocks/${params.symbol}`);
}
request(method, url, endpoint, data) {
// modify the base url if paper is true
if (this.params.paper && url == url_1.URL.REST_ACCOUNT) {
url = url_1.URL.REST_ACCOUNT.replace('api.', 'paper-api.');
// convert any dates to ISO 8601 for Alpaca
if (data) {
for (let [key, value] of Object.entries(data)) {
if (value instanceof Date) {
data[key] = value.toISOString();
}
// convert any dates to ISO 8601 for Alpaca
if (data) {
for (let [key, value] of Object.entries(data)) {
if (value instanceof Date) {
data[key] = value.toISOString();
}
}
}
return new Promise(async (resolve, reject) => {
// do rate limiting
if (this.params.rate_limit) {
await new Promise((resolve) => this.limiter.removeTokens(1, resolve));
}
await node_fetch_1.default(`${url}/${endpoint}`, {
method: method,
headers: {
'APCA-API-KEY-ID': this.params.credentials.key,
'APCA-API-SECRET-KEY': this.params.credentials.secret,
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((response) =>
// is it an alpaca error response?
'code' in response && 'message' in response
? reject(response)
: resolve(response))
.catch(reject);
});
}
}
return new Promise(async (resolve, reject) => {
// do rate limiting
if (this.params.rate_limit) {
await new Promise((resolve) => this.limiter.removeTokens(1, resolve));
}
await node_fetch_1
.default(`${url}/${endpoint}`, {
method: method,
headers: {
"APCA-API-KEY-ID": this.params.credentials.key,
"APCA-API-SECRET-KEY": this.params.credentials.secret,
},
body: JSON.stringify(data),
})
.then((response) => response.json())
.then((response) =>
// is it an alpaca error response?
"code" in response && "message" in response
? reject(response)
: resolve(response)
)
.catch(reject);
});
}
}
exports.Client = Client;
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var __importDefault =
(this && this.__importDefault) ||
function (mod) {
return mod && mod.__esModule ? mod : { default: mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -10,111 +12,122 @@ exports.Stream = void 0;

class Stream extends events_1.EventEmitter {
constructor(params) {
// Makes a new event emitter :D
super();
this.params = params;
this.subscriptions = [];
this.authenticated = false;
// if we haven't made a connection, create one now
this.connection = new ws_1.default(params.host)
// Emits when the websocket is open
.once('open', () => {
// Sends an authentication request if you aren't authorized yet
if (!this.authenticated)
this.connection.send(JSON.stringify({
action: 'authenticate',
data: {
key_id: params.credentials.key,
secret_key: params.credentials.secret,
},
}));
// Emits the open event
this.emit('open', this);
})
// Emit a close event on websocket close.
.once('close', () => this.emit('close', this))
// listen to incoming messages
.on('message', (message) => {
// Parses the object
const object = JSON.parse(message.toString());
// if the state is pending auth and this is an auth message, change the state
// < {"stream":"authorization","data":{"action":"authenticate","status":"authorized"}}
if ('stream' in object && object.stream == 'authorization')
if (object.data.status == 'authorized')
// all good :D
(this.authenticated = true),
this.emit('authenticated', this),
console.log('Connected to the websocket.');
else {
// Closes the connection
this.connection.close();
// Then throws an error
throw new Error('There was an error in authorizing your websocket connection. Object received: ' +
JSON.stringify(object, null, 2));
}
// callback regardless of whether or not we acted on the message above
this.emit('message', object);
// call any of the convenience methods that apply to this message
if ('stream' in object)
this.emit({
trade_updates: 'trade_updates',
account_updates: 'account_updates',
T: 'trade',
Q: 'quote',
AM: 'aggregate_minute',
}[object.stream.split('.')[0]], object.data);
})
// Emits an error event.
.on('error', (err) => this.emit('error', err));
constructor(params) {
// Makes a new event emitter :D
super();
this.params = params;
this.subscriptions = [];
this.authenticated = false;
// if we haven't made a connection, create one now
this.connection = new ws_1.default(params.host)
// Emits when the websocket is open
.once("open", () => {
// Sends an authentication request if you aren't authorized yet
if (!this.authenticated)
this.connection.send(
JSON.stringify({
action: "authenticate",
data: {
key_id: params.credentials.key,
secret_key: params.credentials.secret,
},
})
);
// Emits the open event
this.emit("open", this);
})
// Emit a close event on websocket close.
.once("close", () => this.emit("close", this))
// listen to incoming messages
.on("message", (message) => {
// Parses the object
const object = JSON.parse(message.toString());
// if the state is pending auth and this is an auth message, change the state
// < {"stream":"authorization","data":{"action":"authenticate","status":"authorized"}}
if ("stream" in object && object.stream == "authorization")
if (object.data.status == "authorized")
// all good :D
(this.authenticated = true),
this.emit("authenticated", this),
console.log("Connected to the websocket.");
else {
// Closes the connection
this.connection.close();
// Then throws an error
throw new Error(
"There was an error in authorizing your websocket connection. Object received: " +
JSON.stringify(object, null, 2)
);
}
// callback regardless of whether or not we acted on the message above
this.emit("message", object);
// call any of the convenience methods that apply to this message
if ("stream" in object)
this.emit(
{
trade_updates: "trade_updates",
account_updates: "account_updates",
T: "trade",
Q: "quote",
AM: "aggregate_minute",
}[object.stream.split(".")[0]],
object.data
);
})
// Emits an error event.
.on("error", (err) => this.emit("error", err));
}
/**
* Sends a message to the connected websocket.
* @param message The message itself
*/
send(message) {
// You need to be authenticated to send further messages
if (!this.authenticated) {
throw new Error("You can't send a message until you are authenticated!");
}
/**
* Sends a message to the connected websocket.
* @param message The message itself
*/
send(message) {
// You need to be authenticated to send further messages
if (!this.authenticated) {
throw new Error("You can't send a message until you are authenticated!");
}
// convert object to json
if (typeof message == 'object') {
message = JSON.stringify(message);
}
// Sends the message.
this.connection.send(message);
// Returns instance, making this chainable
return this;
// convert object to json
if (typeof message == "object") {
message = JSON.stringify(message);
}
/**
* Subscribes to channels
* @param channels The channels you want to subscribe to
*/
subscribe(channels) {
// Adds a subscription
this.subscriptions.push(...channels);
// Sends a message specifying to subscribe.
return this.send(JSON.stringify({
action: 'listen',
data: {
streams: channels,
},
}));
}
/**
* Unsubscribes from given channels
* @param channels The channels you want to unsubscribe from
*/
unsubscribe(channels) {
// Removes these channels
for (let i = 0, ln = this.subscriptions.length; i < ln; i++)
if (channels.includes(this.subscriptions[i]))
this.subscriptions.splice(i, 1);
// Send the removal to the websocket
return this.send(JSON.stringify({
action: 'unlisten',
data: {
streams: channels,
},
}));
}
// Sends the message.
this.connection.send(message);
// Returns instance, making this chainable
return this;
}
/**
* Subscribes to channels
* @param channels The channels you want to subscribe to
*/
subscribe(channels) {
// Adds a subscription
this.subscriptions.push(...channels);
// Sends a message specifying to subscribe.
return this.send(
JSON.stringify({
action: "listen",
data: {
streams: channels,
},
})
);
}
/**
* Unsubscribes from given channels
* @param channels The channels you want to unsubscribe from
*/
unsubscribe(channels) {
// Removes these channels
for (let i = 0, ln = this.subscriptions.length; i < ln; i++)
if (channels.includes(this.subscriptions[i]))
this.subscriptions.splice(i, 1);
// Send the removal to the websocket
return this.send(
JSON.stringify({
action: "unlisten",
data: {
streams: channels,
},
})
);
}
}
exports.Stream = Stream;

@@ -6,6 +6,6 @@ "use strict";

(function (URL) {
URL["REST_ACCOUNT"] = "https://api.alpaca.markets/v2";
URL["REST_MARKET_DATA"] = "https://data.alpaca.markets/v1";
URL["WSS_ACCOUNT"] = "wss://api.alpaca.markets/stream";
URL["WSS_MARKET_DATA"] = "wss://data.alpaca.markets/stream";
})(URL = exports.URL || (exports.URL = {}));
URL["REST_ACCOUNT"] = "https://api.alpaca.markets/v2";
URL["REST_MARKET_DATA"] = "https://data.alpaca.markets/v1";
URL["WSS_ACCOUNT"] = "wss://api.alpaca.markets/stream";
URL["WSS_MARKET_DATA"] = "wss://data.alpaca.markets/stream";
})((URL = exports.URL || (exports.URL = {})));
{
"name": "@master-chief/alpaca",
"version": "1.0.6",
"version": "1.0.7",
"description": "A TypeScript Node.js library for the https://alpaca.markets REST API and WebSocket streams.",
"main": "dist",
"types": "types",
"main": "dist/index.js",
"types": "types/index.d.ts",
"keywords": [
"alpaca",
"alpaca-trade-api",
"alpaca-trade-api-ts",
"alpaca-trade-api-js",
"alpaca trade api",
"trading",

@@ -12,0 +12,0 @@ "exchange",

@@ -5,3 +5,3 @@ # alpaca

![Language](https://img.shields.io/github/languages/code-size/117/alpaca?color=F1A42E&style=flat-square)
![Maintenance](https://img.shields.io/maintenance/yes/2020?style=flat-square)
![Maintenance](https://img.shields.io/github/workflow/status/117/alpaca/continuous-integration?style=flat-square)
![Prettier(idk)](https://img.shields.io/static/v1?label=code%20style&message=prettier&color=ff51bc&style=flat-square)

@@ -36,12 +36,12 @@

```typescript
import * as alpaca from '@master-chief/alpaca'
import * as alpaca from "@master-chief/alpaca";
let client = new alpaca.Client({
credentials: {
key: 'mykey',
secret: 'mysecret',
key: "mykey",
secret: "mysecret",
},
paper: true,
rate_limit: true,
})
});
```

@@ -85,3 +85,3 @@

```typescript
await client.isAuthenticated()
await client.isAuthenticated();
```

@@ -92,3 +92,3 @@

```typescript
await client.getAccount()
await client.getAccount();
```

@@ -100,4 +100,4 @@

await client.getOrder({
order_id: '6187635d-04e5-485b-8a94-7ce398b2b81c',
})
order_id: "6187635d-04e5-485b-8a94-7ce398b2b81c",
});
```

@@ -110,4 +110,4 @@

limit: 25,
status: 'all',
})
status: "all",
});
```

@@ -119,8 +119,8 @@

await client.placeOrder({
symbol: 'SPY',
symbol: "SPY",
qty: 1,
side: 'buy',
type: 'market',
time_in_force: 'day',
})
side: "buy",
type: "market",
time_in_force: "day",
});
```

@@ -132,5 +132,5 @@

await client.replaceOrder({
order_id: '69a3db8b-cc63-44da-a26a-e3cca9490308',
order_id: "69a3db8b-cc63-44da-a26a-e3cca9490308",
limit_price: 9.74,
})
});
```

@@ -142,4 +142,4 @@

await client.cancelOrder({
order_id: '69a3db8b-cc63-44da-a26a-e3cca9490308',
})
order_id: "69a3db8b-cc63-44da-a26a-e3cca9490308",
});
```

@@ -150,3 +150,3 @@

```typescript
await client.cancelOrders()
await client.cancelOrders();
```

@@ -157,3 +157,3 @@

```typescript
await client.getPosition({ symbol: 'SPY' })
await client.getPosition({ symbol: "SPY" });
```

@@ -164,3 +164,3 @@

```typescript
await client.getPositions()
await client.getPositions();
```

@@ -171,3 +171,3 @@

```typescript
await client.closePosition({ symbol: 'SPY' })
await client.closePosition({ symbol: "SPY" });
```

@@ -178,3 +178,3 @@

```typescript
await client.closePositions()
await client.closePositions();
```

@@ -185,3 +185,3 @@

```typescript
await client.getAsset({ asset_id_or_symbol: 'SPY' })
await client.getAsset({ asset_id_or_symbol: "SPY" });
```

@@ -192,3 +192,3 @@

```typescript
await client.getAssets({ status: 'active' })
await client.getAssets({ status: "active" });
```

@@ -199,3 +199,3 @@

```typescript
await client.getWatchlist({ uuid: '2000e463-6f87-41c0-a8ba-3e40cbf67128' })
await client.getWatchlist({ uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128" });
```

@@ -206,3 +206,3 @@

```typescript
await client.getWatchlists()
await client.getWatchlists();
```

@@ -214,5 +214,5 @@

await client.createWatchlist({
name: 'my watchlist',
symbols: ['SPY', 'DIA', 'EEM', 'XLF'],
})
name: "my watchlist",
symbols: ["SPY", "DIA", "EEM", "XLF"],
});
```

@@ -224,6 +224,6 @@

await client.updateWatchlist({
uuid: '2000e463-6f87-41c0-a8ba-3e40cbf67128',
name: 'new watchlist name',
symbols: ['TSLA', 'AAPL'],
})
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
name: "new watchlist name",
symbols: ["TSLA", "AAPL"],
});
```

@@ -235,5 +235,5 @@

await client.addToWatchlist({
uuid: '2000e463-6f87-41c0-a8ba-3e40cbf67128',
symbol: 'F',
})
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
symbol: "F",
});
```

@@ -245,5 +245,5 @@

await client.removeFromWatchlist({
uuid: '2000e463-6f87-41c0-a8ba-3e40cbf67128',
symbol: 'F',
})
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
symbol: "F",
});
```

@@ -255,4 +255,4 @@

await client.deleteWatchlist({
uuid: '2000e463-6f87-41c0-a8ba-3e40cbf67128',
})
uuid: "2000e463-6f87-41c0-a8ba-3e40cbf67128",
});
```

@@ -263,3 +263,3 @@

```typescript
await client.getCalendar({ start: new Date(), end: new Date() })
await client.getCalendar({ start: new Date(), end: new Date() });
```

@@ -270,3 +270,3 @@

```typescript
await client.getClock()
await client.getClock();
```

@@ -277,3 +277,3 @@

```typescript
await client.getAccountConfigurations()
await client.getAccountConfigurations();
```

@@ -287,3 +287,3 @@

suspend_trade: true,
})
});
```

@@ -295,4 +295,4 @@

await client.getAccountActivities({
activity_type: 'FILL',
})
activity_type: "FILL",
});
```

@@ -304,5 +304,5 @@

await client.getPortfolioHistory({
period: '1D',
timeframe: '1Min',
})
period: "1D",
timeframe: "1Min",
});
```

@@ -314,4 +314,4 @@

await client.getBars({
symbols: ['SPY', 'DIA', 'XLF'],
})
symbols: ["SPY", "DIA", "XLF"],
});
```

@@ -323,4 +323,4 @@

await client.getLastTrade({
symbol: 'SPY',
})
symbol: "SPY",
});
```

@@ -332,4 +332,4 @@

await client.getLastQuote({
symbol: 'SPY',
})
symbol: "SPY",
});
```

@@ -342,11 +342,11 @@

```typescript
import * as alpaca from '@master-chief/alpaca'
import * as alpaca from "@master-chief/alpaca";
let stream = new alpaca.Stream({
credentials: {
key: 'mykey',
secret: 'mysecret',
key: "mykey",
secret: "mysecret",
},
host: alpaca.URL.WSS_MARKET_DATA,
})
});
```

@@ -363,4 +363,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['AM.SPY']))
stream.on('aggregate_minute', console.log)
stream.on("authenticated", () => stream.subscribe(["AM.SPY"]));
stream.on("aggregate_minute", console.log);
```

@@ -371,4 +371,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['Q.SPY']))
stream.on('quote', console.log)
stream.on("authenticated", () => stream.subscribe(["Q.SPY"]));
stream.on("quote", console.log);
```

@@ -379,4 +379,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['T.SPY']))
stream.on('trade', console.log)
stream.on("authenticated", () => stream.subscribe(["T.SPY"]));
stream.on("trade", console.log);
```

@@ -387,4 +387,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['T.SPY']))
stream.on('trade', console.log)
stream.on("authenticated", () => stream.subscribe(["T.SPY"]));
stream.on("trade", console.log);
```

@@ -400,4 +400,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['trade_updates']))
stream.on('trade_updates', console.log)
stream.on("authenticated", () => stream.subscribe(["trade_updates"]));
stream.on("trade_updates", console.log);
```

@@ -408,4 +408,4 @@

```typescript
stream.on('authenticated', () => stream.subscribe(['account_updates']))
stream.on('account_updates', console.log)
stream.on("authenticated", () => stream.subscribe(["account_updates"]));
stream.on("account_updates", console.log);
```

@@ -412,0 +412,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc