File restructuring
This commit is contained in:
parent
309cd23d4e
commit
ab9afd8697
|
@ -1,48 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
function makeFundWithInfo(name, group, existingDonations, existingPayouts) {
|
|
||||||
return /* record */[
|
|
||||||
/* group */group,
|
|
||||||
/* name */name,
|
|
||||||
/* existingDonations */existingDonations,
|
|
||||||
/* existingPayouts */existingPayouts
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
var funds = /* array */[
|
|
||||||
/* record */[
|
|
||||||
/* group : Fund */[/* ANIMAL_WELFARE */0],
|
|
||||||
/* name */"Animal Welfare Fund",
|
|
||||||
/* existingDonations */4000.0,
|
|
||||||
/* existingPayouts */10.0
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* group : Fund */[/* GLOBAL_HEALTH */1],
|
|
||||||
/* name */"Global Health Fund",
|
|
||||||
/* existingDonations */4000.0,
|
|
||||||
/* existingPayouts */10.0
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* group : Fund */[/* LONG_TERM_FUTURE */2],
|
|
||||||
/* name */"Long Term Future Fund",
|
|
||||||
/* existingDonations */4000.0,
|
|
||||||
/* existingPayouts */10.0
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* group : Fund */[/* ANIMAL_WELFARE */0],
|
|
||||||
/* name */"Meta Fund",
|
|
||||||
/* existingDonations */4000.0,
|
|
||||||
/* existingPayouts */10.0
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* group : All */0,
|
|
||||||
/* name */"All",
|
|
||||||
/* existingDonations */undefined,
|
|
||||||
/* existingPayouts */undefined
|
|
||||||
]
|
|
||||||
];
|
|
||||||
|
|
||||||
exports.makeFundWithInfo = makeFundWithInfo;
|
|
||||||
exports.funds = funds;
|
|
||||||
/* No side effect */
|
|
|
@ -1 +0,0 @@
|
||||||
/* This output is empty. Its source's type definitions, externals and/or unused code got optimized away. */
|
|
|
@ -1,21 +0,0 @@
|
||||||
// let model = EAFunds_Model.Interface.model;
|
|
||||||
// let handleChange = (handleChange, event) =>
|
|
||||||
// handleChange(ReactEvent.Form.target(event)##value);
|
|
||||||
// let model = EAFunds_Model.Interface.model;
|
|
||||||
// let initialMap = Model.toMaps(model);
|
|
||||||
// [@react.component]
|
|
||||||
// let make = () => {
|
|
||||||
// let (params, changeParams) = React.useState(() => Model.toMaps(model));
|
|
||||||
// model.inputs
|
|
||||||
// |> Array.of_list
|
|
||||||
// |> Array.map((parameter: Model.Input.parameter) => {
|
|
||||||
// let value =
|
|
||||||
// params.inputs->Model.MS.get(parameter.id)
|
|
||||||
// |> Belt.Option.flatMap(_, ((_, b)) => b);
|
|
||||||
// <>
|
|
||||||
// {parameter.name |> ReasonReact.string}
|
|
||||||
// {parameter.id |> ReasonReact.string}
|
|
||||||
// <Model.Input.Form parameter value onChange={r => Js.log(r)} />
|
|
||||||
// </>;
|
|
||||||
// });
|
|
||||||
/* }*/
|
|
|
@ -1,225 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var Block = require("bs-platform/lib/js/block.js");
|
|
||||||
var Curry = require("bs-platform/lib/js/curry.js");
|
|
||||||
var Math$ProbExample = require("../Math.bs.js");
|
|
||||||
var Prop$ProbExample = require("../Prop.bs.js");
|
|
||||||
|
|
||||||
function yearDiff(year) {
|
|
||||||
return year - 2020.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
function yearlyMeanGrowthRateIfNotClosed(group) {
|
|
||||||
return /* record */[
|
|
||||||
/* meanDiff */1.1,
|
|
||||||
/* stdDiff */1.1
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
function calculateDifference(currentValue, yearInQuestion, y) {
|
|
||||||
var yearDiff = yearInQuestion - 2020.0;
|
|
||||||
var meanDiff = Math.pow(y[/* meanDiff */0], yearDiff);
|
|
||||||
var stdDevDiff = Math.pow(y[/* meanDiff */0], yearDiff);
|
|
||||||
return Math$ProbExample.normal(currentValue * meanDiff, 0.2 * stdDevDiff);
|
|
||||||
}
|
|
||||||
|
|
||||||
function currentValue(group, output) {
|
|
||||||
if (group) {
|
|
||||||
switch (group[0]) {
|
|
||||||
case /* ANIMAL_WELFARE */0 :
|
|
||||||
if (output) {
|
|
||||||
return 2300000.0;
|
|
||||||
} else {
|
|
||||||
return 300000.0;
|
|
||||||
}
|
|
||||||
case /* GLOBAL_HEALTH */1 :
|
|
||||||
if (output) {
|
|
||||||
return 500000.0;
|
|
||||||
} else {
|
|
||||||
return 1000000.0;
|
|
||||||
}
|
|
||||||
case /* LONG_TERM_FUTURE */2 :
|
|
||||||
if (output) {
|
|
||||||
return 120000.0;
|
|
||||||
} else {
|
|
||||||
return 600000.0;
|
|
||||||
}
|
|
||||||
case /* META */3 :
|
|
||||||
if (output) {
|
|
||||||
return 830000.0;
|
|
||||||
} else {
|
|
||||||
return 9300000.0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return currentValue(/* Fund */[/* ANIMAL_WELFARE */0], output) + currentValue(/* Fund */[/* GLOBAL_HEALTH */1], output) + currentValue(/* Fund */[/* LONG_TERM_FUTURE */2], output) + currentValue(/* Fund */[/* META */3], output);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var PayoutsIfAround = {
|
|
||||||
currentYear: 2020,
|
|
||||||
firstYearStdDev: 0.2,
|
|
||||||
yearDiff: yearDiff,
|
|
||||||
yearlyMeanGrowthRateIfNotClosed: yearlyMeanGrowthRateIfNotClosed,
|
|
||||||
calculateDifference: calculateDifference,
|
|
||||||
currentValue: currentValue
|
|
||||||
};
|
|
||||||
|
|
||||||
function go(group, year, output) {
|
|
||||||
return /* FloatCdf */Block.__(2, [calculateDifference(currentValue(group, output), year, /* record */[
|
|
||||||
/* meanDiff */1.1,
|
|
||||||
/* stdDiff */1.1
|
|
||||||
])]);
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertChoice(s) {
|
|
||||||
switch (s) {
|
|
||||||
case "animal" :
|
|
||||||
return /* Fund */[/* ANIMAL_WELFARE */0];
|
|
||||||
case "globalHealth" :
|
|
||||||
return /* Fund */[/* GLOBAL_HEALTH */1];
|
|
||||||
case "longTerm" :
|
|
||||||
return /* Fund */[/* LONG_TERM_FUTURE */2];
|
|
||||||
case "meta" :
|
|
||||||
return /* Fund */[/* META */3];
|
|
||||||
default:
|
|
||||||
return /* All */0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function convertOutput(s) {
|
|
||||||
if (s === "donations") {
|
|
||||||
return /* DONATIONS */0;
|
|
||||||
} else {
|
|
||||||
return /* PAYOUTS */1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(p) {
|
|
||||||
var partial_arg = p[/* inputValues */1];
|
|
||||||
var partial_arg$1 = Prop$ProbExample.ValueMap.get;
|
|
||||||
var get = function (param) {
|
|
||||||
return partial_arg$1(partial_arg, param);
|
|
||||||
};
|
|
||||||
var match = Curry._1(get, "Fund");
|
|
||||||
var match$1 = Curry._1(get, "Year");
|
|
||||||
var match$2 = Curry._1(get, "Output");
|
|
||||||
if (match !== undefined) {
|
|
||||||
var match$3 = match;
|
|
||||||
switch (match$3.tag | 0) {
|
|
||||||
case /* SelectSingle */0 :
|
|
||||||
if (match$1 !== undefined) {
|
|
||||||
var match$4 = match$1;
|
|
||||||
switch (match$4.tag | 0) {
|
|
||||||
case /* FloatPoint */1 :
|
|
||||||
if (match$2 !== undefined) {
|
|
||||||
var match$5 = match$2;
|
|
||||||
switch (match$5.tag | 0) {
|
|
||||||
case /* SelectSingle */0 :
|
|
||||||
return go(convertChoice(match$3[0]), match$4[0], convertOutput(match$5[0]));
|
|
||||||
case /* FloatPoint */1 :
|
|
||||||
case /* FloatCdf */2 :
|
|
||||||
return ;
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
case /* SelectSingle */0 :
|
|
||||||
case /* FloatCdf */2 :
|
|
||||||
return ;
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
case /* FloatPoint */1 :
|
|
||||||
case /* FloatCdf */2 :
|
|
||||||
return ;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var model_002 = /* inputTypes : array */[
|
|
||||||
Prop$ProbExample.TypeWithMetadata.make("Fund", /* SelectSingle */Block.__(0, [/* record */[
|
|
||||||
/* options : :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"animal",
|
|
||||||
/* name */"Animal Welfare Fund"
|
|
||||||
],
|
|
||||||
/* :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"globalHealth",
|
|
||||||
/* name */"Global Health Fund"
|
|
||||||
],
|
|
||||||
/* :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"longTerm",
|
|
||||||
/* name */"Long Term Future Fund"
|
|
||||||
],
|
|
||||||
/* :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"longterm",
|
|
||||||
/* name */"Meta Fund"
|
|
||||||
],
|
|
||||||
/* :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"all",
|
|
||||||
/* name */"All"
|
|
||||||
],
|
|
||||||
/* [] */0
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* default */"total"
|
|
||||||
]]), undefined, undefined, undefined, /* () */0),
|
|
||||||
Prop$ProbExample.TypeWithMetadata.make("Year", /* Year */Block.__(2, [/* record */[
|
|
||||||
/* default */2030.0,
|
|
||||||
/* min */2020.0,
|
|
||||||
/* max */2050.0
|
|
||||||
]]), undefined, undefined, undefined, /* () */0),
|
|
||||||
Prop$ProbExample.TypeWithMetadata.currentYear,
|
|
||||||
Prop$ProbExample.TypeWithMetadata.make("Output", /* SelectSingle */Block.__(0, [/* record */[
|
|
||||||
/* options : :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"donations",
|
|
||||||
/* name */"Donations"
|
|
||||||
],
|
|
||||||
/* :: */[
|
|
||||||
/* record */[
|
|
||||||
/* id */"funding",
|
|
||||||
/* name */"Funding"
|
|
||||||
],
|
|
||||||
/* [] */0
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* default */"Output"
|
|
||||||
]]), undefined, undefined, undefined, /* () */0)
|
|
||||||
];
|
|
||||||
|
|
||||||
var model_003 = /* outputTypes : array */[];
|
|
||||||
|
|
||||||
var model = /* record */[
|
|
||||||
/* name */"Calculate the payments and payouts of EA Funds based on existing data.",
|
|
||||||
/* author */"George Harrison",
|
|
||||||
model_002,
|
|
||||||
model_003,
|
|
||||||
/* run */run
|
|
||||||
];
|
|
||||||
|
|
||||||
var Interface = {
|
|
||||||
convertChoice: convertChoice,
|
|
||||||
convertOutput: convertOutput,
|
|
||||||
run: run,
|
|
||||||
model: model
|
|
||||||
};
|
|
||||||
|
|
||||||
exports.PayoutsIfAround = PayoutsIfAround;
|
|
||||||
exports.go = go;
|
|
||||||
exports.Interface = Interface;
|
|
||||||
/* model Not a pure module */
|
|
|
@ -26,7 +26,8 @@ type otherSettings = {currentYear: int};
|
||||||
|
|
||||||
let sharesOutstanding = (price, marketCap) =>
|
let sharesOutstanding = (price, marketCap) =>
|
||||||
switch (price, marketCap) {
|
switch (price, marketCap) {
|
||||||
| (Some(price), Some(marketCap)) => Some(Math.divide(marketCap, price))
|
| (Some(price), Some(marketCap)) =>
|
||||||
|
Some(FloatCdf.divide(marketCap, price))
|
||||||
| _ => None
|
| _ => None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,11 +42,11 @@ let rec run =
|
||||||
| (SHARE_PRICE, year, Some(price), _) when year > 2019 && year < 2030 =>
|
| (SHARE_PRICE, year, Some(price), _) when year > 2019 && year < 2030 =>
|
||||||
let diffYears = year - otherSettings.currentYear;
|
let diffYears = year - otherSettings.currentYear;
|
||||||
let diffPerYear = 0.1;
|
let diffPerYear = 0.1;
|
||||||
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
|
Some(FloatCdf.normal(price, float_of_int(diffYears) *. diffPerYear));
|
||||||
| (MARKET_CAP, year, _, Some(price)) when year > 2019 && year < 2030 =>
|
| (MARKET_CAP, year, _, Some(price)) when year > 2019 && year < 2030 =>
|
||||||
let diffYears = year - otherSettings.currentYear;
|
let diffYears = year - otherSettings.currentYear;
|
||||||
let diffPerYear = 0.1;
|
let diffPerYear = 0.1;
|
||||||
Some(Math.normal(price, float_of_int(diffYears) *. diffPerYear));
|
Some(FloatCdf.normal(price, float_of_int(diffYears) *. diffPerYear));
|
||||||
| (SHARES_OUTSTANDING, year, _, _) when year > 2019 && year < 2030 =>
|
| (SHARES_OUTSTANDING, year, _, _) when year > 2019 && year < 2030 =>
|
||||||
let price = run(company, year, SHARE_PRICE, otherSettings);
|
let price = run(company, year, SHARE_PRICE, otherSettings);
|
||||||
let marketCap = run(company, year, MARKET_CAP, otherSettings);
|
let marketCap = run(company, year, MARKET_CAP, otherSettings);
|
|
@ -2,8 +2,8 @@
|
||||||
|
|
||||||
var React = require("react");
|
var React = require("react");
|
||||||
var ReactDOMRe = require("reason-react/src/ReactDOMRe.js");
|
var ReactDOMRe = require("reason-react/src/ReactDOMRe.js");
|
||||||
var Prop$ProbExample = require("./Prop.bs.js");
|
var Prop$ProbExample = require("./lib/Prop.bs.js");
|
||||||
var EAFunds_Model$ProbExample = require("./EAFunds/EAFunds_Model.bs.js");
|
var EAFunds_Model$ProbExample = require("./Models/EAFunds/EAFunds_Model.bs.js");
|
||||||
|
|
||||||
((import('./styles/index.css')));
|
((import('./styles/index.css')));
|
||||||
|
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
function normal(mean, std) {
|
|
||||||
var nMean = mean.toPrecision(4);
|
|
||||||
var nStd = std.toPrecision(2);
|
|
||||||
return "normal(" + (String(nMean) + (", " + (String(nStd) + ")")));
|
|
||||||
}
|
|
||||||
|
|
||||||
function divide(str1, str2) {
|
|
||||||
return "" + (String(str1) + ("/" + (String(str2) + "")));
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.normal = normal;
|
|
||||||
exports.divide = divide;
|
|
||||||
/* No side effect */
|
|
182
src/Modell.re
182
src/Modell.re
|
@ -1,182 +0,0 @@
|
||||||
module InputTypes = {
|
|
||||||
type t =
|
|
||||||
| Year(float)
|
|
||||||
| SingleChoice(string)
|
|
||||||
| FloatPoint(float)
|
|
||||||
| FloatCdf(string);
|
|
||||||
|
|
||||||
type withName = (string, t);
|
|
||||||
let withoutName = ((_, t): withName) => t;
|
|
||||||
type withNames = list(withName);
|
|
||||||
let getName = (r: withNames, name) =>
|
|
||||||
r->Belt.List.getBy(((n, _)) => n == name);
|
|
||||||
let to_string = (t: t) => {
|
|
||||||
switch (t) {
|
|
||||||
| SingleChoice(r) => r
|
|
||||||
| FloatCdf(r) => r
|
|
||||||
| Year(r) => r |> Js.Float.toFixed
|
|
||||||
| FloatPoint(r) => r |> Js.Float.toFixed
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module IOTypes = {
|
|
||||||
type singleChoice = {
|
|
||||||
options: list((string, string)),
|
|
||||||
default: option(string),
|
|
||||||
};
|
|
||||||
type floatPoint = {validatations: list(float => bool)};
|
|
||||||
type withDefaultMinMax('a) = {
|
|
||||||
default: option('a),
|
|
||||||
min: option('a),
|
|
||||||
max: option('a),
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module Input = {
|
|
||||||
type parameterType =
|
|
||||||
| Year(IOTypes.withDefaultMinMax(float))
|
|
||||||
| SingleChoice(IOTypes.singleChoice)
|
|
||||||
| FloatPoint;
|
|
||||||
|
|
||||||
let toInput = (p: parameterType) =>
|
|
||||||
switch (p) {
|
|
||||||
| Year(r) => r.default->Belt.Option.map(p => InputTypes.Year(p))
|
|
||||||
| SingleChoice(r) =>
|
|
||||||
r.default->Belt.Option.map(p => InputTypes.SingleChoice(p))
|
|
||||||
| FloatPoint => None
|
|
||||||
};
|
|
||||||
|
|
||||||
type parameter = {
|
|
||||||
id: string,
|
|
||||||
name: string,
|
|
||||||
parameterType,
|
|
||||||
};
|
|
||||||
|
|
||||||
let currentYear = {
|
|
||||||
id: "currentyear",
|
|
||||||
name: "Current Year",
|
|
||||||
parameterType: FloatPoint,
|
|
||||||
};
|
|
||||||
|
|
||||||
let make = (~name, ~parameterType, ~id=name, ()) => {
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parameterType,
|
|
||||||
};
|
|
||||||
|
|
||||||
module Form = {
|
|
||||||
let handleChange = (handleChange, event) =>
|
|
||||||
handleChange(ReactEvent.Form.target(event)##value);
|
|
||||||
[@react.component]
|
|
||||||
let make =
|
|
||||||
(~parameter: parameter, ~value: option(InputTypes.t), ~onChange) => {
|
|
||||||
switch (parameter.parameterType, value) {
|
|
||||||
| (Year(_), Some(Year(r))) =>
|
|
||||||
<input
|
|
||||||
type_="number"
|
|
||||||
value={r |> Js.Float.toString}
|
|
||||||
onChange={handleChange(r =>
|
|
||||||
switch (Js.Float.fromString(r)) {
|
|
||||||
| r => onChange(_ => Some(InputTypes.Year(r)))
|
|
||||||
}
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
| (FloatPoint, Some(FloatPoint(r))) =>
|
|
||||||
<input type_="number" value={r |> Js.Float.toString} />
|
|
||||||
| (Year(_), _)
|
|
||||||
| (FloatPoint, _) => <input type_="number" value="" />
|
|
||||||
| (SingleChoice(_), _) =>
|
|
||||||
<div> {"Single Choice" |> ReasonReact.string} </div>
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
module Output = {
|
|
||||||
type parameterType =
|
|
||||||
| Year
|
|
||||||
| SingleChoice(IOTypes.singleChoice)
|
|
||||||
| FloatPoint
|
|
||||||
| FloatCdf;
|
|
||||||
|
|
||||||
type parameter = {
|
|
||||||
id: string,
|
|
||||||
name: string,
|
|
||||||
parameterType,
|
|
||||||
};
|
|
||||||
|
|
||||||
type outputConfig =
|
|
||||||
| Single;
|
|
||||||
|
|
||||||
let make = (~name, ~parameterType, ~id=name, ()) => {
|
|
||||||
id,
|
|
||||||
name,
|
|
||||||
parameterType,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
type model = {
|
|
||||||
name: string,
|
|
||||||
author: string,
|
|
||||||
assumptions: list(Input.parameter),
|
|
||||||
inputs: list(Input.parameter),
|
|
||||||
outputs: list(Output.parameter),
|
|
||||||
outputConfig: Output.outputConfig,
|
|
||||||
};
|
|
||||||
|
|
||||||
let gatherInputs = (m: model, a: list(InputTypes.withName)) => {
|
|
||||||
let getItem = (p: Input.parameter) => InputTypes.getName(a, p.id);
|
|
||||||
[
|
|
||||||
m.assumptions |> List.map(getItem),
|
|
||||||
m.inputs |> List.map(getItem),
|
|
||||||
[InputTypes.getName(a, "output")],
|
|
||||||
]
|
|
||||||
|> List.flatten;
|
|
||||||
};
|
|
||||||
|
|
||||||
module MS = Belt.Map.String;
|
|
||||||
|
|
||||||
type modelMaps = {
|
|
||||||
assumptions: MS.t((Input.parameter, option(InputTypes.t))),
|
|
||||||
inputs: MS.t((Input.parameter, option(InputTypes.t))),
|
|
||||||
output: (Output.parameter, option(InputTypes.t)),
|
|
||||||
};
|
|
||||||
|
|
||||||
let toMaps = (m: model): modelMaps => {
|
|
||||||
assumptions:
|
|
||||||
MS.fromArray(
|
|
||||||
m.assumptions
|
|
||||||
|> List.map((r: Input.parameter) =>
|
|
||||||
(r.id, (r, Input.toInput(r.parameterType)))
|
|
||||||
)
|
|
||||||
|> Array.of_list,
|
|
||||||
),
|
|
||||||
inputs:
|
|
||||||
MS.fromArray(
|
|
||||||
m.inputs
|
|
||||||
|> List.map((r: Input.parameter) =>
|
|
||||||
(r.id, (r, Input.toInput(r.parameterType)))
|
|
||||||
)
|
|
||||||
|> Array.of_list,
|
|
||||||
),
|
|
||||||
output: (Output.make(~name="Payouts", ~parameterType=FloatCdf, ()), None),
|
|
||||||
};
|
|
||||||
|
|
||||||
type modelParams = {
|
|
||||||
assumptions: list(option(InputTypes.t)),
|
|
||||||
inputs: list(option(InputTypes.t)),
|
|
||||||
output: option(InputTypes.t),
|
|
||||||
};
|
|
||||||
|
|
||||||
let response = (m: model, a: list(InputTypes.withName)) => {
|
|
||||||
let getItem = (p: Input.parameter) =>
|
|
||||||
InputTypes.getName(a, p.id)->Belt.Option.map(InputTypes.withoutName);
|
|
||||||
{
|
|
||||||
assumptions: m.assumptions |> List.map(getItem),
|
|
||||||
inputs: m.inputs |> List.map(getItem),
|
|
||||||
output:
|
|
||||||
InputTypes.getName(a, "output")
|
|
||||||
->Belt.Option.map(InputTypes.withoutName),
|
|
||||||
};
|
|
||||||
};
|
|
|
@ -19,7 +19,7 @@ module PayoutsIfAround = {
|
||||||
let yearDiff = yearDiff(yearInQuestion);
|
let yearDiff = yearDiff(yearInQuestion);
|
||||||
let meanDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
|
let meanDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
|
||||||
let stdDevDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
|
let stdDevDiff = Js.Math.pow_float(~base=y.meanDiff, ~exp=yearDiff);
|
||||||
Math.normal(currentValue *. meanDiff, firstYearStdDev *. stdDevDiff);
|
FloatCdf.normal(currentValue *. meanDiff, firstYearStdDev *. stdDevDiff);
|
||||||
};
|
};
|
||||||
|
|
||||||
let rec currentValue = (group: group, output) => {
|
let rec currentValue = (group: group, output) => {
|
|
@ -1,63 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var Block = require("bs-platform/lib/js/block.js");
|
|
||||||
|
|
||||||
function foo(joint) {
|
|
||||||
return /* array */[
|
|
||||||
/* record */[
|
|
||||||
/* statements : array */[
|
|
||||||
/* record */[
|
|
||||||
/* statement : Senate */Block.__(0, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [true])
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statement : House */Block.__(1, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [true])
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* probability */0.2
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statements : array */[
|
|
||||||
/* record */[
|
|
||||||
/* statement : Senate */Block.__(0, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [true])
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statement : House */Block.__(1, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [false])
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* probability */0.2
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statements : array */[
|
|
||||||
/* record */[
|
|
||||||
/* statement : Senate */Block.__(0, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [false])
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statement : House */Block.__(1, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [true])
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* probability */0.5
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statements : array */[
|
|
||||||
/* record */[
|
|
||||||
/* statement : Senate */Block.__(0, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [false])
|
|
||||||
],
|
|
||||||
/* record */[
|
|
||||||
/* statement : House */Block.__(1, [/* DEMOCRAT_VICTORY */0]),
|
|
||||||
/* outcome : Bool */Block.__(0, [false])
|
|
||||||
]
|
|
||||||
],
|
|
||||||
/* probability */0.1
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.foo = foo;
|
|
||||||
/* No side effect */
|
|
|
@ -1,59 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
|
|
||||||
function normal(mean, std) {
|
|
||||||
var nMean = mean.toString();
|
|
||||||
var nStd = std.toString();
|
|
||||||
return "normal(" + (String(nMean) + (", " + (String(nStd) + ")")));
|
|
||||||
}
|
|
||||||
|
|
||||||
function divide(str1, str2) {
|
|
||||||
return "" + (String(str1) + ("/" + (String(str2) + "")));
|
|
||||||
}
|
|
||||||
|
|
||||||
var $$Math = {
|
|
||||||
normal: normal,
|
|
||||||
divide: divide
|
|
||||||
};
|
|
||||||
|
|
||||||
function sharesOutstanding(price, marketCap) {
|
|
||||||
if (price !== undefined && marketCap !== undefined) {
|
|
||||||
return divide(marketCap, price);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function run(company, year, param, otherSettings) {
|
|
||||||
var match = company[/* currentPrice */1];
|
|
||||||
var match$1 = company[/* marketCap */2];
|
|
||||||
switch (param) {
|
|
||||||
case /* SHARE_PRICE */0 :
|
|
||||||
if (match !== undefined && year > 2019 && year < 2030) {
|
|
||||||
var diffYears = year - otherSettings[/* currentYear */0] | 0;
|
|
||||||
return normal(match, diffYears * 0.1);
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
case /* SHARES_OUTSTANDING */1 :
|
|
||||||
if (year > 2019 && year < 2030) {
|
|
||||||
var price = run(company, year, /* SHARE_PRICE */0, otherSettings);
|
|
||||||
var marketCap = run(company, year, /* MARKET_CAP */2, otherSettings);
|
|
||||||
return sharesOutstanding(price, marketCap);
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
case /* MARKET_CAP */2 :
|
|
||||||
if (match$1 !== undefined && year > 2019 && year < 2030) {
|
|
||||||
var diffYears$1 = year - otherSettings[/* currentYear */0] | 0;
|
|
||||||
return normal(match$1, diffYears$1 * 0.1);
|
|
||||||
} else {
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.$$Math = $$Math;
|
|
||||||
exports.sharesOutstanding = sharesOutstanding;
|
|
||||||
exports.run = run;
|
|
||||||
/* No side effect */
|
|
Loading…
Reference in New Issue
Block a user