{ "Version" : 2.2, "CaseName" : "Portfolio.minion", "DefaultUnitSet" : "SI", "RootModel" : { "DiagramNotes" : "y", "DiagramY" : -12321, "diagramY" : 13.88198757763975, "Objects" : [ { "DiagramNotes" : "y", "DiagramY" : 15, "DiagramX" : 20, "Type" : "Expression", "Notes" : "Used to force the portfolio to get new values", "Formula" : { "Formula" : "\" \"" }, "name" : "RefreshPortfolio" }, { "DiagramNotes" : "y", "DiagramY" : 15, "Objects" : [ { "DiagramY" : -110, "DiagramX" : 105, "Type" : "Expression", "Notes" : "The column names for the quoteTable", "Formula" : { "Formula" : "{cc \"Symbol\", \"Name\", \"Date\",\"Price\", \"Divident\", \"P/E\"}" }, "name" : "headers", "HideInfo" : "n" }, { "Formula" : { "Formula" : "{replace \"\n$\", \"\",\n\t{replace \"., \", \"\"\n\t\t{wget \"http://finance.yahoo.com/d/quotes.csv?s=\" +\n\t\t\"CADUSD=X\" + \n\t\t\"&f=snd1l1\"}\n\t}\n} + refresh" }, "Type" : "Expression", "DiagramY" : -80, "name" : "YahooUSD", "Notes" : "Being Canadian, I have included some Canadian stocks and the mechanism to convert everything into Canadian dollars. This might possibly be translated for other countries or discarded if only US stocks are of interest.\n\nThis expression retrieves the current US to Canadian dollar conversion rate from Yahoo.", "DiagramX" : 105 }, { "Formula" : { "Formula" : "{replace \"\n$\", \"\",\n\t{replace \"., \", \"\"\n\t\t{wget \"http://finance.yahoo.com/d/quotes.csv?s=\" +\n\t\t{join stocks[0,2], \"+\"} + \n\t\t\"&f=snd1l1yr\"}\n\t}\n} + refresh" }, "Type" : "Expression", "DiagramY" : -50, "name" : "yahoo", "Notes" : "This expression creates the appropriate request from the Stocks table to get quotes from Yahoo.\n\nThe results are returned in comma separated value (CSV) form.", "DiagramX" : 105 }, { "Formula" : { "Formula" : "stocks[0,\"Units\"] * quoteTable[0, \"Price\"] /\nDollarConv\n" }, "Type" : "Expression", "DiagramY" : 0, "name" : "MktValue", "Notes" : "The current market value of each stock holding is calculated by multiplying the number of stocks held by the current price.", "DiagramX" : 165 }, { "Formula" : { "Formula" : "mktValue - Stocks[0,\"Cost\"]" }, "Type" : "Expression", "DiagramY" : 85, "name" : "Gain", "Notes" : "The gain or loss for each stock holding is calculated by subtracting its cost from the current value.", "DiagramX" : 115 }, { "Formula" : { "Formula" : "\"table,en\n\" + {join headers, \",\"} +\"\nstring,string,string,fraction,fraction,fraction\n\" + yahoo" }, "Type" : "Expression", "DiagramY" : -110, "name" : "csv", "Notes" : "Here three lines of setup information are added to the Yahoo CSV to produce a string in the format Math Minion expects when pasting CSV information into it to create a table.", "DiagramX" : 195 }, { "Formula" : { "Formula" : "{table \"table,en\n\" + {join headers[1:4], \",\"} +\"\nstring,string,string,fraction\n\" + YahooUSD\n}" }, "Type" : "Expression", "DiagramY" : -80, "name" : "USD", "Notes" : "The table function is used with the headers and returned Canadian dollar value to create a single row table.", "DiagramX" : 195 }, { "Formula" : { "Formula" : "{if {eq stocks[0,\"country\"], \"U\"}, usd[0,\"Price\"], 1} " }, "Type" : "Expression", "DiagramY" : -45, "name" : "DollarConv", "Notes" : "The country designator in the Stocks table is used with the retrieved dollar value to create an appropriate conversion factor for each row of the Stocks table.", "DiagramX" : 190 }, { "Formula" : { "Formula" : "{table csv} " }, "Type" : "Expression", "DiagramY" : -50, "name" : "quoteTable", "Notes" : "In addition to its normal use, the table function will accept a single string in the CSV format Math Minion expects for pasting. It is used here to create the quote table.", "DiagramX" : 270 }, { "Formula" : { "Formula" : "{append stocks[0,1:4],\n\t{table {cc \"Price\", \"MktValue\", \"Gain\"},\n\t\tquoteTable[0, \"price\"],\n\t\tmktValue,\n\t\tgain\n\t}\n}" }, "Type" : "Expression", "DiagramY" : 60, "name" : "CurrentStocks", "Notes" : "A table of stock information is constructed, including its current value and gain or loss.", "DiagramX" : 210 }, { "Formula" : { "Formula" : "{sumcols CurrentStocks}" }, "Type" : "Expression", "DiagramY" : 70, "name" : "Sums", "Notes" : "All the columns of the CurrentStocks table are summed.", "DiagramX" : 295 }, { "isOutput" : "y", "DiagramY" : 100, "DiagramX" : 295, "Type" : "Expression", "Notes" : "Just the total market value is extracted and made an output for the model.", "Formula" : { "Formula" : "sums.mktvalue" }, "name" : "Total" }, { "DiagramNotes" : "y", "DiagramY" : -60, "DiagramX" : 10, "isInput" : "y", "Type" : "Expression", "Notes" : "This should resolve to a string value that is simply a blank. It is added to the end of the wget results so that refreshing its value will cause the wget calls to be made again, thus getting new values.", "Formula" : { "Formula" : "RefreshPortfolio" }, "name" : "Refresh" }, { "Formula" : { "Formula" : "{sumcols\n\t{select currentstocks\n\t\t{eq stocks.country \"C\"}\n\t}[0,\"MktValue\"]\n}" }, "Type" : "Expression", "DiagramY" : 10, "name" : "CdnStockSum", "Notes" : "Just the Canadian stocks are selected from the CurrentStocks table and their values are summed.", "DiagramX" : 295 }, { "Formula" : { "Formula" : "{sumcols\n\t{select currentstocks\n\t\t{eq stocks.country \"U\"}\n\t}\n}[0,\"MktValue\"]" }, "Type" : "Expression", "DiagramY" : 40, "name" : "USStockSum", "Notes" : "Just the US stocks are selected from the CurrentStocks table and their values are summed.", "DiagramX" : 295 }, { "DiagramNotes" : "y", "DiagramY" : 30, "DiagramX" : 10, "Type" : "Data Table", "Columns" : [ { "name" : "Name", "sValues" : [ "Apple", "Applied Materials", "Coca-Cola", "DuPont", "Duke Energy", "Express Scripts Holding", "IBM Corp.", "Intel", "Johnson & Johnson", "Microsoft", "BCE Inc.", "Royal Bank of Canada" ], "defaultValue" : "\"\"" }, { "name" : "Symbol", "sValues" : [ "AAPL", "AMAT", "KO", "DD", "DUK", "ESRX", "IBM", "INTC", "JNJ", "MSFT", "BCE.TO", "RY.TO" ], "defaultValue" : "\"\"" }, { "displayUnit" : "Fraction", "unitDimensions" : "0 0 0 0 0 0 0", "defaultValue" : "0 fraction", "name" : "Units", "nValues" : [ 100, 200, 216, 40, 30, 45, 20, 160, 150, 300, 400, 600 ] }, { "displayUnit" : "Fraction", "unitDimensions" : "0 0 0 0 0 0 0", "defaultValue" : "0 fraction", "name" : "Cost", "nValues" : [ 14200, 930, 7260, 1000, 3800, 25000, 2100, 13500, 10000, 9300, 13200, 4500 ] }, { "name" : "Country", "sValues" : [ "U", "U", "U", "U", "U", "U", "U", "U", "U", "U", "C", "C" ], "defaultValue" : "\"\"" } ], "Notes" : "This is a table of stock holdings. Its columns are:\n\nCompany Name\nCompany symbol (for Yahoo)\nNumber of Shares\nCost of Shares\nCountry U=US C= Canada", "name" : "Stocks" } ], "DiagramX" : 95, "Type" : "Model", "Notes" : "Contains the stocks held and the mechanism for obtaining quotes.", "diagramScale" : 1.866666666666667, "diagramX" : 0, "name" : "Portfolio", "diagramY" : 132.1428571428571 }, { "DiagramNotes" : "y", "DiagramY" : 25, "X1" : { "v" : "MktValues.date", "Y1" : { "v" : "MktValues.MktValue", "lineType" : 0 }, "unit" : "date" }, "DiagramX" : 210, "Type" : "Graph/Table", "Notes" : "A plot of MktValues by date", "name" : "PortfolioPlot" }, { "DiagramNotes" : "y", "DiagramY" : 75, "DiagramX" : 110, "Type" : "Expression", "Notes" : "Difference between current and max values", "Formula" : { "Formula" : "MktValues[ {nrows MktValues}, 2] -\n{max MktValues.MktValue}" }, "name" : "vsMax" }, { "DiagramNotes" : "y", "DiagramY" : 110, "DiagramX" : 110, "Type" : "Expression", "Notes" : "Difference between current and min values", "Formula" : { "Formula" : "MktValues[ {nrows MktValues}, 2] -\n{min MktValues.MktValue}" }, "name" : "vsMin" }, { "DiagramNotes" : "y", "DiagramY" : 55, "DiagramX" : 210, "Type" : "Expression", "Notes" : "Cascading Style Sheet (CSS) formatting for the form.", "Formula" : { "Formula" : "'\nbody {\n\tbackground-color: #EEFFEE;\n}\n\n\n/* Tables\n * --------------------------------------------------------------------- */\n\n\ttable {\n\t\tborder-top: 0px solid #ddd;\n\t\tborder-left: 0px solid #ddd;\n\t\tmargin-top: 0px;\n\t\tmargin-bottom: 0.5em;\n\t\tpadding-right: 0.5em;\n\t\tfont-size: x-large;\n\t\tfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n\t}\n\tth,td {\n\t\tborder-bottom: 0px solid #ddd;\n\t\tborder-right: 0px solid #ddd;\n\t\tvertical-align: top;\n\t\ttext-align: right;\n\t}\n\n/* Default Classes\n * --------------------------------------------------------------------- */\n\n\tp.title, a.title, div.title {\n\t\tcolor: #040;\n\t\tfont-family: \"Helvetica Neue\", Helvetica, Arial, sans-serif;\n\t\tfont-size: 2.0em;\n\t\ttext-align: center;\n\t}\n\n\tbutton {\n\t\tfont-size: large;\n\t\tmargin-left: auto;\n\t\tmargin-right: auto;\n\t}\n\n\t.center {\n\t\tmargin-left: auto;\n\t\tmargin-right: auto;\n\t\twidth:450px;\n\t\ttext-align: center;\n\t}\n\t\n\t.input {\n\t\twidth: 100%;\n\t\tfont-size: large;\n\t}\n\n\t.result {\n\t\ttext-align: center;\n\t\tfont-size: xx-large;\n\t}\n\n\t#getbutton {\n\t\twidth: 200px;\n\t}\t\n\n\t#buttonrow {\n\t\tmargin-left: auto;\n\t\tmargin-right: auto;\n\t\twidth: 450px;\n\t\ttext-align: center;\n\t}\n\n\t#loadrow {\n\t\tclear: both;\n\t\tmargin-left: auto;\n\t\tmargin-right: auto;\n\t\twidth: 300px;\n\t\ttext-align: center;\n\t}\n\n\t#plotbutton {\n\t\tmargin-left:10px;\n\t\tmargin-right: 10px;\n\t\twidth:120px;\n\t}\n\n\t#tablebutton {\n\t\tmargin-left:10px;\n\t\tmargin-right:10px;\n\t\twidth:120px;\n\t}\n\n\t.menubutton {\n\t\tmargin-top: 20px;\n\t\tmargin-right: 10px;\n\t\tmargin-left: 10px;\n\t\twidth: 120px;\n" }, "name" : "css" }, { "HideInfo" : "n", "f0" : "css", "f1" : "tablerows", "DiagramNotes" : "y", "DiagramX" : 270, "f2" : "{fmt \"$%12.0f\", vsMax}", "DiagramY" : 95, "Formula" : { "Formula" : "'\n\t
\n\t\tPortfolio
\n\t\t\n\t\t\t
Date | Value | Change |
---|
vs Max | |
vs Min |