@barchart/portfolio-client-js 10.3.1 → 10.5.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.
@@ -119,7 +119,8 @@ module.exports = (() => {
119
119
  .withVariableParameter('symbol', 'symbol', 'symbol', false);
120
120
  })
121
121
  .withQueryBuilder((qb) => {
122
- qb.withVariableParameter('day', 'day', 'day', true, x => x.format());
122
+ qb.withVariableParameter('day', 'day', 'day', true, x => x.format())
123
+ .withVariableParameter('closing', 'closing', 'closing', true, x => is.boolean(x) && x ? 'true' : x);
123
124
  })
124
125
  .withRequestInterceptor(RequestInterceptor.PLAIN_TEXT_RESPONSE)
125
126
  .withRequestInterceptor(requestInterceptor)
@@ -630,6 +631,9 @@ module.exports = (() => {
630
631
  .withLiteralParameter('accounts', 'accounts')
631
632
  .withVariableParameter('account', 'account', 'account', false);
632
633
  })
634
+ .withQueryBuilder((qb) => {
635
+ qb.withVariableParameter('openOnly', 'openOnly', 'openOnly', true);
636
+ })
633
637
  .withRequestInterceptor(requestInterceptor)
634
638
  .withResponseInterceptor(responseInterceptorForSnapTradeAccountLinkResponse)
635
639
  .withErrorInterceptor(errorInterceptor)
@@ -669,6 +673,9 @@ module.exports = (() => {
669
673
  .withLiteralParameter('accounts', 'accounts')
670
674
  .withVariableParameter('account', 'account', 'account', false);
671
675
  })
676
+ .withQueryBuilder((qb) => {
677
+ qb.withVariableParameter('openOnly', 'openOnly', 'openOnly', true);
678
+ })
672
679
  .withRequestInterceptor(requestInterceptor)
673
680
  .withResponseInterceptor(responseInterceptorForSnapTradeAccountLinkResponse)
674
681
  .withErrorInterceptor(errorInterceptor)
@@ -755,6 +762,24 @@ module.exports = (() => {
755
762
  return Gateway.invoke(this._readInstrumentEndpoint, payload);
756
763
  }
757
764
 
765
+ /**
766
+ * Resolves an instrument closing price.
767
+ *
768
+ * @public
769
+ * @async
770
+ * @param {String} symbol - The instrument symbol.
771
+ * @param {Day} day - The date the closing price is requested.
772
+ * @returns {Promise<Object>}
773
+ */
774
+ async readInstrumentClosing(symbol, day) {
775
+ checkStart.call(this);
776
+
777
+ assert.argumentIsRequired(symbol, 'symbol', String);
778
+ assert.argumentIsRequired(day, 'day', Day, 'Day');
779
+
780
+ return Gateway.invoke(this._readInstrumentEndpoint, { symbol, day, closing: true });
781
+ }
782
+
758
783
  /**
759
784
  * Creates a new portfolio for the current user.
760
785
  *
@@ -1529,15 +1554,23 @@ module.exports = (() => {
1529
1554
  * @async
1530
1555
  * @param {String} connection - The SnapTrade identifier for the brokerage connection.
1531
1556
  * @param {String} account - The SnapTrade identifier for the brokerage account.
1557
+ * @param {Boolean=} openOnly - When true, links only open positions. When false, links all positions.
1532
1558
  * @returns {Promise<Schema.SnapTradeLinkingReport>}
1533
1559
  */
1534
- async linkSnapTradeAccount(connection, account) {
1560
+ async linkSnapTradeAccount(connection, account, openOnly) {
1535
1561
  checkStart.call(this);
1536
1562
 
1537
1563
  assert.argumentIsRequired(connection, 'connection', String);
1538
1564
  assert.argumentIsRequired(account, 'account', String);
1565
+ assert.argumentIsOptional(openOnly, 'openOnly', Boolean);
1566
+
1567
+ const payload = { connection, account };
1539
1568
 
1540
- return Gateway.invoke(this._linkSnapTradeAccountEndpoint, { connection, account });
1569
+ if (is.boolean(openOnly)) {
1570
+ payload.openOnly = openOnly;
1571
+ }
1572
+
1573
+ return Gateway.invoke(this._linkSnapTradeAccountEndpoint, payload);
1541
1574
  }
1542
1575
 
1543
1576
  /**
@@ -1563,15 +1596,23 @@ module.exports = (() => {
1563
1596
  * @async
1564
1597
  * @param {String} connection - The SnapTrade identifier for the brokerage connection.
1565
1598
  * @param {String} account - The SnapTrade identifier for the brokerage account.
1599
+ * @param {Boolean=} openOnly - When true, refreshes only open positions. When false, refreshes all positions.
1566
1600
  * @returns {Promise<Schema.SnapTradeLinkingReport>}
1567
1601
  */
1568
- async refreshSnapTradeAccount(connection, account) {
1602
+ async refreshSnapTradeAccount(connection, account, openOnly) {
1569
1603
  checkStart.call(this);
1570
1604
 
1571
1605
  assert.argumentIsRequired(connection, 'connection', String);
1572
1606
  assert.argumentIsRequired(account, 'account', String);
1607
+ assert.argumentIsOptional(openOnly, 'openOnly', Boolean);
1608
+
1609
+ const payload = { connection, account };
1610
+
1611
+ if (is.boolean(openOnly)) {
1612
+ payload.openOnly = openOnly;
1613
+ }
1573
1614
 
1574
- return Gateway.invoke(this._refreshSnapTradeAccountEndpoint, { connection, account });
1615
+ return Gateway.invoke(this._refreshSnapTradeAccountEndpoint, payload);
1575
1616
  }
1576
1617
 
1577
1618
  /**
package/lib/index.js CHANGED
@@ -7,6 +7,6 @@ module.exports = (() => {
7
7
  return {
8
8
  JwtProvider: JwtProvider,
9
9
  PortfolioGateway: PortfolioGateway,
10
- version: '10.3.1'
10
+ version: '10.5.0'
11
11
  };
12
12
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@barchart/portfolio-client-js",
3
- "version": "10.3.1",
3
+ "version": "10.5.0",
4
4
  "description": "JavaScript SDK for Barchart's Portfolio Service",
5
5
  "homepage": "https://docs.barchart.com/portfolio/#/",
6
6
  "author": {
@@ -8,6 +8,13 @@
8
8
  "email": "bryan.ingle@barchart.com",
9
9
  "url": "https://www.barchart.com"
10
10
  },
11
+ "contributors": [
12
+ {
13
+ "name": "Luka Sotra",
14
+ "email": "luka.sotra@barchart.com",
15
+ "url": "https://www.barchart.com"
16
+ }
17
+ ],
11
18
  "scripts": {
12
19
  "test": "echo \"Error: Please use gulp to run tests\" && exit 1"
13
20
  },