@barchart/portfolio-client-js 5.1.2 → 5.2.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\""}
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,7 +312,7 @@ 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
317
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
317
318
  .withLiteralParameter('positions', 'positions')
@@ -333,7 +334,7 @@ module.exports = (() => {
333
334
  .withHost(host)
334
335
  .withPort(port)
335
336
  .withPathBuilder((pb) => {
336
- pb.withLiteralParameter('version', 'v1')
337
+ pb.withLiteralParameter('version', REST_API_VERSION)
337
338
  .withLiteralParameter('portfolios', 'portfolios')
338
339
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
339
340
  .withLiteralParameter('positions', 'positions')
@@ -356,7 +357,7 @@ module.exports = (() => {
356
357
  .withHost(host)
357
358
  .withPort(port)
358
359
  .withPathBuilder((pb) => {
359
- pb.withLiteralParameter('version', 'v1')
360
+ pb.withLiteralParameter('version', REST_API_VERSION)
360
361
  .withLiteralParameter('portfolios', 'portfolios')
361
362
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
362
363
  .withLiteralParameter('positions', 'positions')
@@ -379,7 +380,7 @@ module.exports = (() => {
379
380
  .withHost(host)
380
381
  .withPort(port)
381
382
  .withPathBuilder((pb) => {
382
- pb.withLiteralParameter('version', 'v1')
383
+ pb.withLiteralParameter('version', REST_API_VERSION)
383
384
  .withLiteralParameter('portfolios', 'portfolios')
384
385
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
385
386
  .withLiteralParameter('positions', 'positions')
@@ -403,7 +404,7 @@ module.exports = (() => {
403
404
  .withHost(host)
404
405
  .withPort(port)
405
406
  .withPathBuilder((pb) => {
406
- pb.withLiteralParameter('version', 'v1')
407
+ pb.withLiteralParameter('version', REST_API_VERSION)
407
408
  .withLiteralParameter('portfolios', 'portfolios')
408
409
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
409
410
  .withLiteralParameter('positions', 'positions')
@@ -429,7 +430,7 @@ module.exports = (() => {
429
430
  .withHost(host)
430
431
  .withPort(port)
431
432
  .withPathBuilder((pb) => {
432
- pb.withLiteralParameter('version', 'v1')
433
+ pb.withLiteralParameter('version', REST_API_VERSION)
433
434
  .withLiteralParameter('portfolios', 'portfolios')
434
435
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
435
436
  .withLiteralParameter('wealthscope', 'wealthscope')
@@ -447,7 +448,7 @@ module.exports = (() => {
447
448
  .withHost(host)
448
449
  .withPort(port)
449
450
  .withPathBuilder((pb) => {
450
- pb.withLiteralParameter('version', 'v1')
451
+ pb.withLiteralParameter('version', REST_API_VERSION)
451
452
  .withLiteralParameter('portfolios', 'portfolios')
452
453
  .withVariableParameter('portfolio', 'portfolio', 'portfolio', false)
453
454
  .withLiteralParameter('reports', 'reports')
@@ -469,7 +470,7 @@ module.exports = (() => {
469
470
  .withHost(host)
470
471
  .withPort(port)
471
472
  .withPathBuilder((pb) => {
472
- pb.withLiteralParameter('version', 'v1')
473
+ pb.withLiteralParameter('version', REST_API_VERSION)
473
474
  .withLiteralParameter('system', 'system')
474
475
  .withLiteralParameter('version', 'version');
475
476
  })
@@ -531,104 +532,127 @@ module.exports = (() => {
531
532
  }
532
533
 
533
534
  /**
534
- * Reads all portfolios for a user, or a single portfolio.
535
+ * Creates a new portfolio for the current user.
535
536
  *
536
537
  * @public
537
- * @param {String=} portfolio
538
- * @returns {Promise<Portfolio[]>}
538
+ * @param {Schema.PortfolioCreate} portfolio - Data regarding the portfolio to create.
539
+ * @returns {Promise<Schema.Portfolio>}
539
540
  */
540
- readPortfolios(portfolio) {
541
+ createPortfolio(portfolio) {
541
542
  return Promise.resolve()
542
543
  .then(() => {
543
544
  checkStart.call(this);
544
545
 
545
- assert.argumentIsOptional(portfolio, 'portfolio', String);
546
+ assert.argumentIsRequired(portfolio, 'portfolio', Object);
546
547
 
547
- return Gateway.invoke(this._readPortfoliosEndpoint, { portfolio: portfolio || '*' });
548
+ return Gateway.invoke(this._createPortfolioEndpoint, PortfolioSchema.CREATE.schema.format(portfolio));
548
549
  });
549
550
  }
550
551
 
551
552
  /**
552
- * Creates a portfolio.
553
+ * Updates a portfolio.
553
554
  *
554
555
  * @public
555
- * @param {Object} portfolio
556
- * @returns {Promise<Portfolio>}
556
+ * @param {Schema.PortfolioUpdate} portfolio
557
+ * @returns {Promise<Schema.Portfolio>}
557
558
  */
558
- createPortfolio(portfolio) {
559
+ updatePortfolio(portfolio) {
559
560
  return Promise.resolve()
560
561
  .then(() => {
561
562
  checkStart.call(this);
562
563
 
563
564
  assert.argumentIsRequired(portfolio, 'portfolio', Object);
564
565
 
565
- return Gateway.invoke(this._createPortfolioEndpoint, PortfolioSchema.CREATE.schema.format(portfolio));
566
+ return Gateway.invoke(this._updatePortfolioEndpoint, PortfolioSchema.UPDATE.schema.format(portfolio));
566
567
  });
567
568
  }
568
569
 
569
570
  /**
570
- * Creates a new portfolio and immediately populates it with transactions.
571
+ * Deletes a portfolio. All data associated with the portfolio will also be
572
+ * deleted (e.g. positions, transactions, etc).
571
573
  *
572
574
  * @public
573
- * @param {Object} portfolio
574
- * @returns {Promise<Portfolio>}
575
+ * @param {String} portfolio - The identifier of the portfolio to delete.
576
+ * @returns {Promise}
575
577
  */
576
- importPortfolio(portfolio, transactions) {
578
+ deletePortfolio(portfolio) {
577
579
  return Promise.resolve()
578
580
  .then(() => {
579
581
  checkStart.call(this);
580
582
 
581
- return this.createPortfolio(portfolio)
582
- .then((portfolio) => {
583
- return this.batchTransactions(portfolio, transactions);
584
- });
583
+ assert.argumentIsRequired(portfolio, 'portfolio', String);
584
+
585
+ return Gateway.invoke(this._deletePortfolioEndpoint, { portfolio: portfolio });
585
586
  });
586
587
  }
587
588
 
588
589
  /**
589
- * Updates a portfolio.
590
+ * Reads all portfolios (or a single portfolio) for the current user.
590
591
  *
591
592
  * @public
592
- * @param {Object} portfolio
593
- * @returns {Promise<Portfolio>}
593
+ * @param {String=} portfolio - A portfolio identifier. If omitted, all portfolios for the current user will be returned.
594
+ * @returns {Promise<Schema.Portfolio[]>}
594
595
  */
595
- updatePortfolio(portfolio) {
596
+ readPortfolios(portfolio) {
596
597
  return Promise.resolve()
597
598
  .then(() => {
598
599
  checkStart.call(this);
599
600
 
600
- assert.argumentIsRequired(portfolio, 'portfolio', Object);
601
+ assert.argumentIsOptional(portfolio, 'portfolio', String);
601
602
 
602
- return Gateway.invoke(this._updatePortfolioEndpoint, PortfolioSchema.UPDATE.schema.format(portfolio));
603
+ return Gateway.invoke(this._readPortfoliosEndpoint, { portfolio: portfolio || '*' });
603
604
  });
604
605
  }
605
606
 
606
607
  /**
607
- * Deletes a portfolio.
608
+ * Updates a position.
608
609
  *
609
610
  * @public
610
- * @param {String} portfolio - ID of the portfolio to update
611
- * @returns {Promise<Portfolio>}
611
+ * @param {Schema.PositionUpdate} position
612
+ * @returns {Promise<Schema.Position>}
612
613
  */
613
- deletePortfolio(portfolio) {
614
+ updatePosition(position) {
615
+ return Promise.resolve()
616
+ .then(() => {
617
+ checkStart.call(this);
618
+
619
+ assert.argumentIsRequired(position, 'position', Object);
620
+
621
+ return Gateway.invoke(this._updatePositionEndpoint, PositionSchema.UPDATE.schema.format(position));
622
+ });
623
+ }
624
+
625
+ /**
626
+ * Deletes a position (and all associated data, including transactions and summaries).
627
+ * An array of deleted positions is returned (in some rare cases, deleting one position
628
+ * may cause other positions to be be deleted — for example, a position which was spun-off).
629
+ *
630
+ * @public
631
+ * @param {String} portfolio - The identifier of the portfolio which contains the position to delete.
632
+ * @param {String} position - The identifier of the position to delete.
633
+ * @returns {Promise<Schema.Position[]>}
634
+ */
635
+ deletePosition(portfolio, position) {
614
636
  return Promise.resolve()
615
637
  .then(() => {
616
638
  checkStart.call(this);
617
639
 
618
640
  assert.argumentIsRequired(portfolio, 'portfolio', String);
641
+ assert.argumentIsRequired(position, 'position', String);
619
642
 
620
- return Gateway.invoke(this._deletePortfolioEndpoint, { portfolio: portfolio });
643
+ return Gateway.invoke(this._deletePositionEndpoint, { portfolio: portfolio, position: position });
621
644
  });
622
645
  }
623
646
 
647
+
624
648
  /**
625
649
  * Retrieves all positions for a user, a user's portfolio, or a single position.
626
650
  *
627
651
  * @public
628
- * @param {String=} portfolio
629
- * @param {String=} position
652
+ * @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.
653
+ * @param {String=} position - The identifier of the specific position to read. If included, the "portfolio" parameter must be specified.
630
654
  * @param {Boolean=} includePreviousPrice
631
- * @returns {Promise<Position[]>}
655
+ * @returns {Promise<Schema.Position[]>}
632
656
  */
633
657
  readPositions(portfolio, position, includePreviousPrice) {
634
658
  return Promise.resolve()
@@ -639,7 +663,7 @@ module.exports = (() => {
639
663
  assert.argumentIsOptional(position, 'position', String);
640
664
  assert.argumentIsOptional(includePreviousPrice, 'includePreviousPrice', Boolean);
641
665
 
642
- return Gateway.invoke(this._readPositionsEndpoint, { portfolio: portfolio || '*', position: position || '*', includePreviousPrice: includePreviousPrice });
666
+ return Gateway.invoke(this._readPositionsEndpoint, { portfolio: portfolio || '*', position: position || '*', includePreviousPrice: includePreviousPrice || false });
643
667
  });
644
668
  }
645
669
 
@@ -647,10 +671,11 @@ module.exports = (() => {
647
671
  * Queries positions.
648
672
  *
649
673
  * @public
674
+ * @ignore
650
675
  * @param {String} symbol
651
676
  * @param {Boolean=} open
652
677
  * @param {PositionSchema=} schema
653
- * @returns {Promise<Position[]>}
678
+ * @returns {Promise<Schema.Position[]>}
654
679
  */
655
680
  queryPositionsForSymbol(symbol, open, schema) {
656
681
  return Promise.resolve()
@@ -675,29 +700,12 @@ module.exports = (() => {
675
700
  });
676
701
  }
677
702
 
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
703
  /**
697
704
  * Returns a promise which resolves as soon as the position's lock status
698
705
  * changes to false.
699
706
  *
700
707
  * @public
708
+ * @ignore
701
709
  * @param {String} portfolio
702
710
  * @param {String} position
703
711
  * @returns {Promise}
@@ -733,15 +741,16 @@ module.exports = (() => {
733
741
  }
734
742
 
735
743
  /**
736
- * Retrieves positions for a user, a user's portfolio, or a single position.
744
+ * Retrieves summaries for a user, a user's portfolio, or a single position.
737
745
  *
738
746
  * @public
747
+ * @ignore
739
748
  * @param {String=} portfolio
740
749
  * @param {String=} position
741
750
  * @param {Array<PositionSummaryFrame>=|Array<String>=} frames
742
751
  * @param {Number=} periods
743
752
  * @param {Day=|String=} start
744
- * @returns {Promise<Position[]>}
753
+ * @returns {Promise<Schema.Position[]>}
745
754
  */
746
755
  readPositionSummaries(portfolio, position, frames, periods, start) {
747
756
  return Promise.resolve()
@@ -804,49 +813,63 @@ module.exports = (() => {
804
813
  }
805
814
 
806
815
  /**
807
- * Retrieves values availability of the portfolio and it's positions.
816
+ * Retrieves end-of-day valuations for the entire portfolio (or a single position).
808
817
  *
809
818
  * @public
810
- * @param {String} portfolio
811
- * @return {Promise<ValuationsAvailabilityResult>}
819
+ * @ignore
820
+ * @param {String} portfolio - The identifier of the portfolio.
821
+ * @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).
822
+ * @param {Boolean=} parse - If true, the result will be a {@link Schema.ValuationContainer} object. Otherwise, the result will be a JSON-formatted string.
823
+ * @returns {Promise<String|Schema.ValuationContainer>}
812
824
  */
813
- readPositionValuationsAvailability(portfolio) {
825
+ readPositionValuations(portfolio, position, parse) {
814
826
  return Promise.resolve()
815
827
  .then(() => {
816
828
  checkStart.call(this);
817
829
 
818
830
  assert.argumentIsRequired(portfolio, 'portfolio', String);
831
+ assert.argumentIsOptional(position, 'position', String);
819
832
 
820
833
  const payload = { };
821
834
 
822
835
  payload.portfolio = portfolio;
836
+ payload.position = position || '*';
823
837
 
824
- return Gateway.invoke(this._readPositionValuationsAvailabilityEndpoint, payload);
838
+ return Gateway.invoke(this._readPositionValuationsEndpoint, payload)
839
+ .then((json) => {
840
+ let result;
841
+
842
+ if (parse) {
843
+ result = JSON.parse(json);
844
+ } else {
845
+ result = json;
846
+ }
847
+
848
+ return result;
849
+ });
825
850
  });
826
851
  }
827
852
 
828
853
  /**
829
- * Retrieves end-of-day position valuations for the entire portfolio or single position.
854
+ * Retrieves values availability of the portfolio and it's positions.
830
855
  *
831
856
  * @public
857
+ * @ignore
832
858
  * @param {String} portfolio
833
- * @param {String=} position
834
- * @returns {Promise<Object[]>}
859
+ * @return {Promise<Schema.ValuationsAvailabilityResult>}
835
860
  */
836
- readPositionValuations(portfolio, position) {
861
+ readPositionValuationsAvailability(portfolio) {
837
862
  return Promise.resolve()
838
863
  .then(() => {
839
864
  checkStart.call(this);
840
865
 
841
866
  assert.argumentIsRequired(portfolio, 'portfolio', String);
842
- assert.argumentIsOptional(position, 'position', String);
843
867
 
844
868
  const payload = { };
845
869
 
846
870
  payload.portfolio = portfolio;
847
- payload.position = position || '*';
848
871
 
849
- return Gateway.invoke(this._readPositionValuationsEndpoint, payload);
872
+ return Gateway.invoke(this._readPositionValuationsAvailabilityEndpoint, payload);
850
873
  });
851
874
  }
852
875
 
@@ -854,6 +877,7 @@ module.exports = (() => {
854
877
  * Queries end-of-day position valuations across all user portfolios.
855
878
  *
856
879
  * @public
880
+ * @ignore
857
881
  * @param {String} symbol
858
882
  * @return {Promise<Object[]>}
859
883
  */
@@ -866,32 +890,12 @@ module.exports = (() => {
866
890
  });
867
891
  }
868
892
 
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
893
  /**
890
894
  * Creates a new transaction.
891
895
  *
892
896
  * @public
893
- * @param {Object} transaction
894
- * @returns {Promise<TransactionMutateResult>}
897
+ * @param {Schema.TransactionCreate} transaction
898
+ * @returns {Promise<Schema.TransactionMutateResult>}
895
899
  */
896
900
  createTransaction(transaction) {
897
901
  return Promise.resolve()
@@ -913,11 +917,11 @@ module.exports = (() => {
913
917
  }
914
918
 
915
919
  /**
916
- * Edits a transaction.
920
+ * Edits a transaction (e.g. change the date, price, quantity, etc).
917
921
  *
918
922
  * @public
919
- * @param {Object} transaction
920
- * @returns {Promise<TransactionMutateResult>}
923
+ * @param {Schema.Transaction} transaction
924
+ * @returns {Promise<Schema.TransactionMutateResult>}
921
925
  */
922
926
  editTransaction(transaction) {
923
927
  return Promise.resolve()
@@ -939,9 +943,10 @@ module.exports = (() => {
939
943
  * Switch the reinvestment strategy for a single transaction.
940
944
  *
941
945
  * @public
942
- * @param {Object} transaction
946
+ * @ignore
947
+ * @param {Schema.Transaction} transaction
943
948
  * @param {TransactionType} type
944
- * @returns {Promise<TransactionMutateResult>}
949
+ * @returns {Promise<Schema.TransactionMutateResult>}
945
950
  */
946
951
  switchTransaction(transaction, type) {
947
952
  return Promise.resolve()
@@ -967,13 +972,13 @@ module.exports = (() => {
967
972
  * Deletes a transaction.
968
973
  *
969
974
  * @public
970
- * @param {String} portfolio
971
- * @param {String} position
972
- * @param {Number} sequence
975
+ * @param {String} portfolio - The identifier of the portfolio which contains the targeted position.
976
+ * @param {String} position - The identifier of the targeted position.
977
+ * @param {Number} sequence - The sequence number of the transaction to delete.
973
978
  * @param {Boolean=} force
974
979
  * @param {Day=} echoStart
975
980
  * @param {Day=} echoEnd
976
- * @returns {Promise<TransactionMutateResult>}
981
+ * @returns {Promise<Schema.TransactionMutateResult>}
977
982
  */
978
983
  deleteTransaction(portfolio, position, sequence, force, echoStart, echoEnd) {
979
984
  return Promise.resolve()
@@ -1010,10 +1015,10 @@ module.exports = (() => {
1010
1015
  * Retrieves transactions for a portfolio, or a single position.
1011
1016
  *
1012
1017
  * @public
1013
- * @param {String} portfolio
1014
- * @param {String=} position
1015
- * @param {Number=} sequence
1016
- * @returns {Promise<Transaction[]>}
1018
+ * @param {String} portfolio - The identifier of the portfolio containing the desired transactions.
1019
+ * @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.
1020
+ * @param {Number=} sequence - The sequence number of the specific transaction to read. If included, both the "portfolio" and "position" parameters must be specified.
1021
+ * @returns {Promise<Schema.Transaction[]>}
1017
1022
  */
1018
1023
  readTransactions(portfolio, position, sequence) {
1019
1024
  return Promise.resolve()
@@ -1033,6 +1038,7 @@ module.exports = (() => {
1033
1038
  * for a portfolio, or a single position.
1034
1039
  *
1035
1040
  * @public
1041
+ * @ignore
1036
1042
  * @param {String} portfolio
1037
1043
  * @param {String=} position
1038
1044
  * @param {Day=} startDay
@@ -1074,6 +1080,7 @@ module.exports = (() => {
1074
1080
  * Reads a single page of formatted transactions.
1075
1081
  *
1076
1082
  * @public
1083
+ * @ignore
1077
1084
  * @param {String} portfolio
1078
1085
  * @param {String} position
1079
1086
  * @param {Number=} sequence
@@ -1113,10 +1120,35 @@ module.exports = (() => {
1113
1120
  });
1114
1121
  }
1115
1122
 
1123
+ /**
1124
+ * Retrieves end-of-day valuations for the entire portfolio (or a single position).
1125
+ *
1126
+ * @public
1127
+ * @param {String} portfolio - The identifier of the portfolio.
1128
+ * @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).
1129
+ * @returns {Promise<Schema.ValuationContainer>}
1130
+ */
1131
+ readValuations(portfolio, position) {
1132
+ return this.readPositionValuations(portfolio, position, true);
1133
+ }
1134
+
1135
+ /**
1136
+ * Retrieves the status of end-of-day valuations for all positions contained
1137
+ * within a portfolio.
1138
+ *
1139
+ * @public
1140
+ * @param {String} portfolio - The identifier of the portfolio.
1141
+ * @returns {Promise<Schema.ValuationsAvailabilityResult>}
1142
+ */
1143
+ checkValuations(portfolio) {
1144
+ return this.readPositionValuationsAvailability(portfolio);
1145
+ }
1146
+
1116
1147
  /**
1117
1148
  * Reads a wealthscope token for a specific portfolio.
1118
1149
  *
1119
1150
  * @public
1151
+ * @ignore
1120
1152
  * @param {String} portfolio
1121
1153
  * @return {Promise<String>}
1122
1154
  */
@@ -1139,6 +1171,7 @@ module.exports = (() => {
1139
1171
  * Returns all position summary definitions for a portfolio.
1140
1172
  *
1141
1173
  * @public
1174
+ * @ignore
1142
1175
  * @param {String} portfolio
1143
1176
  */
1144
1177
  readBrokerageReportAvailability(portfolio) {
@@ -1158,6 +1191,7 @@ module.exports = (() => {
1158
1191
  * Generates a URL suitable for downloading a brokerage report (as a PDF).
1159
1192
  *
1160
1193
  * @public
1194
+ * @ignore
1161
1195
  * @param {String} user
1162
1196
  * @param {String} portfolio
1163
1197
  * @param {PositionSummaryFrame} frame
@@ -1179,21 +1213,7 @@ module.exports = (() => {
1179
1213
  }
1180
1214
 
1181
1215
  /**
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.
1216
+ * Returns current version of the Portfolio Service.
1197
1217
  *
1198
1218
  * @public
1199
1219
  * @returns {Promise<Object>}
@@ -1228,6 +1248,7 @@ module.exports = (() => {
1228
1248
  * Creates and starts a new {@link PortfolioGateway} for use in the private development environment.
1229
1249
  *
1230
1250
  * @public
1251
+ * @ignore
1231
1252
  * @static
1232
1253
  * @param {JwtProvider} jwtProvider
1233
1254
  * @param {String=} product
@@ -1247,6 +1268,7 @@ module.exports = (() => {
1247
1268
  * Creates and starts a new {@link PortfolioGateway} for use in the private staging environment.
1248
1269
  *
1249
1270
  * @public
1271
+ * @ignore
1250
1272
  * @static
1251
1273
  * @param {JwtProvider} jwtProvider
1252
1274
  * @param {String=} product
@@ -1263,7 +1285,7 @@ module.exports = (() => {
1263
1285
  }
1264
1286
 
1265
1287
  /**
1266
- * Creates and starts a new {@link PortfolioGateway} for use in the private demo environment.
1288
+ * Creates and starts a new {@link PortfolioGateway} for use in the public demo environment.
1267
1289
  *
1268
1290
  * @public
1269
1291
  * @static
@@ -1304,6 +1326,7 @@ module.exports = (() => {
1304
1326
  * Creates and starts a new {@link PortfolioGateway} for use in the private admin environment.
1305
1327
  *
1306
1328
  * @public
1329
+ * @ignore
1307
1330
  * @static
1308
1331
  * @param {JwtProvider} jwtProvider
1309
1332
  * @param {String=} product
@@ -1503,24 +1526,5 @@ module.exports = (() => {
1503
1526
  return returnRef;
1504
1527
  }
1505
1528
 
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
1529
  return PortfolioGateway;
1526
1530
  })();
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.2.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.2.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
  }