@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.
Files changed (67) hide show
  1. package/.env +5 -0
  2. package/.eslintrc.cjs +18 -0
  3. package/.vscode/launch.json +24 -0
  4. package/LICENSE +21 -0
  5. package/README.md +21 -0
  6. package/dist/account-streamer.d.ts +92 -0
  7. package/dist/account-streamer.js +394 -0
  8. package/dist/models/tastytrade-session.d.ts +5 -0
  9. package/dist/models/tastytrade-session.js +23 -0
  10. package/dist/quote-streamer.d.ts +11 -0
  11. package/dist/quote-streamer.js +63 -0
  12. package/dist/services/account-status-service.d.ts +6 -0
  13. package/dist/services/account-status-service.js +64 -0
  14. package/dist/services/accounts-and-customers-service.d.ts +10 -0
  15. package/dist/services/accounts-and-customers-service.js +116 -0
  16. package/dist/services/balances-and-positions-service.d.ts +8 -0
  17. package/dist/services/balances-and-positions-service.js +93 -0
  18. package/dist/services/instruments-service.d.ts +28 -0
  19. package/dist/services/instruments-service.js +370 -0
  20. package/dist/services/margin-requirements-service.d.ts +7 -0
  21. package/dist/services/margin-requirements-service.js +76 -0
  22. package/dist/services/market-metrics-service.d.ts +8 -0
  23. package/dist/services/market-metrics-service.js +91 -0
  24. package/dist/services/net-liquidating-value-history-service.d.ts +7 -0
  25. package/dist/services/net-liquidating-value-history-service.js +77 -0
  26. package/dist/services/orders-service.d.ts +17 -0
  27. package/dist/services/orders-service.js +208 -0
  28. package/dist/services/risk-parameters-service.d.ts +7 -0
  29. package/dist/services/risk-parameters-service.js +76 -0
  30. package/dist/services/session-service.d.ts +9 -0
  31. package/dist/services/session-service.js +113 -0
  32. package/dist/services/symbol-search-service.d.ts +6 -0
  33. package/dist/services/symbol-search-service.js +63 -0
  34. package/dist/services/tastytrade-http-client.d.ts +13 -0
  35. package/dist/services/tastytrade-http-client.js +137 -0
  36. package/dist/services/transactions-service.d.ts +8 -0
  37. package/dist/services/transactions-service.js +91 -0
  38. package/dist/services/watchlists-service.d.ts +14 -0
  39. package/dist/services/watchlists-service.js +170 -0
  40. package/dist/tastytrade-api.d.ts +40 -0
  41. package/dist/tastytrade-api.js +56 -0
  42. package/dist/utils/json-util.d.ts +14 -0
  43. package/dist/utils/json-util.js +43 -0
  44. package/dist/utils/response-util.d.ts +1 -0
  45. package/dist/utils/response-util.js +21 -0
  46. package/lib/account-streamer.ts +394 -0
  47. package/lib/models/tastytrade-session.ts +13 -0
  48. package/lib/quote-streamer.ts +40 -0
  49. package/lib/services/account-status-service.ts +15 -0
  50. package/lib/services/accounts-and-customers-service.ts +35 -0
  51. package/lib/services/balances-and-positions-service.ts +29 -0
  52. package/lib/services/instruments-service.ts +138 -0
  53. package/lib/services/margin-requirements-service.ts +19 -0
  54. package/lib/services/market-metrics-service.ts +24 -0
  55. package/lib/services/net-liquidating-value-history-service.ts +20 -0
  56. package/lib/services/orders-service.ts +80 -0
  57. package/lib/services/risk-parameters-service.ts +19 -0
  58. package/lib/services/session-service.ts +35 -0
  59. package/lib/services/symbol-search-service.ts +14 -0
  60. package/lib/services/tastytrade-http-client.ts +65 -0
  61. package/lib/services/transactions-service.ts +27 -0
  62. package/lib/services/watchlists-service.ts +58 -0
  63. package/lib/tastytrade-api.ts +65 -0
  64. package/lib/utils/json-util.ts +44 -0
  65. package/lib/utils/response-util.ts +15 -0
  66. package/package.json +35 -0
  67. package/tsconfig.json +71 -0
@@ -0,0 +1,370 @@
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 lodash_1 = __importDefault(require("lodash"));
44
+ var InstrumentsService = /** @class */ (function () {
45
+ function InstrumentsService(httpClient) {
46
+ this.httpClient = httpClient;
47
+ }
48
+ //Instruments: Allows an API client to fetch data about instruments.
49
+ InstrumentsService.prototype.getCryptocurrencies = function (symbols) {
50
+ if (symbols === void 0) { symbols = []; }
51
+ return __awaiter(this, void 0, void 0, function () {
52
+ var queryParams, cryptocurrencies;
53
+ return __generator(this, function (_a) {
54
+ switch (_a.label) {
55
+ case 0:
56
+ queryParams = { symbol: symbols };
57
+ return [4 /*yield*/, this.httpClient.getData("/instruments/cryptocurrencies", {}, queryParams)];
58
+ case 1:
59
+ cryptocurrencies = (_a.sent());
60
+ return [2 /*return*/, (0, response_util_1.default)(cryptocurrencies)];
61
+ }
62
+ });
63
+ });
64
+ };
65
+ InstrumentsService.prototype.getSingleCryptocurrency = function (symbol) {
66
+ return __awaiter(this, void 0, void 0, function () {
67
+ var encodedSymbol, singleCryptocurrency;
68
+ return __generator(this, function (_a) {
69
+ switch (_a.label) {
70
+ case 0:
71
+ encodedSymbol = encodeURIComponent(symbol);
72
+ return [4 /*yield*/, this.httpClient.getData("/instruments/cryptocurrencies/".concat(encodedSymbol), {}, {})];
73
+ case 1:
74
+ singleCryptocurrency = (_a.sent());
75
+ return [2 /*return*/, (0, response_util_1.default)(singleCryptocurrency)];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ InstrumentsService.prototype.getActiveEquities = function (queryParams) {
81
+ if (queryParams === void 0) { queryParams = {}; }
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var activeEquities;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/equities/active", {}, queryParams)];
87
+ case 1:
88
+ activeEquities = (_a.sent());
89
+ return [2 /*return*/, (0, response_util_1.default)(activeEquities)];
90
+ }
91
+ });
92
+ });
93
+ };
94
+ InstrumentsService.prototype.getEquityDefinitions = function (queryParams) {
95
+ if (queryParams === void 0) { queryParams = {}; }
96
+ return __awaiter(this, void 0, void 0, function () {
97
+ var equityDefinitions;
98
+ return __generator(this, function (_a) {
99
+ switch (_a.label) {
100
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/equities", {}, queryParams)];
101
+ case 1:
102
+ equityDefinitions = (_a.sent());
103
+ return [2 /*return*/, (0, response_util_1.default)(equityDefinitions)];
104
+ }
105
+ });
106
+ });
107
+ };
108
+ InstrumentsService.prototype.getSingleEquity = function (symbol) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ var singleEquity;
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/equities/".concat(symbol), {}, {})];
114
+ case 1:
115
+ singleEquity = (_a.sent());
116
+ return [2 /*return*/, (0, response_util_1.default)(singleEquity)];
117
+ }
118
+ });
119
+ });
120
+ };
121
+ InstrumentsService.prototype.getEquityOptions = function (symbols, active, withExpired) {
122
+ if (active === void 0) { active = true; }
123
+ if (withExpired === void 0) { withExpired = false; }
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ var queryParams, equityOptions;
126
+ return __generator(this, function (_a) {
127
+ switch (_a.label) {
128
+ case 0:
129
+ if (lodash_1.default.isEmpty(symbols)) {
130
+ throw new Error('Symbols are required for InstrumentService.getEquityOptions');
131
+ }
132
+ queryParams = { symbols: symbols, active: active, withExpired: withExpired };
133
+ return [4 /*yield*/, this.httpClient.getData("/instruments/equity-options", {}, queryParams)];
134
+ case 1:
135
+ equityOptions = (_a.sent());
136
+ return [2 /*return*/, (0, response_util_1.default)(equityOptions)];
137
+ }
138
+ });
139
+ });
140
+ };
141
+ InstrumentsService.prototype.getSingleEquityOption = function (symbol, queryParams) {
142
+ if (queryParams === void 0) { queryParams = {}; }
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ var singleOption;
145
+ return __generator(this, function (_a) {
146
+ switch (_a.label) {
147
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/equity-options/".concat(symbol), {}, queryParams)];
148
+ case 1:
149
+ singleOption = _a.sent();
150
+ return [2 /*return*/, (0, response_util_1.default)(singleOption)];
151
+ }
152
+ });
153
+ });
154
+ };
155
+ InstrumentsService.prototype.getFutures = function (queryParams) {
156
+ if (queryParams === void 0) { queryParams = {}; }
157
+ return __awaiter(this, void 0, void 0, function () {
158
+ var futures;
159
+ return __generator(this, function (_a) {
160
+ switch (_a.label) {
161
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/futures", {}, queryParams)];
162
+ case 1:
163
+ futures = (_a.sent());
164
+ return [2 /*return*/, (0, response_util_1.default)(futures)];
165
+ }
166
+ });
167
+ });
168
+ };
169
+ InstrumentsService.prototype.getSingleFuture = function (symbol) {
170
+ return __awaiter(this, void 0, void 0, function () {
171
+ var singleFuture;
172
+ return __generator(this, function (_a) {
173
+ switch (_a.label) {
174
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/futures/".concat(symbol), {}, {})];
175
+ case 1:
176
+ singleFuture = _a.sent();
177
+ return [2 /*return*/, (0, response_util_1.default)(singleFuture)];
178
+ }
179
+ });
180
+ });
181
+ };
182
+ InstrumentsService.prototype.getFutureOptionsProducts = function () {
183
+ return __awaiter(this, void 0, void 0, function () {
184
+ var futureOptionsProducts;
185
+ return __generator(this, function (_a) {
186
+ switch (_a.label) {
187
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-option-products", {}, {})];
188
+ case 1:
189
+ futureOptionsProducts = (_a.sent());
190
+ return [2 /*return*/, (0, response_util_1.default)(futureOptionsProducts)];
191
+ }
192
+ });
193
+ });
194
+ };
195
+ InstrumentsService.prototype.getSingleFutureOptionProduct = function (exchange, rootSymbol) {
196
+ return __awaiter(this, void 0, void 0, function () {
197
+ var singleFutureOptionProduct;
198
+ return __generator(this, function (_a) {
199
+ switch (_a.label) {
200
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-option-products/".concat(exchange, "/").concat(rootSymbol), {}, {})];
201
+ case 1:
202
+ singleFutureOptionProduct = (_a.sent());
203
+ return [2 /*return*/, (0, response_util_1.default)(singleFutureOptionProduct)];
204
+ }
205
+ });
206
+ });
207
+ };
208
+ InstrumentsService.prototype.getFutureOptions = function (queryParams) {
209
+ if (queryParams === void 0) { queryParams = {}; }
210
+ return __awaiter(this, void 0, void 0, function () {
211
+ var futureOptions;
212
+ return __generator(this, function (_a) {
213
+ switch (_a.label) {
214
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-options", {}, queryParams)];
215
+ case 1:
216
+ futureOptions = (_a.sent());
217
+ return [2 /*return*/, (0, response_util_1.default)(futureOptions)];
218
+ }
219
+ });
220
+ });
221
+ };
222
+ InstrumentsService.prototype.getSingleFutureOption = function (symbol) {
223
+ return __awaiter(this, void 0, void 0, function () {
224
+ var singleFutureOption;
225
+ return __generator(this, function (_a) {
226
+ switch (_a.label) {
227
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-options/".concat(symbol), {}, {})];
228
+ case 1:
229
+ singleFutureOption = _a.sent();
230
+ return [2 /*return*/, (0, response_util_1.default)(singleFutureOption)];
231
+ }
232
+ });
233
+ });
234
+ };
235
+ InstrumentsService.prototype.getFuturesProducts = function () {
236
+ return __awaiter(this, void 0, void 0, function () {
237
+ var futuresProducts;
238
+ return __generator(this, function (_a) {
239
+ switch (_a.label) {
240
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-products", {}, {})];
241
+ case 1:
242
+ futuresProducts = (_a.sent());
243
+ return [2 /*return*/, (0, response_util_1.default)(futuresProducts)];
244
+ }
245
+ });
246
+ });
247
+ };
248
+ InstrumentsService.prototype.getSingleFutureProduct = function (exchange, code) {
249
+ return __awaiter(this, void 0, void 0, function () {
250
+ var singleFutureProduct;
251
+ return __generator(this, function (_a) {
252
+ switch (_a.label) {
253
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/future-products/".concat(exchange, "/").concat(code), {}, {})];
254
+ case 1:
255
+ singleFutureProduct = (_a.sent());
256
+ return [2 /*return*/, (0, response_util_1.default)(singleFutureProduct)];
257
+ }
258
+ });
259
+ });
260
+ };
261
+ InstrumentsService.prototype.getQuantityDecimalPrecisions = function () {
262
+ return __awaiter(this, void 0, void 0, function () {
263
+ var quantityDecimalPrecisions;
264
+ return __generator(this, function (_a) {
265
+ switch (_a.label) {
266
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/quantity-decimal-precisions", {}, {})];
267
+ case 1:
268
+ quantityDecimalPrecisions = (_a.sent());
269
+ return [2 /*return*/, (0, response_util_1.default)(quantityDecimalPrecisions)];
270
+ }
271
+ });
272
+ });
273
+ };
274
+ InstrumentsService.prototype.getWarrants = function (queryParams) {
275
+ if (queryParams === void 0) { queryParams = {}; }
276
+ return __awaiter(this, void 0, void 0, function () {
277
+ var warrants;
278
+ return __generator(this, function (_a) {
279
+ switch (_a.label) {
280
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/warrants", {}, queryParams)];
281
+ case 1:
282
+ warrants = (_a.sent());
283
+ return [2 /*return*/, (0, response_util_1.default)(warrants)];
284
+ }
285
+ });
286
+ });
287
+ };
288
+ InstrumentsService.prototype.getSingleWarrant = function (symbol) {
289
+ return __awaiter(this, void 0, void 0, function () {
290
+ var singleWarrant;
291
+ return __generator(this, function (_a) {
292
+ switch (_a.label) {
293
+ case 0: return [4 /*yield*/, this.httpClient.getData("/instruments/warrants/".concat(symbol), {}, {})];
294
+ case 1:
295
+ singleWarrant = (_a.sent());
296
+ return [2 /*return*/, (0, response_util_1.default)(singleWarrant)];
297
+ }
298
+ });
299
+ });
300
+ };
301
+ //Futures-option-chains: Allows an API client to fetch futures option chains.
302
+ InstrumentsService.prototype.getNestedFutureOptionChains = function (symbol) {
303
+ return __awaiter(this, void 0, void 0, function () {
304
+ var nestedFutureOptionChains;
305
+ return __generator(this, function (_a) {
306
+ switch (_a.label) {
307
+ case 0: return [4 /*yield*/, this.httpClient.getData("/futures-option-chains/".concat(symbol, "/nested"), {}, {})];
308
+ case 1:
309
+ nestedFutureOptionChains = (_a.sent());
310
+ return [2 /*return*/, (0, response_util_1.default)(nestedFutureOptionChains)];
311
+ }
312
+ });
313
+ });
314
+ };
315
+ InstrumentsService.prototype.getFutureOptionChain = function (symbol) {
316
+ return __awaiter(this, void 0, void 0, function () {
317
+ var futureOptionChain;
318
+ return __generator(this, function (_a) {
319
+ switch (_a.label) {
320
+ case 0: return [4 /*yield*/, this.httpClient.getData("/futures-option-chains/".concat(symbol), {}, {})];
321
+ case 1:
322
+ futureOptionChain = (_a.sent());
323
+ return [2 /*return*/, (0, response_util_1.default)(futureOptionChain)];
324
+ }
325
+ });
326
+ });
327
+ };
328
+ //Option-chains: Allows an API client to fetch futures option chains.
329
+ InstrumentsService.prototype.getNestedOptionChain = function (symbol) {
330
+ return __awaiter(this, void 0, void 0, function () {
331
+ var nestedOptionChain;
332
+ return __generator(this, function (_a) {
333
+ switch (_a.label) {
334
+ case 0: return [4 /*yield*/, this.httpClient.getData("/option-chains/".concat(symbol, "/nested"), {}, {})];
335
+ case 1:
336
+ nestedOptionChain = (_a.sent());
337
+ return [2 /*return*/, (0, response_util_1.default)(nestedOptionChain)];
338
+ }
339
+ });
340
+ });
341
+ };
342
+ InstrumentsService.prototype.getCompactOptionChain = function (symbol) {
343
+ return __awaiter(this, void 0, void 0, function () {
344
+ var compactOptionChain;
345
+ return __generator(this, function (_a) {
346
+ switch (_a.label) {
347
+ case 0: return [4 /*yield*/, this.httpClient.getData("/option-chains/".concat(symbol, "/compact"), {}, {})];
348
+ case 1:
349
+ compactOptionChain = (_a.sent());
350
+ return [2 /*return*/, (0, response_util_1.default)(compactOptionChain)];
351
+ }
352
+ });
353
+ });
354
+ };
355
+ InstrumentsService.prototype.getOptionChain = function (symbol) {
356
+ return __awaiter(this, void 0, void 0, function () {
357
+ var optionChain;
358
+ return __generator(this, function (_a) {
359
+ switch (_a.label) {
360
+ case 0: return [4 /*yield*/, this.httpClient.getData("/option-chains/".concat(symbol), {}, {})];
361
+ case 1:
362
+ optionChain = (_a.sent());
363
+ return [2 /*return*/, (0, response_util_1.default)(optionChain)];
364
+ }
365
+ });
366
+ });
367
+ };
368
+ return InstrumentsService;
369
+ }());
370
+ exports.default = InstrumentsService;
@@ -0,0 +1,7 @@
1
+ import TastytradeHttpClient from "./tastytrade-http-client";
2
+ export default class MarginRequirementsService {
3
+ private httpClient;
4
+ constructor(httpClient: TastytradeHttpClient);
5
+ getMarginRequirements(accountNumber: string): Promise<any>;
6
+ postMarginRequirements(accountNumber: string, order: object): Promise<any>;
7
+ }
@@ -0,0 +1,76 @@
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 MarginRequirementsService = /** @class */ (function () {
44
+ function MarginRequirementsService(httpClient) {
45
+ this.httpClient = httpClient;
46
+ }
47
+ //Margin-requirements: Allows a client to fetch margin-requirements for positions and orders
48
+ MarginRequirementsService.prototype.getMarginRequirements = function (accountNumber) {
49
+ return __awaiter(this, void 0, void 0, function () {
50
+ var marginRequirements;
51
+ return __generator(this, function (_a) {
52
+ switch (_a.label) {
53
+ case 0: return [4 /*yield*/, this.httpClient.getData("/margin/accounts/".concat(accountNumber, "/requirements"))];
54
+ case 1:
55
+ marginRequirements = (_a.sent());
56
+ return [2 /*return*/, (0, response_util_1.default)(marginRequirements)];
57
+ }
58
+ });
59
+ });
60
+ };
61
+ MarginRequirementsService.prototype.postMarginRequirements = function (accountNumber, order) {
62
+ return __awaiter(this, void 0, void 0, function () {
63
+ var marginRequirements;
64
+ return __generator(this, function (_a) {
65
+ switch (_a.label) {
66
+ case 0: return [4 /*yield*/, this.httpClient.postData("/margin/accounts/".concat(accountNumber, "/dry-run"), order, {})];
67
+ case 1:
68
+ marginRequirements = (_a.sent());
69
+ return [2 /*return*/, (0, response_util_1.default)(marginRequirements)];
70
+ }
71
+ });
72
+ });
73
+ };
74
+ return MarginRequirementsService;
75
+ }());
76
+ exports.default = MarginRequirementsService;
@@ -0,0 +1,8 @@
1
+ import TastytradeHttpClient from "./tastytrade-http-client";
2
+ export default class MarketMetricsService {
3
+ private httpClient;
4
+ constructor(httpClient: TastytradeHttpClient);
5
+ getMarketMetrics(queryParams?: {}): Promise<any>;
6
+ getHistoricalDividendData(symbol: string): Promise<any>;
7
+ getHistoricalEarningsData(symbol: string, queryParams?: {}): Promise<any>;
8
+ }
@@ -0,0 +1,91 @@
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 MarketMetricsService = /** @class */ (function () {
44
+ function MarketMetricsService(httpClient) {
45
+ this.httpClient = httpClient;
46
+ }
47
+ //Default
48
+ MarketMetricsService.prototype.getMarketMetrics = function (queryParams) {
49
+ if (queryParams === void 0) { queryParams = {}; }
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var marketMetrics;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0: return [4 /*yield*/, this.httpClient.getData('/market-metrics', {}, queryParams)];
55
+ case 1:
56
+ marketMetrics = (_a.sent());
57
+ return [2 /*return*/, (0, response_util_1.default)(marketMetrics)];
58
+ }
59
+ });
60
+ });
61
+ };
62
+ MarketMetricsService.prototype.getHistoricalDividendData = function (symbol) {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var historicalDividendData;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0: return [4 /*yield*/, this.httpClient.getData("/market-metrics/historic-corporate-events/dividends/".concat(symbol), {}, {})];
68
+ case 1:
69
+ historicalDividendData = (_a.sent());
70
+ return [2 /*return*/, (0, response_util_1.default)(historicalDividendData)];
71
+ }
72
+ });
73
+ });
74
+ };
75
+ MarketMetricsService.prototype.getHistoricalEarningsData = function (symbol, queryParams) {
76
+ if (queryParams === void 0) { queryParams = {}; }
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var historicalEarningsData;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0: return [4 /*yield*/, this.httpClient.getData("/market-metrics/historic-corporate-events/earnings-reports/".concat(symbol), {}, queryParams)];
82
+ case 1:
83
+ historicalEarningsData = (_a.sent());
84
+ return [2 /*return*/, (0, response_util_1.default)(historicalEarningsData)];
85
+ }
86
+ });
87
+ });
88
+ };
89
+ return MarketMetricsService;
90
+ }());
91
+ exports.default = MarketMetricsService;
@@ -0,0 +1,7 @@
1
+ import TastytradeHttpClient from "./tastytrade-http-client";
2
+ export default class NetLiquidatingValueHistoryService {
3
+ private httpClient;
4
+ constructor(httpClient: TastytradeHttpClient);
5
+ getNetLiquidatingValueHistory(accountNumber: string, queryParams?: {}): Promise<any>;
6
+ getNetLiquidatingValue(accountNumber: string): Promise<any>;
7
+ }
@@ -0,0 +1,77 @@
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 NetLiquidatingValueHistoryService = /** @class */ (function () {
44
+ function NetLiquidatingValueHistoryService(httpClient) {
45
+ this.httpClient = httpClient;
46
+ }
47
+ //Default
48
+ NetLiquidatingValueHistoryService.prototype.getNetLiquidatingValueHistory = function (accountNumber, queryParams) {
49
+ if (queryParams === void 0) { queryParams = {}; }
50
+ return __awaiter(this, void 0, void 0, function () {
51
+ var netLiquidatingValueHistory;
52
+ return __generator(this, function (_a) {
53
+ switch (_a.label) {
54
+ case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/net-liq/history"), {}, queryParams)];
55
+ case 1:
56
+ netLiquidatingValueHistory = (_a.sent());
57
+ return [2 /*return*/, (0, response_util_1.default)(netLiquidatingValueHistory)];
58
+ }
59
+ });
60
+ });
61
+ };
62
+ NetLiquidatingValueHistoryService.prototype.getNetLiquidatingValue = function (accountNumber) {
63
+ return __awaiter(this, void 0, void 0, function () {
64
+ var netLiquidatingValue;
65
+ return __generator(this, function (_a) {
66
+ switch (_a.label) {
67
+ case 0: return [4 /*yield*/, this.httpClient.getData("/accounts/".concat(accountNumber, "/net-liq"))];
68
+ case 1:
69
+ netLiquidatingValue = _a.sent();
70
+ return [2 /*return*/, (0, response_util_1.default)(netLiquidatingValue)];
71
+ }
72
+ });
73
+ });
74
+ };
75
+ return NetLiquidatingValueHistoryService;
76
+ }());
77
+ exports.default = NetLiquidatingValueHistoryService;
@@ -0,0 +1,17 @@
1
+ import TastytradeHttpClient from "./tastytrade-http-client";
2
+ export default class OrderService {
3
+ private httpClient;
4
+ constructor(httpClient: TastytradeHttpClient);
5
+ postReconfirmOrder(accountNumber: string, orderId: number): Promise<any>;
6
+ replacementOrderDryRun(accountNumber: string, orderId: number, replacementOrder: object): Promise<any>;
7
+ getOrder(accountNumber: string, orderId: number): Promise<any>;
8
+ cancelOrder(accountNumber: string, orderId: number): Promise<any>;
9
+ replaceOrder(accountNumber: string, orderId: number, replacementOrder: object): Promise<any>;
10
+ editOrder(accountNumber: string, orderId: number, order: object): Promise<any>;
11
+ getLiveOrders(accountNumber: string): Promise<any>;
12
+ getOrders(accountNumber: string, queryParams?: {}): Promise<any>;
13
+ createOrder(accountNumber: string, order: object): Promise<any>;
14
+ postOrderDryRun(accountNumber: string, order: object): Promise<any>;
15
+ getLiveOrdersForCustomer(customerId: string): Promise<any>;
16
+ getCustomerOrders(customerId: string, queryParams?: {}): Promise<any>;
17
+ }