diff --git a/doc/source/basicgameplay/stockmarket.rst b/doc/source/basicgameplay/stockmarket.rst index 49b86e3bc..7e44d6c22 100644 --- a/doc/source/basicgameplay/stockmarket.rst +++ b/doc/source/basicgameplay/stockmarket.rst @@ -51,31 +51,6 @@ bid price. Note that this is reversed for a short position. Purchasing a stock in the short position will occur at the stock's bid price, and selling a stock in the short position will occur at the stock's ask price. -.. _gameplay_stock_market_spread_price_movement: - -Transactions Influencing Stock Price -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Buying or selling a large number of shares of a stock will influence that stock's price. - -Buying a stock in the long position will cause that stock's price to -increase. Selling a stock in the long position will cause the stock's price to decrease. -The reverse occurs for the short position. The effect of this depends on how many shares -are being transacted. More shares will have a bigger effect on the stock price. If -only a small number of shares are being transacted, the stock price may not be affected. - -Note that this "influencing" of the stock price **can happen in the middle of a transaction**. -For example, assume you are selling 1m shares of a stock. That stock's bid price -is currently $100. However, selling 100k shares of the stock causes its price to drop -by 1%. This means that for your transaction of 1m shares, the first 100k shares will be -sold at $100. Then the next 100k shares will be sold at $99. Then the next 100k shares will -be sold at $98.01, and so on. - -This is an important concept to keep in mind if you are trying to purchase/sell a -large number of shares, as **it can negatively affect your profits**. - -.. note:: On the Stock Market UI, the displayed profit of a position does not take - this "influencing" into account. - Transactions Influencing Stock Forecast ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ In addition to influencing stock price, buying or selling a large number of shares @@ -142,7 +117,49 @@ A Stop Order to sell will execute if the stock's price >= order's price. However, the transaction causes the stock's price to increase before the order finishes executing all of the shares. Your Limit Order will stop executing, and will continue only when the stock's price drops back to - $5 or below. + $5 or below. + +.. _gameplay_stock_market_player_actions_influencing_stock: + +Player Actions Influencing Stocks +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +It is possible for your actions elsewhere in the game to influence the stock market. + +Hacking + If a server has a corresponding stock (e.g. *foodnstuff* server -> FoodNStuff + stock), then hacking that server can + cause the corresponding stock's forecast to trend downwards in value + over time. + + This effect only occurs if you set the *stock* option to + true when calling the :js:func:`hack` function. The chance that hacking a + server will cause this effect is based on what percentage of the + server's total money you steal. + + A single hack will have a minor + effect, but continuously hacking a server for lots of money over time + will have a noticeable effect in making the stock's forecast trend downwards. + +Growing + If a server has a corresponding stock (e.g. *foodnstuff* server -> FoodNStuff + stock), then growing that server's money can cause the corresponding stock's + forecast to trend upwards in value over time. + + This effect only occurs if you set the *stock* option to true when calling the + :js:func:`grow` function. The chance that growing a server will cause this + effect is based on what percentage of the server's total money to add to it. + + A single grow operation will have a minor effect, but continuously growing + a server for lots of money over time will have a noticeable effect in making + the stock's forecast trend upwards. + +Working for a Company + If a company has a corresponding stock, then working for that company will + cause the corresponding stock's forecast to (slowly) trend upwards in value + over time. + + The potency of this effect is based on how "effective" you are when you work + (i.e. its based on your stats). Automating the Stock Market --------------------------- @@ -159,7 +176,8 @@ are hidden, although some of them can be made visible by purchasing the Four Sigma (4S) Market Data upgrade. Some examples of these properties are: * Volatility -* Likelihood of increasing or decreasing +* Likelihood of increasing or decreasing (i.e. the stock's forecast) +* Likelihood of forecast increasing or decreasing (i.e. the stock's second-order forecast) * How easily a stock's price/forecast is influenced by transactions * Spread percentage * Maximum price (not a real maximum, more of a "soft cap") diff --git a/doc/source/netscript/basicfunctions/grow.rst b/doc/source/netscript/basicfunctions/grow.rst index 026e825cd..fc5257f11 100644 --- a/doc/source/netscript/basicfunctions/grow.rst +++ b/doc/source/netscript/basicfunctions/grow.rst @@ -8,6 +8,8 @@ grow() Netscript Function * threads (*number*) - Number of threads to use for this function. Must be less than or equal to the number of threads the script is running with. + * stock (*boolean*) - If true, the function can affect the stock market. See + :ref:`gameplay_stock_market_player_actions_influencing_stock` :returns: The number by which the money on the server was multiplied for the growth :RAM cost: 0.15 GB diff --git a/doc/source/netscript/basicfunctions/hack.rst b/doc/source/netscript/basicfunctions/hack.rst index 569fb323d..e7f7718ea 100644 --- a/doc/source/netscript/basicfunctions/hack.rst +++ b/doc/source/netscript/basicfunctions/hack.rst @@ -8,6 +8,8 @@ hack() Netscript Function * threads (*number*) - Number of threads to use for this function. Must be less than or equal to the number of threads the script is running with. + * stock (*boolean*) - If true, the function can affect the stock market. See + :ref:`gameplay_stock_market_player_actions_influencing_stock` :returns: The amount of money stolen if the hack is successful, and zero otherwise :RAM cost: 0.1 GB diff --git a/src/Constants.ts b/src/Constants.ts index 4b9ae078d..1b9098645 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -229,7 +229,7 @@ export let CONSTANTS: IMap = { ** Working for a company positively affects the way the corresponding stock's forecast changes * Scripts now start/stop instantly - * Improved performance when starting up many copies of a new script (by Ornedan) + * Improved performance when starting up many copies of a new NetscriptJS script (by Ornedan) * Dialog boxes can now be closed with the ESC key (by jaguilar) * NetscriptJS scripts should now be "re-compiled" if their dependencies change (by jaguilar) * write() function should now properly cause NetscriptJS scripts to "re-compile" (by jaguilar) diff --git a/src/StockMarket/StockMarket.tsx b/src/StockMarket/StockMarket.tsx index 22902bc50..b3d2bf290 100644 --- a/src/StockMarket/StockMarket.tsx +++ b/src/StockMarket/StockMarket.tsx @@ -185,10 +185,10 @@ export function stockMarketCycle() { if (!(stock instanceof Stock)) { continue; } const roll = Math.random(); - if (roll < 0.2) { + if (roll < 0.1) { stock.flipForecastForecast(); StockMarket.ticksUntilCycle = 4 * TicksPerCycle; - } else if (roll < 0.65) { + } else if (roll < 0.55) { stock.b = !stock.b; stock.flipForecastForecast(); StockMarket.ticksUntilCycle = TicksPerCycle; @@ -214,6 +214,9 @@ export function processStockPrices(numCycles=1) { StockMarket.storedCycles -= cyclesPerStockUpdate; // Cycle + if (StockMarket.ticksUntilCycle == null || typeof StockMarket.ticksUntilCycle !== "number") { + StockMarket.ticksUntilCycle = TicksPerCycle; + } --StockMarket.ticksUntilCycle; if (StockMarket.ticksUntilCycle <= 0) { stockMarketCycle(); diff --git a/src/StockMarket/StockMarketConstants.ts b/src/StockMarket/StockMarketConstants.ts index ddcdbb34e..789d17e82 100644 --- a/src/StockMarket/StockMarketConstants.ts +++ b/src/StockMarket/StockMarketConstants.ts @@ -2,4 +2,4 @@ * How many stock market 'ticks' before a 'cycle' is triggered. * A 'tick' is whenver stock prices update */ -export const TicksPerCycle = 80; +export const TicksPerCycle = 70; diff --git a/src/StockMarket/StockMarketHelpers.ts b/src/StockMarket/StockMarketHelpers.ts index 9126edc93..61c1bba2d 100644 --- a/src/StockMarket/StockMarketHelpers.ts +++ b/src/StockMarket/StockMarketHelpers.ts @@ -98,7 +98,10 @@ export function processTransactionForecastMovement(stock: Stock, shares: number) // Forecast always decreases in magnitude const forecastChange = forecastChangePerPriceMovement * (numIterations - 1); - stock.otlkMag = Math.max(6, stock.otlkMag - forecastChange); + const changeLimit = 6; + if (stock.otlkMag > changeLimit) { + stock.otlkMag = Math.max(changeLimit, stock.otlkMag - forecastChange); + } } /** diff --git a/src/StockMarket/data/InitStockMetadata.ts b/src/StockMarket/data/InitStockMetadata.ts index 2b10450f9..3e84c8cd0 100644 --- a/src/StockMarket/data/InitStockMetadata.ts +++ b/src/StockMarket/data/InitStockMetadata.ts @@ -672,8 +672,8 @@ export const InitStockMetadata: IConstructorParams[] = [ marketCap: 58e9, mv: { divisor: 100, - max: 430, - min: 400, + max: 400, + min: 200, }, name: LocationName.AevumNetLinkTechnologies, otlkMag: 1, @@ -750,8 +750,8 @@ export const InitStockMetadata: IConstructorParams[] = [ marketCap: 30e9, mv: { divisor: 100, - max: 300, - min: 260, + max: 275, + min: 100, }, name: "Sigma Cosmetics", otlkMag: 0, @@ -776,8 +776,8 @@ export const InitStockMetadata: IConstructorParams[] = [ marketCap: 42e9, mv: { divisor: 100, - max: 400, - min: 360, + max: 350, + min: 200, }, name: "Joes Guns", otlkMag: 1,