Skip to content

Instantly share code, notes, and snippets.

@beevelop
Last active July 13, 2017 15:14
Show Gist options
  • Save beevelop/075981c168d84150632aa43e3cba14c7 to your computer and use it in GitHub Desktop.
Save beevelop/075981c168d84150632aa43e3cba14c7 to your computer and use it in GitHub Desktop.
Berechnung stochastischer Unternehmenswert

Hi Flo,

git clone https://gist.github.com/beevelop/075981c168d84150632aa43e3cba14c7 stocha
cd stocha
npm i

ausführen mithilfe von

node index.js 100 50 5 0.42

da purzelt dann die algo.json raus. Die kann mithilfe von Tableau analysiert werden.

'use strict'
const _ = require('lodash')
const fs = require('fs')
const winston = require('winston')
winston.remove(winston.transports.Console)
winston.add(winston.transports.Console, { 'timestamp': true })
winston.info('Starting')
let defaultUe = _.toInteger(process.argv[ 2 ]) // 100
let defaultKosten = _.toInteger(process.argv[ 3 ]) // 50
let sprungwert = _.toInteger(process.argv[ 4 ]) // 15
let p = 0.42
let gkk = 0.1 // gewogene Kapitalkosten
winston.info({ defaultUe, defaultKosten, sprungwert, p })
let history = []
let years = 10
let max = 20 * 100000
for (let i = 0; i < max; i++) {
let ue = defaultUe
let kosten = defaultKosten
let uw = 0
let cf = 0
for (let j = 1; j <= years; j++) {
let rw = Math.random()
if (rw > 1 - p) {
ue = ue + sprungwert
} else {
ue = ue - sprungwert
}
rw = Math.random()
if (rw > 1 - p) {
kosten = kosten + sprungwert
} else {
kosten = kosten - sprungwert
}
cf = ue - kosten
uw = uw + cf / Math.pow(1 + gkk, j)
}
let restwert = cf / gkk
uw = uw + restwert / Math.pow(1 + gkk, years)
history.push({ uw, ue, kosten })
}
fs.writeFileSync('algo.json', JSON.stringify(history))
winston.info('Done')
{
"name": "stocha",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "node ./index.js 100 50 5 0.42"
},
"dependencies": {
"debug": "~2.6.3",
"lodash": "^4.17.4",
"winston": "^2.3.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment