Tempered the affect that stock market txs have on stock forecasts

This commit is contained in:
danielyxie 2019-05-20 14:00:20 -07:00 committed by danielyxie
parent 99688b78c7
commit d7f3ab9177
5 changed files with 73 additions and 75 deletions

File diff suppressed because one or more lines are too long

@ -202,7 +202,7 @@ export function stockMarketCycle() {
if (stock.b) { thresh = 0.4; } if (stock.b) { thresh = 0.4; }
if (Math.random() < thresh) { if (Math.random() < thresh) {
stock.b = !stock.b; stock.b = !stock.b;
if (stock.otlkMag < 8) { stock.otlkMag += 0.1; } if (stock.otlkMag < 5) { stock.otlkMag += 0.1; }
} }
} }
} }

@ -3,7 +3,7 @@ import { PositionTypes } from "./data/PositionTypes";
import { CONSTANTS } from "../Constants"; import { CONSTANTS } from "../Constants";
// Amount by which a stock's forecast changes during each price movement // Amount by which a stock's forecast changes during each price movement
export const forecastChangePerPriceMovement = 0.01; export const forecastChangePerPriceMovement = 0.005;
/** /**
* Given a stock, calculates the amount by which the stock price is multiplied * Given a stock, calculates the amount by which the stock price is multiplied
@ -171,9 +171,8 @@ export function processBuyTransactionPriceMovement(stock: Stock, shares: number,
// Forecast always decreases in magnitude // Forecast always decreases in magnitude
const forecastChange = Math.min(5, forecastChangePerPriceMovement * (numIterations - 1)); const forecastChange = Math.min(5, forecastChangePerPriceMovement * (numIterations - 1));
stock.otlkMag -= forecastChange; if (stock.otlkMag > 10) {
if (stock.otlkMag < 0.1) { stock.otlkMag -= forecastChange;
stock.otlkMag = 0.1;
} }
} }
@ -323,9 +322,8 @@ export function processSellTransactionPriceMovement(stock: Stock, shares: number
// Forecast always decreases in magnitude // Forecast always decreases in magnitude
const forecastChange = Math.min(5, forecastChangePerPriceMovement * (numIterations - 1)); const forecastChange = Math.min(5, forecastChangePerPriceMovement * (numIterations - 1));
stock.otlkMag -= forecastChange; if (stock.otlkMag > 10) {
if (stock.otlkMag < 0.1) { stock.otlkMag -= forecastChange;
stock.otlkMag = 0.1;
} }
} }

@ -33,8 +33,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.AevumECorp], symbol: StockSymbols[LocationName.AevumECorp],
}, },
@ -59,8 +59,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.Sector12MegaCorp], symbol: StockSymbols[LocationName.Sector12MegaCorp],
}, },
@ -85,8 +85,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.Sector12BladeIndustries], symbol: StockSymbols[LocationName.Sector12BladeIndustries],
}, },
@ -111,8 +111,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.AevumClarkeIncorporated], symbol: StockSymbols[LocationName.AevumClarkeIncorporated],
}, },
@ -137,8 +137,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.VolhavenOmniTekIncorporated], symbol: StockSymbols[LocationName.VolhavenOmniTekIncorporated],
}, },
@ -163,8 +163,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.Sector12FourSigma], symbol: StockSymbols[LocationName.Sector12FourSigma],
}, },
@ -189,8 +189,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.ChongqingKuaiGongInternational], symbol: StockSymbols[LocationName.ChongqingKuaiGongInternational],
}, },
@ -215,8 +215,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 1, min: 1,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.AevumFulcrumTechnologies], symbol: StockSymbols[LocationName.AevumFulcrumTechnologies],
}, },
@ -241,8 +241,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.IshimaStormTechnologies], symbol: StockSymbols[LocationName.IshimaStormTechnologies],
}, },
@ -267,8 +267,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.NewTokyoDefComm], symbol: StockSymbols[LocationName.NewTokyoDefComm],
}, },
@ -293,8 +293,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.VolhavenHeliosLabs], symbol: StockSymbols[LocationName.VolhavenHeliosLabs],
}, },
@ -319,8 +319,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.NewTokyoVitaLife], symbol: StockSymbols[LocationName.NewTokyoVitaLife],
}, },
@ -345,8 +345,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 3, min: 3,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.Sector12IcarusMicrosystems], symbol: StockSymbols[LocationName.Sector12IcarusMicrosystems],
}, },
@ -371,8 +371,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.Sector12UniversalEnergy], symbol: StockSymbols[LocationName.Sector12UniversalEnergy],
}, },
@ -397,8 +397,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 3, min: 3,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 21e3, min: 42e3,
}, },
symbol: StockSymbols[LocationName.AevumAeroCorp], symbol: StockSymbols[LocationName.AevumAeroCorp],
}, },
@ -423,8 +423,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 21e3, min: 42e3,
}, },
symbol: StockSymbols[LocationName.VolhavenOmniaCybersystems], symbol: StockSymbols[LocationName.VolhavenOmniaCybersystems],
}, },
@ -449,8 +449,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 21e3, min: 42e3,
}, },
symbol: StockSymbols[LocationName.ChongqingSolarisSpaceSystems], symbol: StockSymbols[LocationName.ChongqingSolarisSpaceSystems],
}, },
@ -475,8 +475,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 21e3, min: 42e3,
}, },
symbol: StockSymbols[LocationName.NewTokyoGlobalPharmaceuticals], symbol: StockSymbols[LocationName.NewTokyoGlobalPharmaceuticals],
}, },
@ -501,8 +501,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 21e3, min: 42e3,
}, },
symbol: StockSymbols[LocationName.IshimaNovaMedical], symbol: StockSymbols[LocationName.IshimaNovaMedical],
}, },
@ -527,8 +527,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 27e3, max: 54e3,
min: 6e3, min: 12e3,
}, },
symbol: StockSymbols[LocationName.AevumWatchdogSecurity], symbol: StockSymbols[LocationName.AevumWatchdogSecurity],
}, },
@ -553,8 +553,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 54e3, max: 108e3,
min: 18e3, min: 36e3,
}, },
symbol: StockSymbols[LocationName.VolhavenLexoCorp], symbol: StockSymbols[LocationName.VolhavenLexoCorp],
}, },
@ -579,8 +579,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 3, min: 3,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 30e3, min: 60e3,
}, },
symbol: StockSymbols[LocationName.AevumRhoConstruction], symbol: StockSymbols[LocationName.AevumRhoConstruction],
}, },
@ -605,8 +605,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.Sector12AlphaEnterprises], symbol: StockSymbols[LocationName.Sector12AlphaEnterprises],
}, },
@ -631,7 +631,7 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 15e3,
}, },
symbol: StockSymbols[LocationName.VolhavenSysCoreSecurities], symbol: StockSymbols[LocationName.VolhavenSysCoreSecurities],
@ -657,8 +657,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 63e3, max: 126e3,
min: 30e3, min: 60e3,
}, },
symbol: StockSymbols[LocationName.VolhavenCompuTek], symbol: StockSymbols[LocationName.VolhavenCompuTek],
}, },
@ -683,8 +683,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 27e3, max: 54e3,
min: 9e3, min: 18e3,
}, },
symbol: StockSymbols[LocationName.AevumNetLinkTechnologies], symbol: StockSymbols[LocationName.AevumNetLinkTechnologies],
}, },
@ -709,8 +709,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 4, min: 4,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 45e3, max: 90e3,
min: 15e3, min: 30e3,
}, },
symbol: StockSymbols[LocationName.IshimaOmegaSoftware], symbol: StockSymbols[LocationName.IshimaOmegaSoftware],
}, },
@ -735,8 +735,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 6, min: 6,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 90e3, max: 180e3,
min: 30e3, min: 60e3,
}, },
symbol: StockSymbols[LocationName.Sector12FoodNStuff], symbol: StockSymbols[LocationName.Sector12FoodNStuff],
}, },
@ -761,8 +761,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 6, min: 6,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 42e3, max: 84e3,
min: 12e3, min: 24e3,
}, },
symbol: StockSymbols["Sigma Cosmetics"], symbol: StockSymbols["Sigma Cosmetics"],
}, },
@ -787,8 +787,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 6, min: 6,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 32e3, max: 64e3,
min: 9e3, min: 18e3,
}, },
symbol: StockSymbols["Joes Guns"], symbol: StockSymbols["Joes Guns"],
}, },
@ -813,8 +813,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 5, min: 5,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 36e3, max: 72e3,
min: 12e3, min: 24e3,
}, },
symbol: StockSymbols["Catalyst Ventures"], symbol: StockSymbols["Catalyst Ventures"],
}, },
@ -839,8 +839,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 3, min: 3,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 108e3, max: 216e3,
min: 45e3, min: 90e3,
}, },
symbol: StockSymbols["Microdyne Technologies"], symbol: StockSymbols["Microdyne Technologies"],
}, },
@ -865,8 +865,8 @@ export const InitStockMetadata: IConstructorParams[] = [
min: 2, min: 2,
}, },
shareTxForMovement: { shareTxForMovement: {
max: 108e3, max: 216e3,
min: 45e3, min: 90e3,
}, },
symbol: StockSymbols["Titan Laboratories"], symbol: StockSymbols["Titan Laboratories"],
}, },

@ -45,7 +45,7 @@ describe("Stock Market Tests", function() {
marketCap: 5e9, marketCap: 5e9,
mv: 1, mv: 1,
name: "MockStock", name: "MockStock",
otlkMag: 10, otlkMag: 20,
spreadPerc: 1, spreadPerc: 1,
shareTxForMovement: 5e3, shareTxForMovement: 5e3,
symbol: "mock", symbol: "mock",