@tastytrade/api 3.0.0 → 3.1.0
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/dist/services/account-status-service.js +1 -1
- package/dist/services/orders-service.d.ts +2 -0
- package/dist/services/orders-service.js +26 -0
- package/dist/services/tastytrade-http-client.js +1 -0
- package/lib/services/account-status-service.ts +1 -1
- package/lib/services/orders-service.ts +12 -0
- package/lib/services/tastytrade-http-client.ts +1 -0
- package/package.json +1 -1
|
@@ -40,7 +40,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
40
40
|
};
|
|
41
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
42
|
var response_util_1 = __importDefault(require("../utils/response-util"));
|
|
43
|
-
// create the central class that aggregates all services
|
|
43
|
+
// create the central class that aggregates all services
|
|
44
44
|
var AccountStatusService = /** @class */ (function () {
|
|
45
45
|
function AccountStatusService(httpClient) {
|
|
46
46
|
this.httpClient = httpClient;
|
|
@@ -6,11 +6,13 @@ export default class OrderService {
|
|
|
6
6
|
replacementOrderDryRun(accountNumber: string, orderId: number, replacementOrder: object): Promise<any>;
|
|
7
7
|
getOrder(accountNumber: string, orderId: number): Promise<any>;
|
|
8
8
|
cancelOrder(accountNumber: string, orderId: number): Promise<any>;
|
|
9
|
+
cancelComplexOrder(accountNumber: string, orderId: number): Promise<any>;
|
|
9
10
|
replaceOrder(accountNumber: string, orderId: number, replacementOrder: object): Promise<any>;
|
|
10
11
|
editOrder(accountNumber: string, orderId: number, order: object): Promise<any>;
|
|
11
12
|
getLiveOrders(accountNumber: string): Promise<any>;
|
|
12
13
|
getOrders(accountNumber: string, queryParams?: {}): Promise<any>;
|
|
13
14
|
createOrder(accountNumber: string, order: object): Promise<any>;
|
|
15
|
+
createComplexOrder(accountNumber: string, order: object): Promise<any>;
|
|
14
16
|
postOrderDryRun(accountNumber: string, order: object): Promise<any>;
|
|
15
17
|
getLiveOrdersForCustomer(customerId: string): Promise<any>;
|
|
16
18
|
getCustomerOrders(customerId: string, queryParams?: {}): Promise<any>;
|
|
@@ -97,6 +97,19 @@ var OrderService = /** @class */ (function () {
|
|
|
97
97
|
});
|
|
98
98
|
});
|
|
99
99
|
};
|
|
100
|
+
OrderService.prototype.cancelComplexOrder = function (accountNumber, orderId) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
var order;
|
|
103
|
+
return __generator(this, function (_a) {
|
|
104
|
+
switch (_a.label) {
|
|
105
|
+
case 0: return [4 /*yield*/, this.httpClient.deleteData("/accounts/".concat(accountNumber, "/complex-orders/").concat(orderId), {})];
|
|
106
|
+
case 1:
|
|
107
|
+
order = _a.sent();
|
|
108
|
+
return [2 /*return*/, (0, response_util_1.default)(order)];
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
100
113
|
OrderService.prototype.replaceOrder = function (accountNumber, orderId, replacementOrder) {
|
|
101
114
|
return __awaiter(this, void 0, void 0, function () {
|
|
102
115
|
var order;
|
|
@@ -163,6 +176,19 @@ var OrderService = /** @class */ (function () {
|
|
|
163
176
|
});
|
|
164
177
|
});
|
|
165
178
|
};
|
|
179
|
+
OrderService.prototype.createComplexOrder = function (accountNumber, order) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var orderResponse;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
switch (_a.label) {
|
|
184
|
+
case 0: return [4 /*yield*/, this.httpClient.postData("/accounts/".concat(accountNumber, "/complex-orders"), order, {})];
|
|
185
|
+
case 1:
|
|
186
|
+
orderResponse = _a.sent();
|
|
187
|
+
return [2 /*return*/, (0, response_util_1.default)(orderResponse)];
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
});
|
|
191
|
+
};
|
|
166
192
|
OrderService.prototype.postOrderDryRun = function (accountNumber, order) {
|
|
167
193
|
return __awaiter(this, void 0, void 0, function () {
|
|
168
194
|
var orderDryRun;
|
|
@@ -73,6 +73,7 @@ var TastytradeHttpClient = /** @class */ (function () {
|
|
|
73
73
|
"Content-Type": "application/json",
|
|
74
74
|
"Accept": "application/json",
|
|
75
75
|
"Authorization": this.session.authToken,
|
|
76
|
+
"User-Agent": 'tastytrade-sdk-js'
|
|
76
77
|
};
|
|
77
78
|
};
|
|
78
79
|
TastytradeHttpClient.prototype.executeRequest = function (method, url, data, headers, params) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import extractResponseData from "../utils/response-util";
|
|
2
2
|
import TastytradeHttpClient from "./tastytrade-http-client";
|
|
3
3
|
|
|
4
|
-
// create the central class that aggregates all services
|
|
4
|
+
// create the central class that aggregates all services
|
|
5
5
|
export default class AccountStatusService {
|
|
6
6
|
constructor(private httpClient: TastytradeHttpClient) {
|
|
7
7
|
}
|
|
@@ -30,6 +30,12 @@ export default class OrderService {
|
|
|
30
30
|
return extractResponseData(order)
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
async cancelComplexOrder(accountNumber: string, orderId: number){
|
|
34
|
+
//Requests order cancellation
|
|
35
|
+
const order = await this.httpClient.deleteData(`/accounts/${accountNumber}/complex-orders/${orderId}`, {})
|
|
36
|
+
return extractResponseData(order)
|
|
37
|
+
}
|
|
38
|
+
|
|
33
39
|
async replaceOrder(accountNumber: string, orderId: number, replacementOrder : object){
|
|
34
40
|
//Replaces a live order with a new one. Subsequent fills of the original order will abort the replacement.
|
|
35
41
|
const order = await this.httpClient.putData(`/accounts/${accountNumber}/orders/${orderId}`, replacementOrder , {})
|
|
@@ -60,6 +66,12 @@ export default class OrderService {
|
|
|
60
66
|
return extractResponseData(orderResponse)
|
|
61
67
|
}
|
|
62
68
|
|
|
69
|
+
async createComplexOrder(accountNumber: string, order: object){
|
|
70
|
+
//Accepts a json document containing parameters to create an order for the client.
|
|
71
|
+
const orderResponse = await this.httpClient.postData(`/accounts/${accountNumber}/complex-orders`, order , {})
|
|
72
|
+
return extractResponseData(orderResponse)
|
|
73
|
+
}
|
|
74
|
+
|
|
63
75
|
async postOrderDryRun(accountNumber: string, order: object){
|
|
64
76
|
//Accepts a json document containing parameters to create an order and then runs the prefights without placing the order.
|
|
65
77
|
const orderDryRun = await this.httpClient.postData(`/accounts/${accountNumber}/orders/dry-run`, order , {})
|