Skip to content

Commit

Permalink
Development (#48)
Browse files Browse the repository at this point in the history
* improvements for static list

* Time filter

* remove github assets

* Updated readme

* New option: Hidden Stock

* Update README.md

Co-authored-by: Jan Litzenburger <[email protected]>
  • Loading branch information
jalibu and Jan Litzenburger authored Aug 13, 2022
1 parent 7a828b7 commit 1cc458d
Show file tree
Hide file tree
Showing 14 changed files with 116 additions and 111 deletions.
4 changes: 2 additions & 2 deletions MMM-Jast.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ Static
showChangePercent: true,
showChangeValue: false,
showChangeValueCurrency: false,
showHiddenStocks: false,
showLastUpdate: false,
showPortfolioValue: false,
showPortfolioGrowthPercent: false,
Expand All @@ -78,7 +79,7 @@ Static
stocks: [
{ name: "BASF", symbol: "BAS.DE", quantity: 10 },
{ name: "SAP", symbol: "SAP.DE", quantity: 15 },
{ name: "Henkel", symbol: "HEN3.DE" },
{ name: "Henkel", symbol: "HEN3.DE", hidden: true },
{ name: "Alibaba", symbol: "BABA"}
]
}
Expand All @@ -103,6 +104,7 @@ Static
| `showChangePercent` | Show stocks change against last close in percent. <br><br>**Type:** `Boolean`<br> **Default value:** `true` |
| `showChangeValue` | Show stocks change against last close in absolute value. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
| `showChangeValueCurrency` | Show currency for change value. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
| `showHiddenStocks` | Ignore the hidden property for each stock. This can be useful when you use the same set of stocks with multiple module instances. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
| `showLastUpdate` | Show when the data was updated. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
| `showPortfolioGrowth` | Show portfolio value growth summary. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
| `showPortfolioGrowthPercent` | Show portfolio value growth summary in percent. <br><br>**Type:** `Boolean`<br> **Default value:** `false` |
Expand All @@ -118,6 +120,7 @@ Static
| ---------- | ---------------------------------------------------------------------------------------------------------- |
| `symbol` | Stock's symbol/key <br><br>**Type:** `String` <br> **Example value:** `"SAP.DE"` |
| `name` | Optional: Stock's display name <br><br>**Type:** `String` <br> **Example value:** `"SAP"` |
| `hidden` | Optional: If set to true, this stock is not shown in the ticker but it is still used for portfolio calculation. <br><br>**Type:** `Boolean` <br> **Default value:** `false` |
| `quantity` | Optional: To calculate portfolio value and growth <br><br>**Type:** `Number` <br> **Example value:** `500` |

### Where the hack do I get the symbol for my favorite stocks?!
Expand Down
6 changes: 3 additions & 3 deletions node_helper.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mmm-jast",
"version": "2.7.0",
"version": "2.8.0",
"description": "A minimalistic stock ticker based on Yahoo's finance API for the MagicMirror² platform.",
"main": "MMM-Jast.js",
"repository": {
Expand Down
5 changes: 3 additions & 2 deletions src/backend/Backend.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ module.exports = NodeHelper.create({
},

async socketNotificationReceived(notification, payload) {
if (notification === 'JAST_STOCKS_REQUEST') {
if (notification.includes('JAST_STOCKS_REQUEST')) {
const identifier = notification.substring('JAST_STOCKS_REQUEST'.length + 1)
let stocks = await JastBackendUtils.requestStocks(payload)

stocks = stocks.filter((stock) =>
Expand All @@ -39,7 +40,7 @@ module.exports = NodeHelper.create({
stocks
}

this.sendSocketNotification('JAST_STOCKS_RESPONSE', response)
this.sendSocketNotification(`JAST_STOCKS_RESPONSE-${identifier}`, response)
} else {
Log.warn(`${notification} is invalid notification`)
}
Expand Down
3 changes: 2 additions & 1 deletion src/backend/JastBackendUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ export default class JastBackendUtils {
const meta = {
symbol: config.stocks[index].symbol,
name: config.stocks[index].name,
quantity: config.stocks[index].quantity
quantity: config.stocks[index].quantity,
hidden: config.stocks[index].hidden
}
// Manually convert GBp to GBP
if (response.price.currency === 'GBp') {
Expand Down
Loading

0 comments on commit 1cc458d

Please sign in to comment.