@barchart/portfolio-client-js 5.1.2 → 5.3.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.
@@ -0,0 +1 @@
1
+ {"portfolio/_coverpage.md":"\"f957831627399d4be57ceda0fed32e20\"","portfolio/_sidebar.md":"\"a854b0dcd2d5c0eb4de979a93a232b45\"","portfolio/index.html":"\"9966477f3d373643c1cdff2dfde919d4\"","portfolio/content/_sidebar.md":"\"a854b0dcd2d5c0eb4de979a93a232b45\"","portfolio/content/api_reference.md":"\"d554e76f82877a86c6edfadb6c8ee9fc\"","portfolio/content/product_overview.md":"\"fde131b3a4a7c574a8f41ecfd7f202eb\"","portfolio/content/quick_start.md":"\"2e0d8de7247ebc847ad8a56619ef51d3\"","portfolio/content/release_notes.md":"\"1bd7efe30b675a8e3945070c7e9baf49\"","portfolio/content/sdk_reference.md":"\"a9c9669ce7a6478281ada65009738555\"","portfolio/styles/override.css":"\"9445e9c6a2bb7c2e435a09f22142a073\"","portfolio/static/openapi.yaml":"\"835322160925f1cf7e1e8534dec6fd12\"","portfolio/content/api/_sidebar.md":"\"60cdc1db76e58b2631a95a81411c6963\"","portfolio/content/api/components.md":"\"433f10a6c68ffce3920ece1db1de6b4a\"","portfolio/content/api/paths.md":"\"e11c608cde2a5ad94abe70d01bb43b95\"","portfolio/content/concepts/_sidebar.md":"\"a854b0dcd2d5c0eb4de979a93a232b45\"","portfolio/content/concepts/connecting_to_barchart.md":"\"ebbe0644caea27269ca2d553e9507bbc\"","portfolio/content/concepts/interaction_basics.md":"\"9fd648c53f183143f352e5d117739cdc\"","portfolio/content/concepts/understanding_corporate_actions.md":"\"d41d8cd98f00b204e9800998ecf8427e\"","portfolio/content/concepts/working_with_portfolios.md":"\"520310bbc64c34c82cb3fd9c28321eff\"","portfolio/content/concepts/working_with_positions.md":"\"fa78dc740b9c46b0c2c06e8d810f1a60\"","portfolio/content/concepts/working_with_summaries.md":"\"d41d8cd98f00b204e9800998ecf8427e\"","portfolio/content/concepts/working_with_transactions.md":"\"49f7be257a872ff55c08075ce8c376d0\"","portfolio/content/concepts/working_with_valuations.md":"\"63cd4b5926aae46d91e958d2532a4abd\"","portfolio/content/appendices/data_model_enumerations.md":"\"5180ae3da33e24780eaad020a5443f30\"","portfolio/content/appendices/data_model_structures.md":"\"0fa41f49c618a12c3adb83e496b77763\"","portfolio/content/appendices/demo_applications.md":"\"c26aef709b5c75f0f805f4904e9572a5\"","portfolio/content/appendices/other_services.md":"\"a078a70e4228b093c04329577dd1ad8e\"","portfolio/content/appendices/sample_code.md":"\"e41296a9fbaaab0f7e1355e10dc55493\"","portfolio/content/images/portfolio_ui_web.png":"\"d04afe475e03c1f2121f2a70130e7c42\"","portfolio/content/releases/3.0.0.md":"\"1484919526d7d08694b2ed5afbd84365\"","portfolio/content/releases/3.1.0.md":"\"f28a0be6fbeb32f59ca9ec6c2f9011b4\"","portfolio/content/releases/3.2.0.md":"\"b3b0c996fb4fc094459629a104c24ffb\"","portfolio/content/releases/3.3.0.md":"\"3bbcfedbeb75d5a3206000f85d095a88\"","portfolio/content/releases/3.4.0.md":"\"3a2ad68ebcf001714a163c0b7da74305\"","portfolio/content/releases/3.4.1.md":"\"2dcbc977a354c88cf359ff17b59a4008\"","portfolio/content/releases/4.0.0.md":"\"3e6acdcc34335a3b900a5a1df8b671f1\"","portfolio/content/releases/4.1.0.md":"\"e6f85264ab0ff56d17074c7c0e4d90c5\"","portfolio/content/releases/5.0.1.md":"\"14e442b964a30dab5f1e14edaf9674e9\"","portfolio/content/releases/5.1.0.md":"\"a5a7b4b37328cb60f1cade7ecd779a28\"","portfolio/content/releases/5.1.1.md":"\"4edc2e50d9d8bdd6b5d543f15c1365ea\"","portfolio/content/releases/5.1.2.md":"\"04fc554763d1d664610094d6e2145411\"","portfolio/content/releases/5.2.0.md":"\"08356e1c1d6c068c3aae73876ad941aa\"","portfolio/content/sdk/_sidebar.md":"\"d813bcd5bbfc603368856ca6f71dbee6\"","portfolio/content/sdk/lib-common.md":"\"bd35e956a85e420e62895442fd873d2a\"","portfolio/content/sdk/lib-data.md":"\"1b6feb7043f5f630d2ba744100814a14\"","portfolio/content/sdk/lib-gateway.md":"\"44d4c09ef9020129dfe472061d26359b\"","portfolio/content/sdk/lib-security.md":"\"d8f8c087202e9c2e34e509d5c352c51a\"","portfolio/content/releases/5.3.0.md":"\"7edf2fbbacef8befdeaf589d4fb190ce\""}
package/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ Copyright 2022, Barchart.com, Inc., http://www.barchart.com/
2
+
3
+ This software consists of voluntary contributions made by many
4
+ individuals. For exact contribution history, see the revision history
5
+ available at https://github.com/barchart/barchart-common-js
6
+
7
+ The following license applies to all parts of this software.
8
+
9
+ ====
10
+
11
+ Permission is hereby granted, free of charge, to any person obtaining
12
+ a copy of this software and associated documentation files (the
13
+ "Software"), to deal in the Software without restriction, including
14
+ without limitation the rights to use, copy, modify, merge, publish,
15
+ distribute, sublicense, and/or sell copies of the Software, and to
16
+ permit persons to whom the Software is furnished to do so, subject to
17
+ the following conditions:
18
+
19
+ The above copyright notice and this permission notice shall be
20
+ included in all copies or substantial portions of the Software.
21
+
22
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -2,20 +2,21 @@
2
2
 
3
3
  [![AWS CodeBuild](https://codebuild.us-east-1.amazonaws.com/badges?uuid=eyJlbmNyeXB0ZWREYXRhIjoiM0hCbTN3M253WGFUUUpFcnk1RFZOSTdUcUZnOWJxbXltaEMvQ3JrcENZeWI0cFRDWlFidks2VFhNR3lHeHlBUVdOSjk5TDU5MWd1bE1abGtoc3p1NjFrPSIsIml2UGFyYW1ldGVyU3BlYyI6InZMalFMNG9pZ3E1ekxJSEciLCJtYXRlcmlhbFNldFNlcmlhbCI6MX0%3D&branch=master)](https://github.com/barchart/portfolio-client-js)
4
4
 
5
- A JavaScript SDK for Barchart's Portfolio System.
5
+ ### Overview
6
6
 
7
- ### Development
7
+ This **JavaScript SDK** connects your applications to the [**Barchart Portfolio Service**](https://www.barchart.com/solutions/services/digital/portfolio) — a service for building, managing, and tracking performance for investment portfolios.
8
8
 
9
- #### Documentation
9
+ ### Documentation
10
10
 
11
- The code is documented with [JSDoc](http://usejsdoc.org/). This will be used as the basis for formal documentation (coming soon).
11
+ Complete documentation for this SDK can be accessed here:
12
+
13
+ * [https://docs.barchart.com/portfolio/](https://docs.barchart.com/portfolio/)
12
14
 
13
15
  #### Package Managers
14
16
 
15
- This library has been published as a *private* module to NPM as [@barchart/portfolio-client-js](https://www.npmjs.com/package/@barchart/portfolio-client-js).
17
+ This library has been published as a _public_ package to NPM as [@barchart/portfolio-client-js](https://www.npmjs.com/package/@barchart/portfolio-client-js).
16
18
 
17
19
  ```shell
18
- npm login
19
20
  npm install @barchart/portfolio-client-js -S
20
21
  ```
21
22
 
@@ -5,6 +5,7 @@ module.exports = (() => {
5
5
  * Static configuration data.
6
6
  *
7
7
  * @public
8
+ * @ignore
8
9
  */
9
10
  class Configuration {
10
11
  constructor() {
@@ -0,0 +1,285 @@
1
+ const Currency = require('@barchart/common-js/lang/Currency'),
2
+ Decimal = require('@barchart/common-js/lang/Decimal'),
3
+ Timezones = require('@barchart/common-js/lang/Timezones');
4
+
5
+ const InstrumentType = require('@barchart/portfolio-api-common/lib/data/InstrumentType'),
6
+ PositionDirection = require('@barchart/portfolio-api-common/lib/data/PositionDirection'),
7
+ TransactionType = require('@barchart/portfolio-api-common/lib/data/TransactionType');
8
+
9
+ /**
10
+ * A meta namespace containing structural contracts of anonymous objects.
11
+ *
12
+ * @namespace Schema
13
+ */
14
+
15
+ /**
16
+ * A portfolio.
17
+ *
18
+ * @typedef Portfolio
19
+ * @type Object
20
+ * @memberOf Schema
21
+ * @property {String} portfolio - The portfolio identifier (assigned by the backend).
22
+ * @property {String} user - The identifier for the portfolio's owner (assigned by the backend, based on the authorized user).
23
+ * @property {String} name - The name of the portfolio.
24
+ * @property {Timezones} timezone - The timezone of the portfolio.
25
+ * @property {Schema.PortfolioDefaults} defaults - Default settings for the portfolio.
26
+ */
27
+
28
+ /**
29
+ * An object used to create a new portfolio.
30
+ *
31
+ * @typedef PortfolioCreate
32
+ * @type Object
33
+ * @memberOf Schema
34
+ * @property {String} name - The name of the portfolio.
35
+ * @property {Timezones} timezone - The timezone of the portfolio.
36
+ * @property {Schema.PortfolioDefaults} defaults - Default settings for the portfolio.
37
+ */
38
+
39
+ /**
40
+ * An object used to update an existing portfolio.
41
+ *
42
+ * @typedef PortfolioUpdate
43
+ * @type Object
44
+ * @memberOf Schema
45
+ * @property {String} portfolio - The identifier of the portfolio to update.
46
+ * @property {String=} name - The updated name of the portfolio, if present.
47
+ * @property {Timezones=} timezone - The updated timezone for the portfolio, if present.
48
+ * @property {Schema.PortfolioDefaults=} defaults - The updated default settings for the portfolio, if present.
49
+ */
50
+
51
+ /**
52
+ * An object containing defining default behavior for positions added to the portfolio.
53
+ *
54
+ * @typedef PortfolioDefaults
55
+ * @type Object
56
+ * @memberOf Schema
57
+ * @property {Boolean=} cash - Indicates if corresponding cash transactions should be created, when appropriate (e.g. also DEBIT cash when creating a BUY transaction for stock).
58
+ * @property {Currency=} currency - The default currency for the portfolio, used to determine the basis for reporting.
59
+ * @property {Boolean=} reinvest - Indicates if dividends should be automatically reinvested.
60
+ */
61
+
62
+ /**
63
+ * A position.
64
+ *
65
+ * @typedef Position
66
+ * @type Object
67
+ * @memberOf Schema
68
+ * @property {String} user - The identifier for the position's owner.
69
+ * @property {String} portfolio - The identifier of the portfolio which contains the position.
70
+ * @property {Schema.PositionInstrument} instrument - The position's instrument.
71
+ * @property {String} position - The unique identifier for the position.
72
+ * @property {Number} transaction - The sequence number of the most recent transaction for the position.
73
+ * @property {Boolean=} cash - Indicates if corresponding cash transactions should be created, when appropriate (e.g. also DEBIT cash when creating a BUY transaction for stock).
74
+ * @property {Boolean} reinvest - Indicates if dividends should be automatically reinvested.
75
+ * @property {Schema.PositionSnapshot} snapshot - Summary and performance information for the position, as of the last transaction.
76
+ */
77
+
78
+ /**
79
+ * An object used to update a position's settings (e.g. dividend re-investment settings). Other changes
80
+ * to a position (e.g. the size of the position) are affected by executing transactions.
81
+ *
82
+ * @typedef PositionUpdate
83
+ * @type Object
84
+ * @memberOf Schema
85
+ * @property {String} portfolio - The identifier of the portfolio containing the position to update.
86
+ * @property {String} position - The identifier of the position to update.
87
+ * @property {Boolean=} cash - If present, changes the setting for automatic creation of the cash transactions (based on investment transactions).
88
+ * @property {Boolean=} reinvest - If present, changes whether future dividends are re-invested.
89
+ */
90
+
91
+ /**
92
+ * A position's instrument.
93
+ *
94
+ * @typedef PositionInstrument
95
+ * @type Object
96
+ * @memberOf Schema
97
+ * @property {String} id - The instrument's unique identifier.
98
+ * @property {String} name - The instrument's name (e.g. Apple Inc).
99
+ * @property {InstrumentType} type - The instrument's type (e.g. EQUITY).
100
+ * @property {Currency} currency - The currency used to trade (or value) the instrument (e.g. USD).
101
+ * @property {Schema.Symbols} symbol - The symbol(s) used for the instrument.
102
+ */
103
+
104
+ /**
105
+ * A summary of the status of a position on a given date.
106
+ *
107
+ * @typedef PositionSnapshot
108
+ * @type Object
109
+ * @memberOf Schema
110
+ * @property {Day} date - The date of the snapshot.
111
+ * @property {Decimal} open - The number of shares (units) open (value may be negative).
112
+ * @property {PositionDirection} direction - Qualifies the number of open shares as LONG (i.e. positive), short (i.e. negative), or EVEN (i.e. zero).
113
+ * @property {Decimal} buys - The sum of all purchases in the currency of the underlying instrument (value is never negative).
114
+ * @property {Decimal} sells - The sum of all sales in the currency of the underlying instrument (value is never negative).
115
+ * @property {Decimal} gain - The _realized_ gain on the position (value may be negative).
116
+ * @property {Decimal} basis - The amount invested in the remaining position (value may be negative).
117
+ * @property {Decimal} income - The sum of all income (e.g. dividends) earned on the position (value may be negative).
118
+ * @property {Decimal} value - The current value of the position (value may be negative). Valuation is based on the last transaction price (not the current market price).
119
+ */
120
+
121
+ /**
122
+ * @typedef PositionSummary
123
+ * @type Object
124
+ * @memberOf Schema
125
+ */
126
+
127
+ /**
128
+ * A transaction.
129
+ *
130
+ * @typedef Transaction
131
+ * @type Object
132
+ * @memberOf Schema
133
+ * @property {String} portfolio - The identifier of the portfolio which contains the transaction (a UUID).
134
+ * @property {String} position - The identifier of the position which contains the transaction (a UUID).
135
+ * @property {String} transaction - The identifier of the transaction (a UUID).
136
+ * @property {String} sequence - The sequence number of the transaction (with respect to other transactions for the same position, starts with one).
137
+ * @property {TransactionType} type - The type of transaction (e.g. BUY, SELL, SELL_SHORT, etc).
138
+ * @property {Day} date - The day the transaction occurs. Time of day is not specified. Refer to the "sequence" property for ordering within the same day.
139
+ * @property {String=} description - Autogenerated text describing the transaction (used for cash positions).
140
+ * @property {Decimal} amount - The amount of currency affected by the transaction. In cases where currency was paid, the value is negative. In cases where currency was received, the value is positive.
141
+ * @property {Decimal} quantity - The number of shares (or units) of the position's instrument affected by the transaction. The value will be positive when purchasing and negative when selling.
142
+ * @property {Decimal=} fee - The number of shares or units of the position's instrument affected by the transaction. The value will be positive when purchasing and negative when selling.
143
+ * @property {Schema.TransactionReference=} reference - A reference to another transaction — a transaction which caused this transaction to occur.
144
+ * @property {Schema.PositionSnapshot} snapshot - A summary of the position size and performance, immediately after this transaction was executed.
145
+ * @property {Schema.TransactionExtensionForTrade=} trade - Additional information, only present if transaction is a trade (type is B, S, SS, etc).
146
+ * @property {Schema.TransactionExtensionForDividend=} dividend - Additional information, only present if transaction is a dividend (type is DV, DX, DF, DY, etc).
147
+ * @property {Schema.TransactionExtensionForSplit=} split - Additional information, only present if transaction is a split (type is SP).
148
+ */
149
+
150
+ /**
151
+ * A reference to a related, automatically-generated transaction. For example, assume we execute
152
+ * a transaction to BUY stock. If the stock position is configured to automatically create cash
153
+ * transactions, then a DEBIT transaction to a cash position is also executed (to pay for the stock
154
+ * purchase). In this case, the DEBIT transaction will reference the BUY transaction.
155
+ *
156
+ * @typedef TransactionReference
157
+ * @type Object
158
+ * @memberOf Schema
159
+ * @property {String} position - The identifier of the referenced position.
160
+ * @property {String} transaction - The identifier of the referenced transaction.
161
+ */
162
+
163
+ /**
164
+ * Information, extending a {@link Schema.Transaction}, where the transaction's type is a trade.
165
+ *
166
+ * @typedef TransactionExtensionForTrade
167
+ * @type Object
168
+ * @memberOf Schema
169
+ * @property {Decimal} price - The unit price the transaction was executed at.
170
+ */
171
+
172
+ /**
173
+ * Information, extending a {@link Schema.Transaction}, where the transaction's type is a
174
+ * dividend (or a distribution).
175
+ *
176
+ * @typedef TransactionExtensionForDividend
177
+ * @type Object
178
+ * @memberOf Schema
179
+ * @property {Decimal} rate - The amount paid per unit.
180
+ * @property {Day} effective - The day used to determine the quantity eligible to receive the dividend (i.e. the dividend ex-date).
181
+ * @property {Decimal=} price - The market value of the underlying at the time the dividend was paid (used to calculate reinvestment quantities).
182
+ * @property {Decimal} amount - The currency amount of the dividend (e.g the rate multiplied by the quantity eligible to receive the dividend).
183
+ */
184
+
185
+ /**
186
+ * Information, extending a {@link Schema.Transaction}, where the transaction's type is a split.
187
+ *
188
+ * @typedef TransactionExtensionForSplit
189
+ * @type Object
190
+ * @memberOf Schema
191
+ * @property {Decimal} numerator - The numerator in the following fraction: [ shares owned after dividend ] / [ shares owned before dividend ].
192
+ * @property {Decimal} numerator - The denominator in the following fraction: [ shares owned after dividend ] / [ shares owned before dividend ].
193
+ * @property {Day} effective - The day used to determine the quantity eligible to be split (i.e. the split ex-date).
194
+ */
195
+
196
+ /**
197
+ * Data required to create a new transaction. Essentially a subset of the _Transaction_ schema (although,
198
+ * instrument metadata is added for transactions which open new positions).
199
+ *
200
+ * @typedef TransactionCreate
201
+ * @type Object
202
+ * @memberOf Schema
203
+ * @property {String} portfolio - The identifier of the portfolio which will contain the transaction (a UUID).
204
+ * @property {String} position - The identifier of the position to add the transaction to (use "new" for new positions).
205
+ * @property {TransactionType} type - The type of transaction (e.g. BUY, SELL, SELL_SHORT, etc).
206
+ * @property {Schema.TransactionCreateInstrument} instrument - Information about the instrument (required when opening a new position, ignored otherwise).
207
+ * @property {Day} date - The day the transaction occurs.
208
+ * @property {Decimal=} price - The unit price of the instrument at the time the transaction executes.
209
+ * @property {Decimal} quantity - The number of units affected by the transaction (can be an integer or decimal value).
210
+ * @property {Decimal=} fee - A fee paid to execute the transaction (can be zero).
211
+ */
212
+
213
+ /**
214
+ * Data required to identify the instrument for a new transaction.
215
+ *
216
+ * @typedef TransactionCreateInstrument
217
+ * @type Object
218
+ * @memberOf Schema
219
+ * @property {Schema.Symbols} symbol - The symbol(s) used to identify an instrument.
220
+ * @property {String=} name - The name of the instrument.
221
+ * @property {String=} type - The code of the asset class. See the InstrumentAssetClass enumeration in the @barchart/portfolio-api-common library.
222
+ * @property {Number=} code - The numeric code of the asset class. See the InstrumentAssetClass enumeration in the @barchart/portfolio-api-common library.
223
+ * @property {String=} exchange - The code of the listing exchange.
224
+ * @property {Currency=} currency - The currency the instrument is transacted in.
225
+ */
226
+
227
+ /**
228
+ * The result of transaction create, update, or delete operation. This object lists the positions
229
+ * that were changed (as a result of the operation) and includes updated {@link Schema.PositionSummary}
230
+ * objects.
231
+ *
232
+ * @typedef TransactionMutateResult
233
+ * @type Object
234
+ * @memberOf Schema
235
+ * @property {Object} positions
236
+ * @property {Schema.Position[]} positions.saved - All positions which were created or updated.
237
+ * @property {Schema.Position[]} positions.deleted - All positions which were deleted.
238
+ * @property {Schema.PositionSummary[]} summaries - All position summaries created or updated.
239
+ * @property {Boolean} replaced - If true, the position (and position summaries) need to be replaced.
240
+ */
241
+
242
+ /**
243
+ * The symbols (i.e. codes) used to identify an instrument (e.g. "AAPL" for Apple Inc).
244
+ *
245
+ * @typedef Symbols
246
+ * @type Object
247
+ * @memberOf Schema
248
+ * @property {String} barchart - The symbol used by Barchart (required to lookup quotes and determine prices).
249
+ * @property {String} display - The symbol used for display purposes (often the same as the Barchart symbol).
250
+ */
251
+
252
+ /**
253
+ * An ordered list of end-of-day valuations (for an individual position or an entire portfolio),
254
+ * along with metadata regarding the valuations (e.g. portfolio, position, currency).
255
+ *
256
+ * @typedef ValuationContainer
257
+ * @type Object
258
+ * @memberOf Schema
259
+ * @property {String} user - The identifier for the portfolio's owner.
260
+ * @property {String} portfolio - The identifier for the portfolio.
261
+ * @property {String} position - The identifier for the position being valued. If this value is an asterisk (```*```), then valuation refers to the entire portfolio.
262
+ * @property {Currency=} currency - The currency of the valuations (absent when no valuations are returned).
263
+ * @property {Array<Schema.Valuation>} valuations - The end-of-day valuations.
264
+ */
265
+
266
+ /**
267
+ * The valuation of a position (or portfolio) on a given day.
268
+ *
269
+ * @typedef Valuation
270
+ * @type Object
271
+ * @memberOf Schema
272
+ * @property {Day} date - The date of the valuation.
273
+ * @property {Number} market - The market value of the position (or portfolio).
274
+ */
275
+
276
+ /**
277
+ * The result of valuations availability.
278
+ *
279
+ * @ignore
280
+ * @typedef ValuationsAvailabilityResult
281
+ * @type {Object}
282
+ * @memberOf Schema
283
+ * @property {Boolean} available - If true, all position and portfolio valuations are up-to-date.
284
+ * @property {String[]} positions - Array of position identifiers for which are currently being calculated. An empty result indicates all position valuations are up-to-date.
285
+ */
@@ -32,6 +32,7 @@ const Configuration = require('./../common/Configuration'),
32
32
  module.exports = (() => {
33
33
  'use strict';
34
34
 
35
+ const REST_API_VERSION = 'v1';
35
36
  const REST_API_SECURE_PROTOCOL = 'https';
36
37
  const REST_API_SECURE_PORT = 443;
37
38
 
@@ -40,7 +41,7 @@ module.exports = (() => {
40
41
  * Portfolio Service. It can be used to query, edit, and delete portfolios.
41
42
  *
42
43
  * @public
43
- * @param {String} protocol - The protocol of the of the Portfolio web service (either http or https).
44
+ * @param {String} protocol - The protocol of the Portfolio web service (either http or https).
44
45
  * @param {String} host - The hostname of the Portfolio web service.
45
46
  * @param {Number} port - The TCP port number of the Portfolio web service.
46
47
  * @param {String} environment - A description of the environment we're connecting to.
@@ -89,7 +90,7 @@ module.exports = (() => {
89
90
  .withHost(host)
90
91
  .withPort(port)
91
92
  .withPathBuilder((pb) => {
92
- pb.withLiteralParameter('version', 'v1')
93
+ pb.withLiteralParameter('version', REST_API_VERSION)
93
94
  .withLiteralParameter('portfolios', 'portfolios')
94
95
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
95
96
  })
@@ -105,7 +106,7 @@ module.exports = (() => {
105
106
  .withHost(host)
106
107
  .withPort(port)
107
108
  .withPathBuilder((pb) => {
108
- pb.withLiteralParameter('version', 'v1')
109
+ pb.withLiteralParameter('version', REST_API_VERSION)
109
110
  .withLiteralParameter('portfolios', 'portfolios');
110
111
  })
111
112
  .withBody('portfolio')
@@ -122,7 +123,7 @@ module.exports = (() => {
122
123
  .withHost(host)
123
124
  .withPort(port)
124
125
  .withPathBuilder((pb) => {
125
- pb.withLiteralParameter('version', 'v1')
126
+ pb.withLiteralParameter('version', REST_API_VERSION)
126
127
  .withLiteralParameter('portfolios', 'portfolios')
127
128
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
128
129
  })
@@ -140,7 +141,7 @@ module.exports = (() => {
140
141
  .withHost(host)
141
142
  .withPort(port)
142
143
  .withPathBuilder((pb) => {
143
- pb.withLiteralParameter('version', 'v1')
144
+ pb.withLiteralParameter('version', REST_API_VERSION)
144
145
  .withLiteralParameter('portfolios', 'portfolios')
145
146
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false);
146
147
  })
@@ -154,7 +155,7 @@ module.exports = (() => {
154
155
  .withHost(host)
155
156
  .withPort(port)
156
157
  .withPathBuilder((pb) => {
157
- pb.withLiteralParameter('version', 'v1')
158
+ pb.withLiteralParameter('version', REST_API_VERSION)
158
159
  .withLiteralParameter('portfolios', 'portfolios')
159
160
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
160
161
  .withLiteralParameter('positions', 'positions')
@@ -177,7 +178,7 @@ module.exports = (() => {
177
178
  .withHost(host)
178
179
  .withPort(port)
179
180
  .withPathBuilder((pb) => {
180
- pb.withLiteralParameter('version', 'v1')
181
+ pb.withLiteralParameter('version', REST_API_VERSION)
181
182
  .withLiteralParameter('portfolios', 'portfolios')
182
183
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
183
184
  .withLiteralParameter('positions', 'positions')
@@ -196,7 +197,7 @@ module.exports = (() => {
196
197
  .withHost(host)
197
198
  .withPort(port)
198
199
  .withPathBuilder((pb) => {
199
- pb.withLiteralParameter('version', 'v1')
200
+ pb.withLiteralParameter('version', REST_API_VERSION)
200
201
  .withLiteralParameter('portfolios', 'portfolios')
201
202
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
202
203
  .withLiteralParameter('positions', 'positions')
@@ -214,7 +215,7 @@ module.exports = (() => {
214
215
  .withHost(host)
215
216
  .withPort(port)
216
217
  .withPathBuilder((pb) => {
217
- pb.withLiteralParameter('version', 'v1')
218
+ pb.withLiteralParameter('version', REST_API_VERSION)
218
219
  .withLiteralParameter('portfolios', 'portfolios')
219
220
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
220
221
  .withLiteralParameter('summaries', 'summaries')
@@ -237,7 +238,7 @@ module.exports = (() => {
237
238
  .withHost(host)
238
239
  .withPort(port)
239
240
  .withPathBuilder((pb) => {
240
- pb.withLiteralParameter('version', 'v1')
241
+ pb.withLiteralParameter('version', REST_API_VERSION)
241
242
  .withLiteralParameter('portfolios', 'portfolios')
242
243
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
243
244
  .withLiteralParameter('values', 'values')
@@ -255,7 +256,7 @@ module.exports = (() => {
255
256
  .withHost(host)
256
257
  .withPort(port)
257
258
  .withPathBuilder((pb) => {
258
- pb.withLiteralParameter('version', 'v1')
259
+ pb.withLiteralParameter('version', REST_API_VERSION)
259
260
  .withLiteralParameter('portfolios', 'portfolios')
260
261
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
261
262
  .withLiteralParameter('positions', 'positions')
@@ -274,7 +275,7 @@ module.exports = (() => {
274
275
  .withHost(host)
275
276
  .withPort(port)
276
277
  .withPathBuilder((pb) => {
277
- pb.withLiteralParameter('version', 'v1')
278
+ pb.withLiteralParameter('version', REST_API_VERSION)
278
279
  .withLiteralParameter('values', 'values');
279
280
  })
280
281
  .withQueryBuilder((qb) => {
@@ -291,7 +292,7 @@ module.exports = (() => {
291
292
  .withHost(host)
292
293
  .withPort(port)
293
294
  .withPathBuilder((pb) => {
294
- pb.withLiteralParameter('version', 'v1')
295
+ pb.withLiteralParameter('version', REST_API_VERSION)
295
296
  .withLiteralParameter('portfolios', 'portfolios')
296
297
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
297
298
  .withLiteralParameter('positions', 'positions')
@@ -311,17 +312,20 @@ module.exports = (() => {
311
312
  .withHost(host)
312
313
  .withPort(port)
313
314
  .withPathBuilder((pb) => {
314
- pb.withLiteralParameter('version', 'v1')
315
+ pb.withLiteralParameter('version', REST_API_VERSION)
315
316
  .withLiteralParameter('portfolios', 'portfolios')
316
- .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
317
+ .withVariableParameter('portfolio', 'portfolio', 'transaction.portfolio', false)
317
318
  .withLiteralParameter('positions', 'positions')
318
- .withVariableParameter('position', 'position', 'position', false)
319
+ .withVariableParameter('position', 'position', 'transaction.position', false)
319
320
  .withLiteralParameter('transactions', 'transactions');
320
321
  })
321
322
  .withQueryBuilder((qb) => {
322
- qb.withVariableParameter('type', 'type', 'type', false, x => x.code);
323
+ qb.withVariableParameter('type', 'type', 'transaction.type', false, x => x.code)
324
+ .withVariableParameter('suppressCorporateActions', 'suppressCorporateActions', 'options.suppressCorporateActions', true, x => is.boolean(x) && x ? 'true' : x);
325
+ })
326
+ .withBodyBuilder((bb) => {
327
+ bb.withVariableParameter('body', 'body', 'transaction', false);
323
328
  })
324
- .withBody('transaction')
325
329
  .withRequestInterceptor(requestInterceptor)
326
330
  .withResponseInterceptor(responseInterceptorForPositionMutateDeserialization)
327
331
  .withErrorInterceptor(ErrorInterceptor.GENERAL)
@@ -333,7 +337,7 @@ module.exports = (() => {
333
337
  .withHost(host)
334
338
  .withPort(port)
335
339
  .withPathBuilder((pb) => {
336
- pb.withLiteralParameter('version', 'v1')
340
+ pb.withLiteralParameter('version', REST_API_VERSION)
337
341
  .withLiteralParameter('portfolios', 'portfolios')
338
342
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
339
343
  .withLiteralParameter('positions', 'positions')
@@ -356,7 +360,7 @@ module.exports = (() => {
356
360
  .withHost(host)
357
361
  .withPort(port)
358
362
  .withPathBuilder((pb) => {
359
- pb.withLiteralParameter('version', 'v1')
363
+ pb.withLiteralParameter('version', REST_API_VERSION)
360
364
  .withLiteralParameter('portfolios', 'portfolios')
361
365
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
362
366
  .withLiteralParameter('positions', 'positions')
@@ -379,7 +383,7 @@ module.exports = (() => {
379
383
  .withHost(host)
380
384
  .withPort(port)
381
385
  .withPathBuilder((pb) => {
382
- pb.withLiteralParameter('version', 'v1')
386
+ pb.withLiteralParameter('version', REST_API_VERSION)
383
387
  .withLiteralParameter('portfolios', 'portfolios')
384
388
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
385
389
  .withLiteralParameter('positions', 'positions')
@@ -403,7 +407,7 @@ module.exports = (() => {
403
407
  .withHost(host)
404
408
  .withPort(port)
405
409
  .withPathBuilder((pb) => {
406
- pb.withLiteralParameter('version', 'v1')
410
+ pb.withLiteralParameter('version', REST_API_VERSION)
407
411
  .withLiteralParameter('portfolios', 'portfolios')
408
412
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
409
413
  .withLiteralParameter('positions', 'positions')
@@ -429,7 +433,7 @@ module.exports = (() => {
429
433
  .withHost(host)
430
434
  .withPort(port)
431
435
  .withPathBuilder((pb) => {
432
- pb.withLiteralParameter('version', 'v1')
436
+ pb.withLiteralParameter('version', REST_API_VERSION)
433
437
  .withLiteralParameter('portfolios', 'portfolios')
434
438
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
435
439
  .withLiteralParameter('wealthscope', 'wealthscope')
@@ -447,7 +451,7 @@ module.exports = (() => {
447
451
  .withHost(host)
448
452
  .withPort(port)
449
453
  .withPathBuilder((pb) => {
450
- pb.withLiteralParameter('version', 'v1')
454
+ pb.withLiteralParameter('version', REST_API_VERSION)
451
455
  .withLiteralParameter('portfolios', 'portfolios')
452
456
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
453
457
  .withLiteralParameter('reports', 'reports')
@@ -469,7 +473,7 @@ module.exports = (() => {
469
473
  .withHost(host)
470
474
  .withPort(port)
471
475
  .withPathBuilder((pb) => {
472
- pb.withLiteralParameter('version', 'v1')
476
+ pb.withLiteralParameter('version', REST_API_VERSION)
473
477
  .withLiteralParameter('system', 'system')
474
478
  .withLiteralParameter('version', 'version');
475
479
  })
@@ -531,104 +535,127 @@ module.exports = (() => {
531
535
  }
532
536
 
533
537
  /**
534
- * Reads all portfolios for a user, or a single portfolio.
538
+ * Creates a new portfolio for the current user.
535
539
  *
536
540
  * @public
537
- * @param {String=} portfolio
538
- * @returns {Promise<Portfolio[]>}
541
+ * @param {Schema.PortfolioCreate} portfolio - Data regarding the portfolio to create.
542
+ * @returns {Promise<Schema.Portfolio>}
539
543
  */
540
- readPortfolios(portfolio) {
544
+ createPortfolio(portfolio) {
541
545
  return Promise.resolve()
542
546
  .then(() => {
543
547
  checkStart.call(this);
544
548
 
545
- assert.argumentIsOptional(portfolio, 'portfolio', String);
549
+ assert.argumentIsRequired(portfolio, 'portfolio', Object);
546
550
 
547
- return Gateway.invoke(this._readPortfoliosEndpoint, { portfolio: portfolio || '*' });
551
+ return Gateway.invoke(this._createPortfolioEndpoint, PortfolioSchema.CREATE.schema.format(portfolio));
548
552
  });
549
553
  }
550
554
 
551
555
  /**
552
- * Creates a portfolio.
556
+ * Updates a portfolio.
553
557
  *
554
558
  * @public
555
- * @param {Object} portfolio
556
- * @returns {Promise<Portfolio>}
559
+ * @param {Schema.PortfolioUpdate} portfolio
560
+ * @returns {Promise<Schema.Portfolio>}
557
561
  */
558
- createPortfolio(portfolio) {
562
+ updatePortfolio(portfolio) {
559
563
  return Promise.resolve()
560
564
  .then(() => {
561
565
  checkStart.call(this);
562
566
 
563
567
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
564
568
 
565
- return Gateway.invoke(this._createPortfolioEndpoint, PortfolioSchema.CREATE.schema.format(portfolio));
569
+ return Gateway.invoke(this._updatePortfolioEndpoint, PortfolioSchema.UPDATE.schema.format(portfolio));
566
570
  });
567
571
  }
568
572
 
569
573
  /**
570
- * Creates a new portfolio and immediately populates it with transactions.
574
+ * Deletes a portfolio. All data associated with the portfolio will also be
575
+ * deleted (e.g. positions, transactions, etc).
571
576
  *
572
577
  * @public
573
- * @param {Object} portfolio
574
- * @returns {Promise<Portfolio>}
578
+ * @param {String} portfolio - The identifier of the portfolio to delete.
579
+ * @returns {Promise}
575
580
  */
576
- importPortfolio(portfolio, transactions) {
581
+ deletePortfolio(portfolio) {
577
582
  return Promise.resolve()
578
583
  .then(() => {
579
584
  checkStart.call(this);
580
585
 
581
- return this.createPortfolio(portfolio)
582
- .then((portfolio) => {
583
- return this.batchTransactions(portfolio, transactions);
584
- });
586
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
587
+
588
+ return Gateway.invoke(this._deletePortfolioEndpoint, { portfolio: portfolio });
585
589
  });
586
590
  }
587
591
 
588
592
  /**
589
- * Updates a portfolio.
593
+ * Reads all portfolios (or a single portfolio) for the current user.
590
594
  *
591
595
  * @public
592
- * @param {Object} portfolio
593
- * @returns {Promise<Portfolio>}
596
+ * @param {String=} portfolio - A portfolio identifier. If omitted, all portfolios for the current user will be returned.
597
+ * @returns {Promise<Schema.Portfolio[]>}
594
598
  */
595
- updatePortfolio(portfolio) {
599
+ readPortfolios(portfolio) {
596
600
  return Promise.resolve()
597
601
  .then(() => {
598
602
  checkStart.call(this);
599
603
 
600
- assert.argumentIsRequired(portfolio, 'portfolio', Object);
604
+ assert.argumentIsOptional(portfolio, 'portfolio', String);
601
605
 
602
- return Gateway.invoke(this._updatePortfolioEndpoint, PortfolioSchema.UPDATE.schema.format(portfolio));
606
+ return Gateway.invoke(this._readPortfoliosEndpoint, { portfolio: portfolio || '*' });
603
607
  });
604
608
  }
605
609
 
606
610
  /**
607
- * Deletes a portfolio.
611
+ * Updates a position.
608
612
  *
609
613
  * @public
610
- * @param {String} portfolio - ID of the portfolio to update
611
- * @returns {Promise<Portfolio>}
614
+ * @param {Schema.PositionUpdate} position
615
+ * @returns {Promise<Schema.Position>}
612
616
  */
613
- deletePortfolio(portfolio) {
617
+ updatePosition(position) {
618
+ return Promise.resolve()
619
+ .then(() => {
620
+ checkStart.call(this);
621
+
622
+ assert.argumentIsRequired(position, 'position', Object);
623
+
624
+ return Gateway.invoke(this._updatePositionEndpoint, PositionSchema.UPDATE.schema.format(position));
625
+ });
626
+ }
627
+
628
+ /**
629
+ * Deletes a position (and all associated data, including transactions and summaries).
630
+ * An array of deleted positions is returned (in some rare cases, deleting one position
631
+ * may cause other positions to be be deleted — for example, a position which was spun-off).
632
+ *
633
+ * @public
634
+ * @param {String} portfolio - The identifier of the portfolio which contains the position to delete.
635
+ * @param {String} position - The identifier of the position to delete.
636
+ * @returns {Promise<Schema.Position[]>}
637
+ */
638
+ deletePosition(portfolio, position) {
614
639
  return Promise.resolve()
615
640
  .then(() => {
616
641
  checkStart.call(this);
617
642
 
618
643
  assert.argumentIsRequired(portfolio, 'portfolio', String);
644
+ assert.argumentIsRequired(position, 'position', String);
619
645
 
620
- return Gateway.invoke(this._deletePortfolioEndpoint, { portfolio: portfolio });
646
+ return Gateway.invoke(this._deletePositionEndpoint, { portfolio: portfolio, position: position });
621
647
  });
622
648
  }
623
649
 
650
+
624
651
  /**
625
652
  * Retrieves all positions for a user, a user's portfolio, or a single position.
626
653
  *
627
654
  * @public
628
- * @param {String=} portfolio
629
- * @param {String=} position
655
+ * @param {String=} portfolio - The identifier of the portfolio containing the desired positions. If omitted, all positions for the current user, regardless of portfolio, will be returned.
656
+ * @param {String=} position - The identifier of the specific position to read. If included, the "portfolio" parameter must be specified.
630
657
  * @param {Boolean=} includePreviousPrice
631
- * @returns {Promise<Position[]>}
658
+ * @returns {Promise<Schema.Position[]>}
632
659
  */
633
660
  readPositions(portfolio, position, includePreviousPrice) {
634
661
  return Promise.resolve()
@@ -639,7 +666,7 @@ module.exports = (() => {
639
666
  assert.argumentIsOptional(position, 'position', String);
640
667
  assert.argumentIsOptional(includePreviousPrice, 'includePreviousPrice', Boolean);
641
668
 
642
- return Gateway.invoke(this._readPositionsEndpoint, { portfolio: portfolio || '*', position: position || '*', includePreviousPrice: includePreviousPrice });
669
+ return Gateway.invoke(this._readPositionsEndpoint, { portfolio: portfolio || '*', position: position || '*', includePreviousPrice: includePreviousPrice || false });
643
670
  });
644
671
  }
645
672
 
@@ -647,10 +674,11 @@ module.exports = (() => {
647
674
  * Queries positions.
648
675
  *
649
676
  * @public
677
+ * @ignore
650
678
  * @param {String} symbol
651
679
  * @param {Boolean=} open
652
680
  * @param {PositionSchema=} schema
653
- * @returns {Promise<Position[]>}
681
+ * @returns {Promise<Schema.Position[]>}
654
682
  */
655
683
  queryPositionsForSymbol(symbol, open, schema) {
656
684
  return Promise.resolve()
@@ -675,29 +703,12 @@ module.exports = (() => {
675
703
  });
676
704
  }
677
705
 
678
- /**
679
- * Updates a position.
680
- *
681
- * @public
682
- * @param {Object} position
683
- * @returns {Promise<Position>}
684
- */
685
- updatePosition(position) {
686
- return Promise.resolve()
687
- .then(() => {
688
- checkStart.call(this);
689
-
690
- assert.argumentIsRequired(position, 'position', Object);
691
-
692
- return Gateway.invoke(this._updatePositionEndpoint, PositionSchema.UPDATE.schema.format(position));
693
- });
694
- }
695
-
696
706
  /**
697
707
  * Returns a promise which resolves as soon as the position's lock status
698
708
  * changes to false.
699
709
  *
700
710
  * @public
711
+ * @ignore
701
712
  * @param {String} portfolio
702
713
  * @param {String} position
703
714
  * @returns {Promise}
@@ -733,15 +744,16 @@ module.exports = (() => {
733
744
  }
734
745
 
735
746
  /**
736
- * Retrieves positions for a user, a user's portfolio, or a single position.
747
+ * Retrieves summaries for a user, a user's portfolio, or a single position.
737
748
  *
738
749
  * @public
750
+ * @ignore
739
751
  * @param {String=} portfolio
740
752
  * @param {String=} position
741
753
  * @param {Array<PositionSummaryFrame>=|Array<String>=} frames
742
754
  * @param {Number=} periods
743
755
  * @param {Day=|String=} start
744
- * @returns {Promise<Position[]>}
756
+ * @returns {Promise<Schema.Position[]>}
745
757
  */
746
758
  readPositionSummaries(portfolio, position, frames, periods, start) {
747
759
  return Promise.resolve()
@@ -804,49 +816,63 @@ module.exports = (() => {
804
816
  }
805
817
 
806
818
  /**
807
- * Retrieves values availability of the portfolio and it's positions.
819
+ * Retrieves end-of-day valuations for the entire portfolio (or a single position).
808
820
  *
809
821
  * @public
810
- * @param {String} portfolio
811
- * @return {Promise<ValuationsAvailabilityResult>}
822
+ * @ignore
823
+ * @param {String} portfolio - The identifier of the portfolio.
824
+ * @param {String=} position - The identifier of the position. If omitted, that valuation history will be returned for the entire portfolio (i.e. sum of valuations for all positions contained in the portfolio).
825
+ * @param {Boolean=} parse - If true, the result will be a {@link Schema.ValuationContainer} object. Otherwise, the result will be a JSON-formatted string.
826
+ * @returns {Promise<String|Schema.ValuationContainer>}
812
827
  */
813
- readPositionValuationsAvailability(portfolio) {
828
+ readPositionValuations(portfolio, position, parse) {
814
829
  return Promise.resolve()
815
830
  .then(() => {
816
831
  checkStart.call(this);
817
832
 
818
833
  assert.argumentIsRequired(portfolio, 'portfolio', String);
834
+ assert.argumentIsOptional(position, 'position', String);
819
835
 
820
836
  const payload = { };
821
837
 
822
838
  payload.portfolio = portfolio;
839
+ payload.position = position || '*';
823
840
 
824
- return Gateway.invoke(this._readPositionValuationsAvailabilityEndpoint, payload);
841
+ return Gateway.invoke(this._readPositionValuationsEndpoint, payload)
842
+ .then((json) => {
843
+ let result;
844
+
845
+ if (parse) {
846
+ result = JSON.parse(json);
847
+ } else {
848
+ result = json;
849
+ }
850
+
851
+ return result;
852
+ });
825
853
  });
826
854
  }
827
855
 
828
856
  /**
829
- * Retrieves end-of-day position valuations for the entire portfolio or single position.
857
+ * Retrieves values availability of the portfolio and it's positions.
830
858
  *
831
859
  * @public
860
+ * @ignore
832
861
  * @param {String} portfolio
833
- * @param {String=} position
834
- * @returns {Promise<Object[]>}
862
+ * @return {Promise<Schema.ValuationsAvailabilityResult>}
835
863
  */
836
- readPositionValuations(portfolio, position) {
864
+ readPositionValuationsAvailability(portfolio) {
837
865
  return Promise.resolve()
838
866
  .then(() => {
839
867
  checkStart.call(this);
840
868
 
841
869
  assert.argumentIsRequired(portfolio, 'portfolio', String);
842
- assert.argumentIsOptional(position, 'position', String);
843
870
 
844
871
  const payload = { };
845
872
 
846
873
  payload.portfolio = portfolio;
847
- payload.position = position || '*';
848
874
 
849
- return Gateway.invoke(this._readPositionValuationsEndpoint, payload);
875
+ return Gateway.invoke(this._readPositionValuationsAvailabilityEndpoint, payload);
850
876
  });
851
877
  }
852
878
 
@@ -854,6 +880,7 @@ module.exports = (() => {
854
880
  * Queries end-of-day position valuations across all user portfolios.
855
881
  *
856
882
  * @public
883
+ * @ignore
857
884
  * @param {String} symbol
858
885
  * @return {Promise<Object[]>}
859
886
  */
@@ -866,34 +893,15 @@ module.exports = (() => {
866
893
  });
867
894
  }
868
895
 
869
- /**
870
- * Deletes a position.
871
- *
872
- * @public
873
- * @param {String} portfolio
874
- * @param {String} position
875
- * @returns {Promise<Position[]>}
876
- */
877
- deletePosition(portfolio, position) {
878
- return Promise.resolve()
879
- .then(() => {
880
- checkStart.call(this);
881
-
882
- assert.argumentIsRequired(portfolio, 'portfolio', String);
883
- assert.argumentIsRequired(position, 'position', String);
884
-
885
- return Gateway.invoke(this._deletePositionEndpoint, { portfolio: portfolio, position: position });
886
- });
887
- }
888
-
889
896
  /**
890
897
  * Creates a new transaction.
891
898
  *
892
899
  * @public
893
- * @param {Object} transaction
894
- * @returns {Promise<TransactionMutateResult>}
900
+ * @param {Schema.TransactionCreate} transaction
901
+ * @param {Object} options
902
+ * @returns {Promise<Schema.TransactionMutateResult>}
895
903
  */
896
- createTransaction(transaction) {
904
+ createTransaction(transaction, options) {
897
905
  return Promise.resolve()
898
906
  .then(() => {
899
907
  checkStart.call(this);
@@ -901,6 +909,7 @@ module.exports = (() => {
901
909
  assert.argumentIsRequired(transaction, 'transaction', Object);
902
910
  assert.argumentIsRequired(transaction.portfolio, 'transaction.portfolio', String);
903
911
  assert.argumentIsOptional(transaction.position, 'transaction.position', String);
912
+ assert.argumentIsOptional(options, 'options', Object);
904
913
 
905
914
  if (!transaction.position) {
906
915
  transaction.position = 'new';
@@ -908,16 +917,21 @@ module.exports = (() => {
908
917
 
909
918
  const schema = getTransactionSchema(transaction);
910
919
 
911
- return Gateway.invoke(this._createTransactionEndpoint, schema.schema.format(transaction));
920
+ const payload = { };
921
+
922
+ payload.transaction = schema.schema.format(transaction);
923
+ payload.options = options || { };
924
+
925
+ return Gateway.invoke(this._createTransactionEndpoint, payload);
912
926
  });
913
927
  }
914
928
 
915
929
  /**
916
- * Edits a transaction.
930
+ * Edits a transaction (e.g. change the date, price, quantity, etc).
917
931
  *
918
932
  * @public
919
- * @param {Object} transaction
920
- * @returns {Promise<TransactionMutateResult>}
933
+ * @param {Schema.Transaction} transaction
934
+ * @returns {Promise<Schema.TransactionMutateResult>}
921
935
  */
922
936
  editTransaction(transaction) {
923
937
  return Promise.resolve()
@@ -939,9 +953,10 @@ module.exports = (() => {
939
953
  * Switch the reinvestment strategy for a single transaction.
940
954
  *
941
955
  * @public
942
- * @param {Object} transaction
956
+ * @ignore
957
+ * @param {Schema.Transaction} transaction
943
958
  * @param {TransactionType} type
944
- * @returns {Promise<TransactionMutateResult>}
959
+ * @returns {Promise<Schema.TransactionMutateResult>}
945
960
  */
946
961
  switchTransaction(transaction, type) {
947
962
  return Promise.resolve()
@@ -967,13 +982,13 @@ module.exports = (() => {
967
982
  * Deletes a transaction.
968
983
  *
969
984
  * @public
970
- * @param {String} portfolio
971
- * @param {String} position
972
- * @param {Number} sequence
985
+ * @param {String} portfolio - The identifier of the portfolio which contains the targeted position.
986
+ * @param {String} position - The identifier of the targeted position.
987
+ * @param {Number} sequence - The sequence number of the transaction to delete.
973
988
  * @param {Boolean=} force
974
989
  * @param {Day=} echoStart
975
990
  * @param {Day=} echoEnd
976
- * @returns {Promise<TransactionMutateResult>}
991
+ * @returns {Promise<Schema.TransactionMutateResult>}
977
992
  */
978
993
  deleteTransaction(portfolio, position, sequence, force, echoStart, echoEnd) {
979
994
  return Promise.resolve()
@@ -1010,10 +1025,10 @@ module.exports = (() => {
1010
1025
  * Retrieves transactions for a portfolio, or a single position.
1011
1026
  *
1012
1027
  * @public
1013
- * @param {String} portfolio
1014
- * @param {String=} position
1015
- * @param {Number=} sequence
1016
- * @returns {Promise<Transaction[]>}
1028
+ * @param {String} portfolio - The identifier of the portfolio containing the desired transactions.
1029
+ * @param {String=} position - The identifier for the position to read transactions for. If included, the resulting transactions will be limited to the specified position. Otherwise, transactions for all positions in the portfolio, will be returned.
1030
+ * @param {Number=} sequence - The sequence number of the specific transaction to read. If included, both the "portfolio" and "position" parameters must be specified.
1031
+ * @returns {Promise<Schema.Transaction[]>}
1017
1032
  */
1018
1033
  readTransactions(portfolio, position, sequence) {
1019
1034
  return Promise.resolve()
@@ -1033,6 +1048,7 @@ module.exports = (() => {
1033
1048
  * for a portfolio, or a single position.
1034
1049
  *
1035
1050
  * @public
1051
+ * @ignore
1036
1052
  * @param {String} portfolio
1037
1053
  * @param {String=} position
1038
1054
  * @param {Day=} startDay
@@ -1074,6 +1090,7 @@ module.exports = (() => {
1074
1090
  * Reads a single page of formatted transactions.
1075
1091
  *
1076
1092
  * @public
1093
+ * @ignore
1077
1094
  * @param {String} portfolio
1078
1095
  * @param {String} position
1079
1096
  * @param {Number=} sequence
@@ -1113,10 +1130,35 @@ module.exports = (() => {
1113
1130
  });
1114
1131
  }
1115
1132
 
1133
+ /**
1134
+ * Retrieves end-of-day valuations for the entire portfolio (or a single position).
1135
+ *
1136
+ * @public
1137
+ * @param {String} portfolio - The identifier of the portfolio.
1138
+ * @param {String=} position - The identifier of the position. If omitted, that valuation history will be returned for the entire portfolio (i.e. sum of valuations for all positions contained in the portfolio).
1139
+ * @returns {Promise<Schema.ValuationContainer>}
1140
+ */
1141
+ readValuations(portfolio, position) {
1142
+ return this.readPositionValuations(portfolio, position, true);
1143
+ }
1144
+
1145
+ /**
1146
+ * Retrieves the status of end-of-day valuations for all positions contained
1147
+ * within a portfolio.
1148
+ *
1149
+ * @public
1150
+ * @param {String} portfolio - The identifier of the portfolio.
1151
+ * @returns {Promise<Schema.ValuationsAvailabilityResult>}
1152
+ */
1153
+ checkValuations(portfolio) {
1154
+ return this.readPositionValuationsAvailability(portfolio);
1155
+ }
1156
+
1116
1157
  /**
1117
1158
  * Reads a wealthscope token for a specific portfolio.
1118
1159
  *
1119
1160
  * @public
1161
+ * @ignore
1120
1162
  * @param {String} portfolio
1121
1163
  * @return {Promise<String>}
1122
1164
  */
@@ -1139,6 +1181,7 @@ module.exports = (() => {
1139
1181
  * Returns all position summary definitions for a portfolio.
1140
1182
  *
1141
1183
  * @public
1184
+ * @ignore
1142
1185
  * @param {String} portfolio
1143
1186
  */
1144
1187
  readBrokerageReportAvailability(portfolio) {
@@ -1158,6 +1201,7 @@ module.exports = (() => {
1158
1201
  * Generates a URL suitable for downloading a brokerage report (as a PDF).
1159
1202
  *
1160
1203
  * @public
1204
+ * @ignore
1161
1205
  * @param {String} user
1162
1206
  * @param {String} portfolio
1163
1207
  * @param {PositionSummaryFrame} frame
@@ -1179,21 +1223,7 @@ module.exports = (() => {
1179
1223
  }
1180
1224
 
1181
1225
  /**
1182
- * Queries existing positions for a specific symbol.
1183
- *
1184
- * @public
1185
- * @param {String} symbol
1186
- * @returns {Promise<Array>}
1187
- */
1188
- querySymbol(symbol) {
1189
- return Promise.resolve()
1190
- .then(() => {
1191
- return [ ];
1192
- });
1193
- }
1194
-
1195
- /**
1196
- * Returns current API version of portfolio.
1226
+ * Returns current version of the Portfolio Service.
1197
1227
  *
1198
1228
  * @public
1199
1229
  * @returns {Promise<Object>}
@@ -1228,6 +1258,7 @@ module.exports = (() => {
1228
1258
  * Creates and starts a new {@link PortfolioGateway} for use in the private development environment.
1229
1259
  *
1230
1260
  * @public
1261
+ * @ignore
1231
1262
  * @static
1232
1263
  * @param {JwtProvider} jwtProvider
1233
1264
  * @param {String=} product
@@ -1247,6 +1278,7 @@ module.exports = (() => {
1247
1278
  * Creates and starts a new {@link PortfolioGateway} for use in the private staging environment.
1248
1279
  *
1249
1280
  * @public
1281
+ * @ignore
1250
1282
  * @static
1251
1283
  * @param {JwtProvider} jwtProvider
1252
1284
  * @param {String=} product
@@ -1263,7 +1295,7 @@ module.exports = (() => {
1263
1295
  }
1264
1296
 
1265
1297
  /**
1266
- * Creates and starts a new {@link PortfolioGateway} for use in the private demo environment.
1298
+ * Creates and starts a new {@link PortfolioGateway} for use in the public demo environment.
1267
1299
  *
1268
1300
  * @public
1269
1301
  * @static
@@ -1304,6 +1336,7 @@ module.exports = (() => {
1304
1336
  * Creates and starts a new {@link PortfolioGateway} for use in the private admin environment.
1305
1337
  *
1306
1338
  * @public
1339
+ * @ignore
1307
1340
  * @static
1308
1341
  * @param {JwtProvider} jwtProvider
1309
1342
  * @param {String=} product
@@ -1503,24 +1536,5 @@ module.exports = (() => {
1503
1536
  return returnRef;
1504
1537
  }
1505
1538
 
1506
- /**
1507
- * The result of transaction create operation.
1508
- *
1509
- * @typedef TransactionMutateResult
1510
- * @type {Object}
1511
- * @property {Object[]} positions - All positions updated as a consequence of processing the transaction.
1512
- * @property {Object[]} summaries - All position summaries updated as a consequence of processing the transaction.
1513
- * @property {Boolean} replaced - If true, the position (and position summaries) need to be replaced.
1514
- */
1515
-
1516
- /**
1517
- * The result of valuations availability.
1518
- *
1519
- * @typedef ValuationsAvailabilityResult
1520
- * @type {Object}
1521
- * @property {Boolean} available - If true, portfolio valuations are up-to-date and ready.
1522
- * @property {String[]} positions - Array of position id's that are in recalculation state.
1523
- */
1524
-
1525
1539
  return PortfolioGateway;
1526
1540
  })();
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtProvider: JwtProvider,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '5.1.2'
10
+ version: '5.3.0'
11
11
  };
12
12
  })();
@@ -5,7 +5,7 @@
5
5
  */
6
6
 
7
7
  /**
8
- * A function which returns a signed token.
8
+ * A function, accepting no arguments, which returns a signed token.
9
9
  *
10
10
  * @public
11
11
  * @callback JwtTokenGenerator
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "5.1.2",
4
- "description": "JavaScript library for interfacing with Barchart's Portfolio API",
3
+ "version": "5.3.0",
4
+ "description": "JavaScript SDK for Barchart's Portfolio Service",
5
+ "homepage": "https://docs.barchart.com/portfolio/#/",
5
6
  "author": {
6
7
  "name": "Bryan Ingle",
7
8
  "email": "bryan.ingle@barchart.com",
@@ -12,12 +13,18 @@
12
13
  },
13
14
  "repository": {
14
15
  "type": "git",
15
- "url": "git+ssh://git@github.com/barchart/barchart/portfolio-client-js.git"
16
+ "url": "git+ssh://git@github.com/barchart/portfolio-client-js.git"
17
+ },
18
+ "directories": {
19
+ "test": "test"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/barchart/portfolio-client-js/issues"
16
23
  },
17
24
  "keywords": [
18
25
  "Barchart",
26
+ "Portfolio",
19
27
  "JavaScript",
20
- "Client",
21
28
  "SDK"
22
29
  ],
23
30
  "dependencies": {
@@ -31,11 +38,13 @@
31
38
  "git-get-status": "^1.0.5",
32
39
  "glob": "^6.0.1",
33
40
  "gulp": "^4.0.2",
41
+ "gulp-awspublish": "^4.1.2",
34
42
  "gulp-git": "^2.9.0",
35
43
  "gulp-jasmine": "^2.2.1",
36
44
  "gulp-jsdoc3": "^1.0.1",
37
45
  "gulp-jshint": "~2.1.0",
38
46
  "gulp-prompt": "^1.2.0",
47
+ "gulp-rename": "^1.4.0",
39
48
  "gulp-replace": "^0.5.4",
40
49
  "jshint": "^2.12.0",
41
50
  "vinyl-buffer": "^1.0.1",
@@ -48,12 +57,5 @@
48
57
  ]
49
58
  ]
50
59
  },
51
- "license": "UNLICENSED",
52
- "bugs": {
53
- "url": "https://github.com/barchart/portfolio-client-js/issues"
54
- },
55
- "homepage": "https://github.com/barchart/portfolio-client-js#readme",
56
- "directories": {
57
- "test": "test"
58
- }
60
+ "license": "MIT"
59
61
  }