@tastytrade/api 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +5 -0
- package/.eslintrc.cjs +18 -0
- package/.vscode/launch.json +24 -0
- package/LICENSE +21 -0
- package/README.md +21 -0
- package/dist/account-streamer.d.ts +92 -0
- package/dist/account-streamer.js +394 -0
- package/dist/models/tastytrade-session.d.ts +5 -0
- package/dist/models/tastytrade-session.js +23 -0
- package/dist/quote-streamer.d.ts +11 -0
- package/dist/quote-streamer.js +63 -0
- package/dist/services/account-status-service.d.ts +6 -0
- package/dist/services/account-status-service.js +64 -0
- package/dist/services/accounts-and-customers-service.d.ts +10 -0
- package/dist/services/accounts-and-customers-service.js +116 -0
- package/dist/services/balances-and-positions-service.d.ts +8 -0
- package/dist/services/balances-and-positions-service.js +93 -0
- package/dist/services/instruments-service.d.ts +28 -0
- package/dist/services/instruments-service.js +370 -0
- package/dist/services/margin-requirements-service.d.ts +7 -0
- package/dist/services/margin-requirements-service.js +76 -0
- package/dist/services/market-metrics-service.d.ts +8 -0
- package/dist/services/market-metrics-service.js +91 -0
- package/dist/services/net-liquidating-value-history-service.d.ts +7 -0
- package/dist/services/net-liquidating-value-history-service.js +77 -0
- package/dist/services/orders-service.d.ts +17 -0
- package/dist/services/orders-service.js +208 -0
- package/dist/services/risk-parameters-service.d.ts +7 -0
- package/dist/services/risk-parameters-service.js +76 -0
- package/dist/services/session-service.d.ts +9 -0
- package/dist/services/session-service.js +113 -0
- package/dist/services/symbol-search-service.d.ts +6 -0
- package/dist/services/symbol-search-service.js +63 -0
- package/dist/services/tastytrade-http-client.d.ts +13 -0
- package/dist/services/tastytrade-http-client.js +137 -0
- package/dist/services/transactions-service.d.ts +8 -0
- package/dist/services/transactions-service.js +91 -0
- package/dist/services/watchlists-service.d.ts +14 -0
- package/dist/services/watchlists-service.js +170 -0
- package/dist/tastytrade-api.d.ts +40 -0
- package/dist/tastytrade-api.js +56 -0
- package/dist/utils/json-util.d.ts +14 -0
- package/dist/utils/json-util.js +43 -0
- package/dist/utils/response-util.d.ts +1 -0
- package/dist/utils/response-util.js +21 -0
- package/lib/account-streamer.ts +394 -0
- package/lib/models/tastytrade-session.ts +13 -0
- package/lib/quote-streamer.ts +40 -0
- package/lib/services/account-status-service.ts +15 -0
- package/lib/services/accounts-and-customers-service.ts +35 -0
- package/lib/services/balances-and-positions-service.ts +29 -0
- package/lib/services/instruments-service.ts +138 -0
- package/lib/services/margin-requirements-service.ts +19 -0
- package/lib/services/market-metrics-service.ts +24 -0
- package/lib/services/net-liquidating-value-history-service.ts +20 -0
- package/lib/services/orders-service.ts +80 -0
- package/lib/services/risk-parameters-service.ts +19 -0
- package/lib/services/session-service.ts +35 -0
- package/lib/services/symbol-search-service.ts +14 -0
- package/lib/services/tastytrade-http-client.ts +65 -0
- package/lib/services/transactions-service.ts +27 -0
- package/lib/services/watchlists-service.ts +58 -0
- package/lib/tastytrade-api.ts +65 -0
- package/lib/utils/json-util.ts +44 -0
- package/lib/utils/response-util.ts +15 -0
- package/package.json +35 -0
- package/tsconfig.json +71 -0
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.SupportedEventTypes = void 0;
|
|
30
|
+
var api_1 = __importStar(require("@dxfeed/api"));
|
|
31
|
+
var lodash_1 = __importDefault(require("lodash"));
|
|
32
|
+
exports.SupportedEventTypes = [
|
|
33
|
+
api_1.EventType.Quote,
|
|
34
|
+
api_1.EventType.Trade,
|
|
35
|
+
api_1.EventType.Summary,
|
|
36
|
+
api_1.EventType.Greeks,
|
|
37
|
+
api_1.EventType.Profile
|
|
38
|
+
];
|
|
39
|
+
var QuoteStreamer = /** @class */ (function () {
|
|
40
|
+
function QuoteStreamer(token, url) {
|
|
41
|
+
this.token = token;
|
|
42
|
+
this.url = url;
|
|
43
|
+
this.feed = null;
|
|
44
|
+
}
|
|
45
|
+
QuoteStreamer.prototype.connect = function () {
|
|
46
|
+
this.feed = new api_1.default();
|
|
47
|
+
this.feed.setAuthToken(this.token);
|
|
48
|
+
this.feed.connect(this.url);
|
|
49
|
+
};
|
|
50
|
+
QuoteStreamer.prototype.disconnect = function () {
|
|
51
|
+
if (!lodash_1.default.isNil(this.feed)) {
|
|
52
|
+
this.feed.disconnect();
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
QuoteStreamer.prototype.subscribe = function (dxfeedSymbol, eventHandler) {
|
|
56
|
+
if (lodash_1.default.isNil(this.feed)) {
|
|
57
|
+
return lodash_1.default.noop;
|
|
58
|
+
}
|
|
59
|
+
return this.feed.subscribe(exports.SupportedEventTypes, [dxfeedSymbol], eventHandler);
|
|
60
|
+
};
|
|
61
|
+
return QuoteStreamer;
|
|
62
|
+
}());
|
|
63
|
+
exports.default = QuoteStreamer;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var response_util_1 = __importDefault(require("../utils/response-util"));
|
|
43
|
+
// create the central class that aggregates all services from dmoss
|
|
44
|
+
var AccountStatusService = /** @class */ (function () {
|
|
45
|
+
function AccountStatusService(httpClient) {
|
|
46
|
+
this.httpClient = httpClient;
|
|
47
|
+
}
|
|
48
|
+
//Trading Status: Allows an API client to request information about the basic trade status of an account. This includes information about the strategies an account can trade.
|
|
49
|
+
AccountStatusService.prototype.getAccountStatus = function (accountNumber) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var accountStatus;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/trading-status"), {}, {})];
|
|
55
|
+
case 1:
|
|
56
|
+
accountStatus = (_a.sent());
|
|
57
|
+
return [2 /*return*/, (0, response_util_1.default)(accountStatus)];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
return AccountStatusService;
|
|
63
|
+
}());
|
|
64
|
+
exports.default = AccountStatusService;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TastytradeHttpClient from "./tastytrade-http-client";
|
|
2
|
+
export default class AccountsAndCustomersService {
|
|
3
|
+
private httpClient;
|
|
4
|
+
constructor(httpClient: TastytradeHttpClient);
|
|
5
|
+
getCustomerAccounts(): Promise<any>;
|
|
6
|
+
getCustomerResource(customerId: string): Promise<any>;
|
|
7
|
+
getCustomerAccountResources(customerId: string): Promise<any>;
|
|
8
|
+
getFullCustomerAccountResource(customerId: string, accountNumber: string): Promise<any>;
|
|
9
|
+
getQuoteStreamerTokens(): Promise<any>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var response_util_1 = __importDefault(require("../utils/response-util"));
|
|
43
|
+
var AccountsAndCustomersService = /** @class */ (function () {
|
|
44
|
+
function AccountsAndCustomersService(httpClient) {
|
|
45
|
+
this.httpClient = httpClient;
|
|
46
|
+
}
|
|
47
|
+
AccountsAndCustomersService.prototype.getCustomerAccounts = function () {
|
|
48
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
49
|
+
var accountNumber;
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
switch (_a.label) {
|
|
52
|
+
case 0: return [4 /*yield*/, this.httpClient.getData('/customers/me/accounts', {}, {})];
|
|
53
|
+
case 1:
|
|
54
|
+
accountNumber = (_a.sent());
|
|
55
|
+
return [2 /*return*/, (0, response_util_1.default)(accountNumber)];
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
};
|
|
60
|
+
//Customers: Operations about customers
|
|
61
|
+
AccountsAndCustomersService.prototype.getCustomerResource = function (customerId) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var customerResource;
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
switch (_a.label) {
|
|
66
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/customers/".concat(customerId), {}, {})];
|
|
67
|
+
case 1:
|
|
68
|
+
customerResource = (_a.sent());
|
|
69
|
+
return [2 /*return*/, (0, response_util_1.default)(customerResource)];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
AccountsAndCustomersService.prototype.getCustomerAccountResources = function (customerId) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
var customerAccountResources;
|
|
77
|
+
return __generator(this, function (_a) {
|
|
78
|
+
switch (_a.label) {
|
|
79
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/customers/".concat(customerId, "/accounts"), {}, {})];
|
|
80
|
+
case 1:
|
|
81
|
+
customerAccountResources = (_a.sent());
|
|
82
|
+
return [2 /*return*/, (0, response_util_1.default)(customerAccountResources)];
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
AccountsAndCustomersService.prototype.getFullCustomerAccountResource = function (customerId, accountNumber) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
var fullCustomerAccountResource;
|
|
90
|
+
return __generator(this, function (_a) {
|
|
91
|
+
switch (_a.label) {
|
|
92
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/customers/".concat(customerId, "/accounts/").concat(accountNumber), {}, {})];
|
|
93
|
+
case 1:
|
|
94
|
+
fullCustomerAccountResource = (_a.sent());
|
|
95
|
+
return [2 /*return*/, (0, response_util_1.default)(fullCustomerAccountResource)];
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
//Quote-streamer-tokens: Operations about quote-streamer-tokens
|
|
101
|
+
AccountsAndCustomersService.prototype.getQuoteStreamerTokens = function () {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
103
|
+
var quoteStreamerTokens;
|
|
104
|
+
return __generator(this, function (_a) {
|
|
105
|
+
switch (_a.label) {
|
|
106
|
+
case 0: return [4 /*yield*/, this.httpClient.getData('/quote-streamer-tokens', {}, {})];
|
|
107
|
+
case 1:
|
|
108
|
+
quoteStreamerTokens = (_a.sent());
|
|
109
|
+
return [2 /*return*/, (0, response_util_1.default)(quoteStreamerTokens)];
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
};
|
|
114
|
+
return AccountsAndCustomersService;
|
|
115
|
+
}());
|
|
116
|
+
exports.default = AccountsAndCustomersService;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import TastytradeHttpClient from "./tastytrade-http-client";
|
|
2
|
+
export default class BalancesAndPositionsService {
|
|
3
|
+
private httpClient;
|
|
4
|
+
constructor(httpClient: TastytradeHttpClient);
|
|
5
|
+
getPositionsList(accountNumber: string, queryParams?: {}): Promise<any>;
|
|
6
|
+
getAccountBalanceValues(accountNumber: string): Promise<any>;
|
|
7
|
+
getBalanceSnapshots(accountNumber: string, queryParams?: {}): Promise<any>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
var response_util_1 = __importDefault(require("../utils/response-util"));
|
|
43
|
+
var BalancesAndPositionsService = /** @class */ (function () {
|
|
44
|
+
function BalancesAndPositionsService(httpClient) {
|
|
45
|
+
this.httpClient = httpClient;
|
|
46
|
+
}
|
|
47
|
+
//Positions: Operations about positions
|
|
48
|
+
BalancesAndPositionsService.prototype.getPositionsList = function (accountNumber, queryParams) {
|
|
49
|
+
if (queryParams === void 0) { queryParams = {}; }
|
|
50
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
51
|
+
var positionsList;
|
|
52
|
+
return __generator(this, function (_a) {
|
|
53
|
+
switch (_a.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/positions"), {}, queryParams)];
|
|
55
|
+
case 1:
|
|
56
|
+
positionsList = (_a.sent());
|
|
57
|
+
return [2 /*return*/, (0, response_util_1.default)(positionsList)];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
//Accounts: Operations about accounts
|
|
63
|
+
BalancesAndPositionsService.prototype.getAccountBalanceValues = function (accountNumber) {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var accountBalanceValues;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/balances"), {}, {})];
|
|
69
|
+
case 1:
|
|
70
|
+
accountBalanceValues = (_a.sent());
|
|
71
|
+
return [2 /*return*/, (0, response_util_1.default)(accountBalanceValues)];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
//Balance-snapshots Operations about balance-snapshots
|
|
77
|
+
BalancesAndPositionsService.prototype.getBalanceSnapshots = function (accountNumber, queryParams) {
|
|
78
|
+
if (queryParams === void 0) { queryParams = {}; }
|
|
79
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
80
|
+
var balanceSnapshot;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/balance-snapshots"), {}, queryParams)];
|
|
84
|
+
case 1:
|
|
85
|
+
balanceSnapshot = (_a.sent());
|
|
86
|
+
return [2 /*return*/, (0, response_util_1.default)(balanceSnapshot)];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
return BalancesAndPositionsService;
|
|
92
|
+
}());
|
|
93
|
+
exports.default = BalancesAndPositionsService;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import TastytradeHttpClient from "./tastytrade-http-client";
|
|
2
|
+
export default class InstrumentsService {
|
|
3
|
+
private httpClient;
|
|
4
|
+
constructor(httpClient: TastytradeHttpClient);
|
|
5
|
+
getCryptocurrencies(symbols?: string[]): Promise<any>;
|
|
6
|
+
getSingleCryptocurrency(symbol: string): Promise<any>;
|
|
7
|
+
getActiveEquities(queryParams?: {}): Promise<any>;
|
|
8
|
+
getEquityDefinitions(queryParams?: {}): Promise<any>;
|
|
9
|
+
getSingleEquity(symbol: string): Promise<any>;
|
|
10
|
+
getEquityOptions(symbols: string[], active?: boolean, withExpired?: boolean): Promise<any>;
|
|
11
|
+
getSingleEquityOption(symbol: string, queryParams?: {}): Promise<any>;
|
|
12
|
+
getFutures(queryParams?: {}): Promise<any>;
|
|
13
|
+
getSingleFuture(symbol: string): Promise<any>;
|
|
14
|
+
getFutureOptionsProducts(): Promise<any>;
|
|
15
|
+
getSingleFutureOptionProduct(exchange: string, rootSymbol: string): Promise<any>;
|
|
16
|
+
getFutureOptions(queryParams?: {}): Promise<any>;
|
|
17
|
+
getSingleFutureOption(symbol: string): Promise<any>;
|
|
18
|
+
getFuturesProducts(): Promise<any>;
|
|
19
|
+
getSingleFutureProduct(exchange: string, code: string): Promise<any>;
|
|
20
|
+
getQuantityDecimalPrecisions(): Promise<any>;
|
|
21
|
+
getWarrants(queryParams?: {}): Promise<any>;
|
|
22
|
+
getSingleWarrant(symbol: string): Promise<any>;
|
|
23
|
+
getNestedFutureOptionChains(symbol: string): Promise<any>;
|
|
24
|
+
getFutureOptionChain(symbol: string): Promise<any>;
|
|
25
|
+
getNestedOptionChain(symbol: string): Promise<any>;
|
|
26
|
+
getCompactOptionChain(symbol: string): Promise<any>;
|
|
27
|
+
getOptionChain(symbol: string): Promise<any>;
|
|
28
|
+
}
|