snaptrade-typescript-sdk 6.4.0 → 8.0.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/.konfig/generate-id.txt +1 -1
- package/README.md +1 -1
- package/api/transactions-and-reporting-api.ts +26 -18
- package/configuration.ts +1 -1
- package/dist/api/transactions-and-reporting-api.d.ts +14 -14
- package/dist/api/transactions-and-reporting-api.js +16 -8
- package/dist/configuration.js +1 -1
- package/dist/models/brokerage.d.ts +2 -2
- package/dist/models/snap-trade-holdings-account.d.ts +2 -3
- package/dist/models/universal-activity.d.ts +2 -23
- package/dist/models/universal-activity.js +0 -21
- package/docs/TransactionsAndReportingApi.md +4 -4
- package/index.test.ts +60 -0
- package/models/brokerage.ts +2 -2
- package/models/snap-trade-holdings-account.ts +2 -5
- package/models/universal-activity.ts +2 -26
- package/package.json +4 -1
package/.konfig/generate-id.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
00ef5794-51d6-46ef-99cc-cd54502667c1
|
package/README.md
CHANGED
|
@@ -37,14 +37,14 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
|
|
|
37
37
|
* @summary Get transaction history for a user
|
|
38
38
|
* @param {string} userId
|
|
39
39
|
* @param {string} userSecret
|
|
40
|
-
* @param {string} [startDate]
|
|
41
|
-
* @param {string} [endDate]
|
|
40
|
+
* @param {string | Date} [startDate]
|
|
41
|
+
* @param {string | Date} [endDate]
|
|
42
42
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
43
43
|
* @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
|
|
44
44
|
* @param {*} [options] Override http request option.
|
|
45
45
|
* @throws {RequiredError}
|
|
46
46
|
*/
|
|
47
|
-
getActivities: async (userId: string, userSecret: string, startDate?: string, endDate?: string, accounts?: string, brokerageAuthorizations?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
47
|
+
getActivities: async (userId: string, userSecret: string, startDate?: string | Date, endDate?: string | Date, accounts?: string, brokerageAuthorizations?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
48
48
|
// verify required parameter 'userId' is not null or undefined
|
|
49
49
|
assertParamExists('getActivities', 'userId', userId)
|
|
50
50
|
// verify required parameter 'userSecret' is not null or undefined
|
|
@@ -68,11 +68,15 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
|
|
|
68
68
|
// authentication PartnerTimestamp required
|
|
69
69
|
await setApiKeyToObject({object: localVarQueryParameter, keyParamName: "timestamp", configuration})
|
|
70
70
|
if (startDate !== undefined) {
|
|
71
|
-
localVarQueryParameter['startDate'] = startDate
|
|
71
|
+
localVarQueryParameter['startDate'] = (startDate as any instanceof Date) ?
|
|
72
|
+
(startDate as any).toISOString().substr(0,10) :
|
|
73
|
+
startDate;
|
|
72
74
|
}
|
|
73
75
|
|
|
74
76
|
if (endDate !== undefined) {
|
|
75
|
-
localVarQueryParameter['endDate'] = endDate
|
|
77
|
+
localVarQueryParameter['endDate'] = (endDate as any instanceof Date) ?
|
|
78
|
+
(endDate as any).toISOString().substr(0,10) :
|
|
79
|
+
endDate;
|
|
76
80
|
}
|
|
77
81
|
|
|
78
82
|
if (accounts !== undefined) {
|
|
@@ -111,8 +115,8 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
|
|
|
111
115
|
/**
|
|
112
116
|
* Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
|
|
113
117
|
* @summary Get performance information for a specific timeframe
|
|
114
|
-
* @param {string} startDate
|
|
115
|
-
* @param {string} endDate
|
|
118
|
+
* @param {string | Date} startDate
|
|
119
|
+
* @param {string | Date} endDate
|
|
116
120
|
* @param {string} userId
|
|
117
121
|
* @param {string} userSecret
|
|
118
122
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
@@ -121,7 +125,7 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
|
|
|
121
125
|
* @param {*} [options] Override http request option.
|
|
122
126
|
* @throws {RequiredError}
|
|
123
127
|
*/
|
|
124
|
-
getReportingCustomRange: async (startDate: string, endDate: string, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
128
|
+
getReportingCustomRange: async (startDate: string | Date, endDate: string | Date, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
|
|
125
129
|
// verify required parameter 'startDate' is not null or undefined
|
|
126
130
|
assertParamExists('getReportingCustomRange', 'startDate', startDate)
|
|
127
131
|
// verify required parameter 'endDate' is not null or undefined
|
|
@@ -149,11 +153,15 @@ export const TransactionsAndReportingApiAxiosParamCreator = function (configurat
|
|
|
149
153
|
// authentication PartnerTimestamp required
|
|
150
154
|
await setApiKeyToObject({object: localVarQueryParameter, keyParamName: "timestamp", configuration})
|
|
151
155
|
if (startDate !== undefined) {
|
|
152
|
-
localVarQueryParameter['startDate'] = startDate
|
|
156
|
+
localVarQueryParameter['startDate'] = (startDate as any instanceof Date) ?
|
|
157
|
+
(startDate as any).toISOString().substr(0,10) :
|
|
158
|
+
startDate;
|
|
153
159
|
}
|
|
154
160
|
|
|
155
161
|
if (endDate !== undefined) {
|
|
156
|
-
localVarQueryParameter['endDate'] = endDate
|
|
162
|
+
localVarQueryParameter['endDate'] = (endDate as any instanceof Date) ?
|
|
163
|
+
(endDate as any).toISOString().substr(0,10) :
|
|
164
|
+
endDate;
|
|
157
165
|
}
|
|
158
166
|
|
|
159
167
|
if (accounts !== undefined) {
|
|
@@ -281,17 +289,17 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
|
|
|
281
289
|
|
|
282
290
|
/**
|
|
283
291
|
*
|
|
284
|
-
* @type {string}
|
|
292
|
+
* @type {string | Date}
|
|
285
293
|
* @memberof TransactionsAndReportingApiGetActivities
|
|
286
294
|
*/
|
|
287
|
-
readonly startDate?: string
|
|
295
|
+
readonly startDate?: string | Date
|
|
288
296
|
|
|
289
297
|
/**
|
|
290
298
|
*
|
|
291
|
-
* @type {string}
|
|
299
|
+
* @type {string | Date}
|
|
292
300
|
* @memberof TransactionsAndReportingApiGetActivities
|
|
293
301
|
*/
|
|
294
|
-
readonly endDate?: string
|
|
302
|
+
readonly endDate?: string | Date
|
|
295
303
|
|
|
296
304
|
/**
|
|
297
305
|
* Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
@@ -318,17 +326,17 @@ export type TransactionsAndReportingApiGetReportingCustomRangeRequest = {
|
|
|
318
326
|
|
|
319
327
|
/**
|
|
320
328
|
*
|
|
321
|
-
* @type {string}
|
|
329
|
+
* @type {string | Date}
|
|
322
330
|
* @memberof TransactionsAndReportingApiGetReportingCustomRange
|
|
323
331
|
*/
|
|
324
|
-
readonly startDate: string
|
|
332
|
+
readonly startDate: string | Date
|
|
325
333
|
|
|
326
334
|
/**
|
|
327
335
|
*
|
|
328
|
-
* @type {string}
|
|
336
|
+
* @type {string | Date}
|
|
329
337
|
* @memberof TransactionsAndReportingApiGetReportingCustomRange
|
|
330
338
|
*/
|
|
331
|
-
readonly endDate: string
|
|
339
|
+
readonly endDate: string | Date
|
|
332
340
|
|
|
333
341
|
/**
|
|
334
342
|
*
|
package/configuration.ts
CHANGED
|
@@ -110,7 +110,7 @@ export class Configuration {
|
|
|
110
110
|
this.accessToken = param.accessToken;
|
|
111
111
|
this.basePath = param.basePath;
|
|
112
112
|
this.baseOptions = param.baseOptions ?? {};
|
|
113
|
-
this.userAgent = param.userAgent === undefined ? "Konfig/
|
|
113
|
+
this.userAgent = param.userAgent === undefined ? "Konfig/8.0.0/typescript" : param.userAgent;
|
|
114
114
|
this.formDataCtor = param.formDataCtor;
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -25,19 +25,19 @@ export declare const TransactionsAndReportingApiAxiosParamCreator: (configuratio
|
|
|
25
25
|
* @summary Get transaction history for a user
|
|
26
26
|
* @param {string} userId
|
|
27
27
|
* @param {string} userSecret
|
|
28
|
-
* @param {string} [startDate]
|
|
29
|
-
* @param {string} [endDate]
|
|
28
|
+
* @param {string | Date} [startDate]
|
|
29
|
+
* @param {string | Date} [endDate]
|
|
30
30
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
31
31
|
* @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
|
|
32
32
|
* @param {*} [options] Override http request option.
|
|
33
33
|
* @throws {RequiredError}
|
|
34
34
|
*/
|
|
35
|
-
getActivities: (userId: string, userSecret: string, startDate?: string, endDate?: string, accounts?: string, brokerageAuthorizations?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
35
|
+
getActivities: (userId: string, userSecret: string, startDate?: string | Date, endDate?: string | Date, accounts?: string, brokerageAuthorizations?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
36
36
|
/**
|
|
37
37
|
* Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
|
|
38
38
|
* @summary Get performance information for a specific timeframe
|
|
39
|
-
* @param {string} startDate
|
|
40
|
-
* @param {string} endDate
|
|
39
|
+
* @param {string | Date} startDate
|
|
40
|
+
* @param {string | Date} endDate
|
|
41
41
|
* @param {string} userId
|
|
42
42
|
* @param {string} userSecret
|
|
43
43
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
@@ -46,7 +46,7 @@ export declare const TransactionsAndReportingApiAxiosParamCreator: (configuratio
|
|
|
46
46
|
* @param {*} [options] Override http request option.
|
|
47
47
|
* @throws {RequiredError}
|
|
48
48
|
*/
|
|
49
|
-
getReportingCustomRange: (startDate: string, endDate: string, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
49
|
+
getReportingCustomRange: (startDate: string | Date, endDate: string | Date, userId: string, userSecret: string, accounts?: string, detailed?: boolean, frequency?: string, options?: AxiosRequestConfig) => Promise<RequestArgs>;
|
|
50
50
|
};
|
|
51
51
|
/**
|
|
52
52
|
* TransactionsAndReportingApi - functional programming interface
|
|
@@ -112,16 +112,16 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
|
|
|
112
112
|
readonly userSecret: string;
|
|
113
113
|
/**
|
|
114
114
|
*
|
|
115
|
-
* @type {string}
|
|
115
|
+
* @type {string | Date}
|
|
116
116
|
* @memberof TransactionsAndReportingApiGetActivities
|
|
117
117
|
*/
|
|
118
|
-
readonly startDate?: string;
|
|
118
|
+
readonly startDate?: string | Date;
|
|
119
119
|
/**
|
|
120
120
|
*
|
|
121
|
-
* @type {string}
|
|
121
|
+
* @type {string | Date}
|
|
122
122
|
* @memberof TransactionsAndReportingApiGetActivities
|
|
123
123
|
*/
|
|
124
|
-
readonly endDate?: string;
|
|
124
|
+
readonly endDate?: string | Date;
|
|
125
125
|
/**
|
|
126
126
|
* Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
127
127
|
* @type {string}
|
|
@@ -143,16 +143,16 @@ export type TransactionsAndReportingApiGetActivitiesRequest = {
|
|
|
143
143
|
export type TransactionsAndReportingApiGetReportingCustomRangeRequest = {
|
|
144
144
|
/**
|
|
145
145
|
*
|
|
146
|
-
* @type {string}
|
|
146
|
+
* @type {string | Date}
|
|
147
147
|
* @memberof TransactionsAndReportingApiGetReportingCustomRange
|
|
148
148
|
*/
|
|
149
|
-
readonly startDate: string;
|
|
149
|
+
readonly startDate: string | Date;
|
|
150
150
|
/**
|
|
151
151
|
*
|
|
152
|
-
* @type {string}
|
|
152
|
+
* @type {string | Date}
|
|
153
153
|
* @memberof TransactionsAndReportingApiGetReportingCustomRange
|
|
154
154
|
*/
|
|
155
|
-
readonly endDate: string;
|
|
155
|
+
readonly endDate: string | Date;
|
|
156
156
|
/**
|
|
157
157
|
*
|
|
158
158
|
* @type {string}
|
|
@@ -96,8 +96,8 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
|
|
|
96
96
|
* @summary Get transaction history for a user
|
|
97
97
|
* @param {string} userId
|
|
98
98
|
* @param {string} userSecret
|
|
99
|
-
* @param {string} [startDate]
|
|
100
|
-
* @param {string} [endDate]
|
|
99
|
+
* @param {string | Date} [startDate]
|
|
100
|
+
* @param {string | Date} [endDate]
|
|
101
101
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
102
102
|
* @param {string} [brokerageAuthorizations] Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations
|
|
103
103
|
* @param {*} [options] Override http request option.
|
|
@@ -142,10 +142,14 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
|
|
|
142
142
|
// authentication PartnerTimestamp required
|
|
143
143
|
_a.sent();
|
|
144
144
|
if (startDate !== undefined) {
|
|
145
|
-
localVarQueryParameter['startDate'] = startDate
|
|
145
|
+
localVarQueryParameter['startDate'] = (startDate instanceof Date) ?
|
|
146
|
+
startDate.toISOString().substr(0, 10) :
|
|
147
|
+
startDate;
|
|
146
148
|
}
|
|
147
149
|
if (endDate !== undefined) {
|
|
148
|
-
localVarQueryParameter['endDate'] = endDate
|
|
150
|
+
localVarQueryParameter['endDate'] = (endDate instanceof Date) ?
|
|
151
|
+
endDate.toISOString().substr(0, 10) :
|
|
152
|
+
endDate;
|
|
149
153
|
}
|
|
150
154
|
if (accounts !== undefined) {
|
|
151
155
|
localVarQueryParameter['accounts'] = accounts;
|
|
@@ -179,8 +183,8 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
|
|
|
179
183
|
/**
|
|
180
184
|
* Returns performance information (contributions, dividends, rate of return, etc) for a specific timeframe. Total Equity Timeframe and Rate of Returns are experimental and should not be trusted to be 100% accurate
|
|
181
185
|
* @summary Get performance information for a specific timeframe
|
|
182
|
-
* @param {string} startDate
|
|
183
|
-
* @param {string} endDate
|
|
186
|
+
* @param {string | Date} startDate
|
|
187
|
+
* @param {string | Date} endDate
|
|
184
188
|
* @param {string} userId
|
|
185
189
|
* @param {string} userSecret
|
|
186
190
|
* @param {string} [accounts] Optional comma seperated list of account IDs used to filter the request on specific accounts
|
|
@@ -232,10 +236,14 @@ var TransactionsAndReportingApiAxiosParamCreator = function (configuration) {
|
|
|
232
236
|
// authentication PartnerTimestamp required
|
|
233
237
|
_a.sent();
|
|
234
238
|
if (startDate !== undefined) {
|
|
235
|
-
localVarQueryParameter['startDate'] = startDate
|
|
239
|
+
localVarQueryParameter['startDate'] = (startDate instanceof Date) ?
|
|
240
|
+
startDate.toISOString().substr(0, 10) :
|
|
241
|
+
startDate;
|
|
236
242
|
}
|
|
237
243
|
if (endDate !== undefined) {
|
|
238
|
-
localVarQueryParameter['endDate'] = endDate
|
|
244
|
+
localVarQueryParameter['endDate'] = (endDate instanceof Date) ?
|
|
245
|
+
endDate.toISOString().substr(0, 10) :
|
|
246
|
+
endDate;
|
|
239
247
|
}
|
|
240
248
|
if (accounts !== undefined) {
|
|
241
249
|
localVarQueryParameter['accounts'] = accounts;
|
package/dist/configuration.js
CHANGED
|
@@ -34,7 +34,7 @@ var Configuration = /** @class */ (function () {
|
|
|
34
34
|
this.accessToken = param.accessToken;
|
|
35
35
|
this.basePath = param.basePath;
|
|
36
36
|
this.baseOptions = (_a = param.baseOptions) !== null && _a !== void 0 ? _a : {};
|
|
37
|
-
this.userAgent = param.userAgent === undefined ? "Konfig/
|
|
37
|
+
this.userAgent = param.userAgent === undefined ? "Konfig/8.0.0/typescript" : param.userAgent;
|
|
38
38
|
this.formDataCtor = param.formDataCtor;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
@@ -82,13 +82,13 @@ export interface Brokerage {
|
|
|
82
82
|
* @type {boolean}
|
|
83
83
|
* @memberof Brokerage
|
|
84
84
|
*/
|
|
85
|
-
'allows_trading'?: boolean;
|
|
85
|
+
'allows_trading'?: boolean | null;
|
|
86
86
|
/**
|
|
87
87
|
*
|
|
88
88
|
* @type {boolean}
|
|
89
89
|
* @memberof Brokerage
|
|
90
90
|
*/
|
|
91
|
-
'has_reporting'?: boolean;
|
|
91
|
+
'has_reporting'?: boolean | null;
|
|
92
92
|
/**
|
|
93
93
|
*
|
|
94
94
|
* @type {boolean}
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
* https://konfigthis.com
|
|
10
10
|
* Do not edit the class manually.
|
|
11
11
|
*/
|
|
12
|
-
import { BrokerageAuthorization } from './brokerage-authorization';
|
|
13
12
|
/**
|
|
14
13
|
* SnapTradeUser Investment Account
|
|
15
14
|
* @export
|
|
@@ -25,10 +24,10 @@ export interface SnapTradeHoldingsAccount {
|
|
|
25
24
|
'id'?: string;
|
|
26
25
|
/**
|
|
27
26
|
*
|
|
28
|
-
* @type {
|
|
27
|
+
* @type {string}
|
|
29
28
|
* @memberof SnapTradeHoldingsAccount
|
|
30
29
|
*/
|
|
31
|
-
'brokerage_authorization'?:
|
|
30
|
+
'brokerage_authorization'?: string;
|
|
32
31
|
/**
|
|
33
32
|
*
|
|
34
33
|
* @type {string}
|
|
@@ -99,11 +99,11 @@ export interface UniversalActivity {
|
|
|
99
99
|
*/
|
|
100
100
|
'trade_date'?: string | null;
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
102
|
+
* Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT
|
|
103
103
|
* @type {string}
|
|
104
104
|
* @memberof UniversalActivity
|
|
105
105
|
*/
|
|
106
|
-
'type'?:
|
|
106
|
+
'type'?: string;
|
|
107
107
|
/**
|
|
108
108
|
* Usually but not necessarily an integer
|
|
109
109
|
* @type {number}
|
|
@@ -111,24 +111,3 @@ export interface UniversalActivity {
|
|
|
111
111
|
*/
|
|
112
112
|
'units'?: number;
|
|
113
113
|
}
|
|
114
|
-
export declare const UniversalActivityTypeEnum: {
|
|
115
|
-
readonly Dividend: "DIVIDEND";
|
|
116
|
-
readonly Buy: "BUY";
|
|
117
|
-
readonly Sell: "SELL";
|
|
118
|
-
readonly Contribution: "CONTRIBUTION";
|
|
119
|
-
readonly Withdrawal: "WITHDRAWAL";
|
|
120
|
-
readonly ExternalAssetTransferIn: "EXTERNAL_ASSET_TRANSFER_IN";
|
|
121
|
-
readonly ExternalAssetTransferOut: "EXTERNAL_ASSET_TRANSFER_OUT";
|
|
122
|
-
readonly InternalCashTransferIn: "INTERNAL_CASH_TRANSFER_IN";
|
|
123
|
-
readonly InternalCashTransferOut: "INTERNAL_CASH_TRANSFER_OUT";
|
|
124
|
-
readonly InternalAssetTransferIn: "INTERNAL_ASSET_TRANSFER_IN";
|
|
125
|
-
readonly InternalAssetTransferOut: "INTERNAL_ASSET_TRANSFER_OUT";
|
|
126
|
-
readonly Interest: "INTEREST";
|
|
127
|
-
readonly Rebate: "REBATE";
|
|
128
|
-
readonly GovGrant: "GOV_GRANT";
|
|
129
|
-
readonly Tax: "TAX";
|
|
130
|
-
readonly Fee: "FEE";
|
|
131
|
-
readonly Rei: "REI";
|
|
132
|
-
readonly Fxt: "FXT";
|
|
133
|
-
};
|
|
134
|
-
export type UniversalActivityTypeEnum = typeof UniversalActivityTypeEnum[keyof typeof UniversalActivityTypeEnum];
|
|
@@ -13,24 +13,3 @@
|
|
|
13
13
|
* Do not edit the class manually.
|
|
14
14
|
*/
|
|
15
15
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
-
exports.UniversalActivityTypeEnum = void 0;
|
|
17
|
-
exports.UniversalActivityTypeEnum = {
|
|
18
|
-
Dividend: 'DIVIDEND',
|
|
19
|
-
Buy: 'BUY',
|
|
20
|
-
Sell: 'SELL',
|
|
21
|
-
Contribution: 'CONTRIBUTION',
|
|
22
|
-
Withdrawal: 'WITHDRAWAL',
|
|
23
|
-
ExternalAssetTransferIn: 'EXTERNAL_ASSET_TRANSFER_IN',
|
|
24
|
-
ExternalAssetTransferOut: 'EXTERNAL_ASSET_TRANSFER_OUT',
|
|
25
|
-
InternalCashTransferIn: 'INTERNAL_CASH_TRANSFER_IN',
|
|
26
|
-
InternalCashTransferOut: 'INTERNAL_CASH_TRANSFER_OUT',
|
|
27
|
-
InternalAssetTransferIn: 'INTERNAL_ASSET_TRANSFER_IN',
|
|
28
|
-
InternalAssetTransferOut: 'INTERNAL_ASSET_TRANSFER_OUT',
|
|
29
|
-
Interest: 'INTEREST',
|
|
30
|
-
Rebate: 'REBATE',
|
|
31
|
-
GovGrant: 'GOV_GRANT',
|
|
32
|
-
Tax: 'TAX',
|
|
33
|
-
Fee: 'FEE',
|
|
34
|
-
Rei: 'REI',
|
|
35
|
-
Fxt: 'FXT'
|
|
36
|
-
};
|
|
@@ -48,8 +48,8 @@ Name | Type | Description | Notes
|
|
|
48
48
|
------------- | ------------- | ------------- | -------------
|
|
49
49
|
**userId** | [**string**] | | defaults to undefined
|
|
50
50
|
**userSecret** | [**string**] | | defaults to undefined
|
|
51
|
-
**startDate** | [**string**] | | (optional) defaults to undefined
|
|
52
|
-
**endDate** | [**string**] | | (optional) defaults to undefined
|
|
51
|
+
**startDate** | [**string | Date**] | | (optional) defaults to undefined
|
|
52
|
+
**endDate** | [**string | Date**] | | (optional) defaults to undefined
|
|
53
53
|
**accounts** | [**string**] | Optional comma seperated list of account IDs used to filter the request on specific accounts | (optional) defaults to undefined
|
|
54
54
|
**brokerageAuthorizations** | [**string**] | Optional comma seperated list of brokerage authorization IDs used to filter the request on only accounts that belong to those authorizations | (optional) defaults to undefined
|
|
55
55
|
|
|
@@ -111,8 +111,8 @@ console.log(getReportingCustomRangeResponse)
|
|
|
111
111
|
|
|
112
112
|
Name | Type | Description | Notes
|
|
113
113
|
------------- | ------------- | ------------- | -------------
|
|
114
|
-
**startDate** | [**string**] | | defaults to undefined
|
|
115
|
-
**endDate** | [**string**] | | defaults to undefined
|
|
114
|
+
**startDate** | [**string | Date**] | | defaults to undefined
|
|
115
|
+
**endDate** | [**string | Date**] | | defaults to undefined
|
|
116
116
|
**userId** | [**string**] | | defaults to undefined
|
|
117
117
|
**userSecret** | [**string**] | | defaults to undefined
|
|
118
118
|
**accounts** | [**string**] | Optional comma seperated list of account IDs used to filter the request on specific accounts | (optional) defaults to undefined
|
package/index.test.ts
CHANGED
|
@@ -88,6 +88,66 @@ it("getUserAccountBalance", async () => {
|
|
|
88
88
|
console.log(response.data);
|
|
89
89
|
});
|
|
90
90
|
|
|
91
|
+
it("getActivities", async () => {
|
|
92
|
+
const snaptrade = new Snaptrade({
|
|
93
|
+
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
|
|
94
|
+
clientId: process.env.SNAPTRADE_CLIENT_ID,
|
|
95
|
+
});
|
|
96
|
+
const userId = process.env.SNAPTRADE_TEST_USER_ID;
|
|
97
|
+
const userSecret = process.env.SNAPTRADE_TEST_USER_SECRET;
|
|
98
|
+
let activities = await snaptrade.transactionsAndReporting.getActivities({
|
|
99
|
+
userId,
|
|
100
|
+
userSecret,
|
|
101
|
+
});
|
|
102
|
+
console.log(activities.data);
|
|
103
|
+
expect(activities).not.toBeNull();
|
|
104
|
+
// create two variables "startDate" and "endDate" that are strings representing 1 year ago and today in yyyy-mm-dd format using today's date
|
|
105
|
+
const startDate = "2020-01-01";
|
|
106
|
+
const endDate = "2020-12-31";
|
|
107
|
+
activities = await snaptrade.transactionsAndReporting.getActivities({
|
|
108
|
+
userId,
|
|
109
|
+
userSecret,
|
|
110
|
+
startDate,
|
|
111
|
+
endDate,
|
|
112
|
+
});
|
|
113
|
+
console.log(activities.data);
|
|
114
|
+
expect(activities).not.toBeNull();
|
|
115
|
+
// create two variables "startDate" and "endDate" that are Date instances representing 1 year ago and today
|
|
116
|
+
const endDate2 = new Date();
|
|
117
|
+
// create variable startDate2 which is 1 year before endDate2
|
|
118
|
+
const startDate2 = new Date(endDate2);
|
|
119
|
+
startDate2.setFullYear(startDate2.getFullYear() - 1);
|
|
120
|
+
activities = await snaptrade.transactionsAndReporting.getActivities({
|
|
121
|
+
userId,
|
|
122
|
+
userSecret,
|
|
123
|
+
startDate: startDate2,
|
|
124
|
+
endDate: endDate2,
|
|
125
|
+
});
|
|
126
|
+
console.log(activities.data);
|
|
127
|
+
expect(activities).not.toBeNull();
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("getUserHoldings", async () => {
|
|
131
|
+
const snaptrade = new Snaptrade({
|
|
132
|
+
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
|
|
133
|
+
clientId: process.env.SNAPTRADE_CLIENT_ID,
|
|
134
|
+
});
|
|
135
|
+
const userId = process.env.SNAPTRADE_TEST_USER_ID;
|
|
136
|
+
const userSecret = process.env.SNAPTRADE_TEST_USER_SECRET;
|
|
137
|
+
const accounts = await snaptrade.accountInformation.listUserAccounts({
|
|
138
|
+
userId,
|
|
139
|
+
userSecret,
|
|
140
|
+
});
|
|
141
|
+
const holdings = await snaptrade.accountInformation.getUserHoldings({
|
|
142
|
+
userId,
|
|
143
|
+
userSecret,
|
|
144
|
+
accountId: accounts.data[0].id,
|
|
145
|
+
});
|
|
146
|
+
// assert holdings is not null with jest
|
|
147
|
+
expect(holdings).not.toBeNull();
|
|
148
|
+
console.log(holdings.data);
|
|
149
|
+
});
|
|
150
|
+
|
|
91
151
|
it.skip("getOptionsChain", async () => {
|
|
92
152
|
const snaptrade = new Snaptrade({
|
|
93
153
|
consumerKey: process.env.SNAPTRADE_CONSUMER_KEY,
|
package/models/brokerage.ts
CHANGED
|
@@ -89,13 +89,13 @@ export interface Brokerage {
|
|
|
89
89
|
* @type {boolean}
|
|
90
90
|
* @memberof Brokerage
|
|
91
91
|
*/
|
|
92
|
-
'allows_trading'?: boolean;
|
|
92
|
+
'allows_trading'?: boolean | null;
|
|
93
93
|
/**
|
|
94
94
|
*
|
|
95
95
|
* @type {boolean}
|
|
96
96
|
* @memberof Brokerage
|
|
97
97
|
*/
|
|
98
|
-
'has_reporting'?: boolean;
|
|
98
|
+
'has_reporting'?: boolean | null;
|
|
99
99
|
/**
|
|
100
100
|
*
|
|
101
101
|
* @type {boolean}
|
|
@@ -12,9 +12,6 @@
|
|
|
12
12
|
* Do not edit the class manually.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
-
// May contain unused imports in some cases
|
|
16
|
-
// @ts-ignore
|
|
17
|
-
import { BrokerageAuthorization } from './brokerage-authorization';
|
|
18
15
|
|
|
19
16
|
/**
|
|
20
17
|
* SnapTradeUser Investment Account
|
|
@@ -32,10 +29,10 @@ export interface SnapTradeHoldingsAccount {
|
|
|
32
29
|
'id'?: string;
|
|
33
30
|
/**
|
|
34
31
|
*
|
|
35
|
-
* @type {
|
|
32
|
+
* @type {string}
|
|
36
33
|
* @memberof SnapTradeHoldingsAccount
|
|
37
34
|
*/
|
|
38
|
-
'brokerage_authorization'?:
|
|
35
|
+
'brokerage_authorization'?: string;
|
|
39
36
|
/**
|
|
40
37
|
*
|
|
41
38
|
* @type {string}
|
|
@@ -112,11 +112,11 @@ export interface UniversalActivity {
|
|
|
112
112
|
*/
|
|
113
113
|
'trade_date'?: string | null;
|
|
114
114
|
/**
|
|
115
|
-
*
|
|
115
|
+
* Potential values include - DIVIDEND - BUY - SELL - CONTRIBUTION - WITHDRAWAL - EXTERNAL_ASSET_TRANSFER_IN - EXTERNAL_ASSET_TRANSFER_OUT - INTERNAL_CASH_TRANSFER_IN - INTERNAL_CASH_TRANSFER_OUT - INTERNAL_ASSET_TRANSFER_IN - INTERNAL_ASSET_TRANSFER_OUT - INTEREST - REBATE - GOV_GRANT - TAX - FEE - REI - FXT
|
|
116
116
|
* @type {string}
|
|
117
117
|
* @memberof UniversalActivity
|
|
118
118
|
*/
|
|
119
|
-
'type'?:
|
|
119
|
+
'type'?: string;
|
|
120
120
|
/**
|
|
121
121
|
* Usually but not necessarily an integer
|
|
122
122
|
* @type {number}
|
|
@@ -125,27 +125,3 @@ export interface UniversalActivity {
|
|
|
125
125
|
'units'?: number;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
export const UniversalActivityTypeEnum = {
|
|
129
|
-
Dividend: 'DIVIDEND',
|
|
130
|
-
Buy: 'BUY',
|
|
131
|
-
Sell: 'SELL',
|
|
132
|
-
Contribution: 'CONTRIBUTION',
|
|
133
|
-
Withdrawal: 'WITHDRAWAL',
|
|
134
|
-
ExternalAssetTransferIn: 'EXTERNAL_ASSET_TRANSFER_IN',
|
|
135
|
-
ExternalAssetTransferOut: 'EXTERNAL_ASSET_TRANSFER_OUT',
|
|
136
|
-
InternalCashTransferIn: 'INTERNAL_CASH_TRANSFER_IN',
|
|
137
|
-
InternalCashTransferOut: 'INTERNAL_CASH_TRANSFER_OUT',
|
|
138
|
-
InternalAssetTransferIn: 'INTERNAL_ASSET_TRANSFER_IN',
|
|
139
|
-
InternalAssetTransferOut: 'INTERNAL_ASSET_TRANSFER_OUT',
|
|
140
|
-
Interest: 'INTEREST',
|
|
141
|
-
Rebate: 'REBATE',
|
|
142
|
-
GovGrant: 'GOV_GRANT',
|
|
143
|
-
Tax: 'TAX',
|
|
144
|
-
Fee: 'FEE',
|
|
145
|
-
Rei: 'REI',
|
|
146
|
-
Fxt: 'FXT'
|
|
147
|
-
} as const;
|
|
148
|
-
|
|
149
|
-
export type UniversalActivityTypeEnum = typeof UniversalActivityTypeEnum[keyof typeof UniversalActivityTypeEnum];
|
|
150
|
-
|
|
151
|
-
|
package/package.json
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "snaptrade-typescript-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "8.0.0",
|
|
4
4
|
"description": "Client for SnapTrade",
|
|
5
5
|
"author": "Konfig",
|
|
6
|
+
"engines": {
|
|
7
|
+
"node": ">=10"
|
|
8
|
+
},
|
|
6
9
|
"repository": {
|
|
7
10
|
"type": "git",
|
|
8
11
|
"url": "https://github.com/passiv/snaptrade-sdks/tree/master/sdks/typescript"
|