API: Standardize names of Stock APIs (#2173)

This commit is contained in:
catloversg
2025-06-02 16:36:36 +07:00
committed by GitHub
parent 856ce9a5c9
commit 7d2686ed1b
16 changed files with 104 additions and 57 deletions

View File

@@ -22,6 +22,6 @@ interface StockMarketConstants
| [msPerStockUpdateMin](./bitburner.stockmarketconstants.msperstockupdatemin.md) | | number | Minimum time in ms between stock market updates if there is stored offline/bonus time |
| [StockMarketCommission](./bitburner.stockmarketconstants.stockmarketcommission.md) | | number | Commission fee for transactions |
| [TicksPerCycle](./bitburner.stockmarketconstants.tickspercycle.md) | | number | An internal constant used while determining when to flip a stock's forecast |
| [TIXAPICost](./bitburner.stockmarketconstants.tixapicost.md) | | number | Cost of the TIX API |
| [WSEAccountCost](./bitburner.stockmarketconstants.wseaccountcost.md) | | number | Cost of the WSE account |
| [TixApiCost](./bitburner.stockmarketconstants.tixapicost.md) | | number | Cost of the TIX API |
| [WseAccountCost](./bitburner.stockmarketconstants.wseaccountcost.md) | | number | Cost of the WSE account |

View File

@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [StockMarketConstants](./bitburner.stockmarketconstants.md) &gt; [TIXAPICost](./bitburner.stockmarketconstants.tixapicost.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [StockMarketConstants](./bitburner.stockmarketconstants.md) &gt; [TixApiCost](./bitburner.stockmarketconstants.tixapicost.md)
## StockMarketConstants.TIXAPICost property
## StockMarketConstants.TixApiCost property
Cost of the TIX API
**Signature:**
```typescript
TIXAPICost: number;
TixApiCost: number;
```

View File

@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [StockMarketConstants](./bitburner.stockmarketconstants.md) &gt; [WSEAccountCost](./bitburner.stockmarketconstants.wseaccountcost.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [StockMarketConstants](./bitburner.stockmarketconstants.md) &gt; [WseAccountCost](./bitburner.stockmarketconstants.wseaccountcost.md)
## StockMarketConstants.WSEAccountCost property
## StockMarketConstants.WseAccountCost property
Cost of the WSE account
**Signature:**
```typescript
WSEAccountCost: number;
WseAccountCost: number;
```

View File

@@ -30,9 +30,9 @@ RAM cost: 2 GB
The organization associated with the corresponding stock symbol. This function requires that you have the following:
1. WSE Account
- WSE Account
1. TIX API Access
- TIX API Access
## Example

View File

@@ -30,9 +30,9 @@ RAM cost: 2 GB
The stocks price is the average of its bid and ask prices. This function requires that you have the following:
1. WSE Account
- WSE Account
1. TIX API Access
- TIX API Access
## Example

View File

@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [has4SDataTIXAPI](./bitburner.tix.has4sdatatixapi.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [has4SDataTixApi](./bitburner.tix.has4sdatatixapi.md)
## TIX.has4SDataTIXAPI() method
## TIX.has4SDataTixApi() method
Returns true if the player has access to the 4SData TIX API
**Signature:**
```typescript
has4SDataTIXAPI(): boolean;
has4SDataTixApi(): boolean;
```
**Returns:**

View File

@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [hasTIXAPIAccess](./bitburner.tix.hastixapiaccess.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [hasTixApiAccess](./bitburner.tix.hastixapiaccess.md)
## TIX.hasTIXAPIAccess() method
## TIX.hasTixApiAccess() method
Returns true if the player has access to the TIX API
**Signature:**
```typescript
hasTIXAPIAccess(): boolean;
hasTixApiAccess(): boolean;
```
**Returns:**

View File

@@ -1,15 +1,15 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [hasWSEAccount](./bitburner.tix.haswseaccount.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [TIX](./bitburner.tix.md) &gt; [hasWseAccount](./bitburner.tix.haswseaccount.md)
## TIX.hasWSEAccount() method
## TIX.hasWseAccount() method
Returns true if the player has access to a WSE Account
**Signature:**
```typescript
hasWSEAccount(): boolean;
hasWseAccount(): boolean;
```
**Returns:**

View File

@@ -34,9 +34,9 @@ export interface TIX
| [getSymbols()](./bitburner.tix.getsymbols.md) | Returns an array of the symbols of the tradable stocks |
| [getVolatility(sym)](./bitburner.tix.getvolatility.md) | Returns the volatility of the specified stock. |
| [has4SData()](./bitburner.tix.has4sdata.md) | Returns true if the player has access to the 4S Data |
| [has4SDataTIXAPI()](./bitburner.tix.has4sdatatixapi.md) | Returns true if the player has access to the 4SData TIX API |
| [hasTIXAPIAccess()](./bitburner.tix.hastixapiaccess.md) | Returns true if the player has access to the TIX API |
| [hasWSEAccount()](./bitburner.tix.haswseaccount.md) | Returns true if the player has access to a WSE Account |
| [has4SDataTixApi()](./bitburner.tix.has4sdatatixapi.md) | Returns true if the player has access to the 4SData TIX API |
| [hasTixApiAccess()](./bitburner.tix.hastixapiaccess.md) | Returns true if the player has access to the TIX API |
| [hasWseAccount()](./bitburner.tix.haswseaccount.md) | Returns true if the player has access to a WSE Account |
| [nextUpdate()](./bitburner.tix.nextupdate.md) | Sleep until the next Stock Market price update has happened. |
| [placeOrder(sym, shares, price, orderType, positionType)](./bitburner.tix.placeorder.md) | Place order for stocks. |
| [purchase4SMarketData()](./bitburner.tix.purchase4smarketdata.md) | Purchase 4S Market Data Access. |

View File

@@ -128,10 +128,10 @@ const hacknet = {
// Stock API
const stock = {
getConstants: 0,
hasWSEAccount: 0.05,
hasTIXAPIAccess: 0.05,
hasWseAccount: 0.05,
hasTixApiAccess: 0.05,
has4SData: 0.05,
has4SDataTIXAPI: 0.05,
has4SDataTixApi: 0.05,
getBonusTime: 0,
nextUpdate: RamCostConstants.CycleTiming,
getSymbols: RamCostConstants.GetStock,

View File

@@ -16,9 +16,9 @@ import {
getStockMarketWseCost,
getStockMarketTixApiCost,
} from "../StockMarket/StockMarketCosts";
import { Stock } from "../StockMarket/Stock";
import { StockOrder, TIX } from "@nsdefs";
import { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
import type { Stock } from "../StockMarket/Stock";
import type { StockOrder, TIX } from "@nsdefs";
import { setRemovedFunctions, type InternalAPI, type NetscriptContext } from "../Netscript/APIWrapper";
import { helpers } from "../Netscript/NetscriptHelpers";
import { StockMarketConstants } from "../StockMarket/data/Constants";
import { getEnumHelper } from "../utils/EnumHelper";
@@ -43,12 +43,12 @@ export function NetscriptStockMarket(): InternalAPI<TIX> {
return stock;
};
return {
const stockFunctions: InternalAPI<TIX> = {
getConstants: () => () => structuredClone(StockMarketConstants),
hasWSEAccount: () => () => Player.hasWseAccount,
hasTIXAPIAccess: () => () => Player.hasTixApiAccess,
hasWseAccount: () => () => Player.hasWseAccount,
hasTixApiAccess: () => () => Player.hasTixApiAccess,
has4SData: () => () => Player.has4SData,
has4SDataTIXAPI: () => () => Player.has4SDataTixApi,
has4SDataTixApi: () => () => Player.has4SDataTixApi,
getSymbols: (ctx) => () => {
checkTixApiAccess(ctx);
return Object.values(StockSymbol);
@@ -333,4 +333,12 @@ export function NetscriptStockMarket(): InternalAPI<TIX> {
return StockMarketPromise.promise;
},
};
setRemovedFunctions(stockFunctions, {
hasWSEAccount: { version: "3.0.0", replacement: "stock.hasWseAccount()" },
hasTIXAPIAccess: { version: "3.0.0", replacement: "stock.hasTixApiAccess()" },
has4SDataTIXAPI: { version: "3.0.0", replacement: "stock.has4SDataTixApi()" },
});
return stockFunctions;
}

View File

@@ -453,9 +453,9 @@ interface StockMarketConstants {
/** An internal constant used while determining when to flip a stock's forecast */
TicksPerCycle: number;
/** Cost of the WSE account */
WSEAccountCost: number;
WseAccountCost: number;
/** Cost of the TIX API */
TIXAPICost: number;
TixApiCost: number;
/** Cost of the 4S Market Data */
MarketData4SCost: number;
/** Cost of the 4S Market Data TIX API integration */
@@ -1219,19 +1219,22 @@ export interface NetscriptPort {
* @public
*/
export interface TIX {
/** Get game constants for the stock market mechanic.
* @remarks RAM cost: 0 GB */
/**
* Get game constants for the stock market mechanic.
*
* @remarks RAM cost: 0 GB
*/
getConstants(): StockMarketConstants;
/**
* Returns true if the player has access to a WSE Account
* @remarks RAM cost: 0.05 GB
*/
hasWSEAccount(): boolean;
hasWseAccount(): boolean;
/**
* Returns true if the player has access to the TIX API
* @remarks RAM cost: 0.05 GB
*/
hasTIXAPIAccess(): boolean;
hasTixApiAccess(): boolean;
/**
* Returns true if the player has access to the 4S Data
* @remarks RAM cost: 0.05 GB
@@ -1241,7 +1244,7 @@ export interface TIX {
* Returns true if the player has access to the 4SData TIX API
* @remarks RAM cost: 0.05 GB
*/
has4SDataTIXAPI(): boolean;
has4SDataTixApi(): boolean;
/**
* Returns an array of the symbols of the tradable stocks
*
@@ -1259,9 +1262,9 @@ export interface TIX {
* The stocks price is the average of its bid and ask prices. This function requires
* that you have the following:
*
* 1. WSE Account
* - WSE Account
*
* 1. TIX API Access
* - TIX API Access
*
* @example
* ```js
@@ -1287,9 +1290,9 @@ export interface TIX {
* The organization associated with the corresponding stock symbol. This function
* requires that you have the following:
*
* 1. WSE Account
* - WSE Account
*
* 1. TIX API Access
* - TIX API Access
*
* @example
* ```js

View File

@@ -10,9 +10,9 @@ export function getStockMarket4STixApiCost(): number {
}
export function getStockMarketWseCost(): number {
return StockMarketConstants.WSEAccountCost;
return StockMarketConstants.WseAccountCost;
}
export function getStockMarketTixApiCost(): number {
return StockMarketConstants.TIXAPICost;
return StockMarketConstants.TixApiCost;
}

View File

@@ -4,8 +4,8 @@ export const StockMarketConstants: ConstantsType = {
msPerStockUpdate: 6e3,
msPerStockUpdateMin: 4e3,
TicksPerCycle: 75,
WSEAccountCost: 200e6,
TIXAPICost: 5e9,
WseAccountCost: 200e6,
TixApiCost: 5e9,
MarketData4SCost: 1e9,
MarketDataTixApi4SCost: 25e9,
StockMarketCommission: 100e3,

View File

@@ -82,16 +82,16 @@ function PurchaseWseAccountButton(props: IProps): React.ReactElement {
if (Player.hasWseAccount) {
return;
}
if (!Player.canAfford(StockMarketConstants.WSEAccountCost)) {
if (!Player.canAfford(StockMarketConstants.WseAccountCost)) {
return;
}
Player.hasWseAccount = true;
initStockMarket();
Player.loseMoney(StockMarketConstants.WSEAccountCost, "stock");
Player.loseMoney(StockMarketConstants.WseAccountCost, "stock");
props.rerender();
}
const cost = StockMarketConstants.WSEAccountCost;
const cost = StockMarketConstants.WseAccountCost;
return (
<>
<Typography>To begin trading, you must first purchase an account:</Typography>
@@ -111,11 +111,11 @@ function PurchaseTixApiAccessButton(props: IProps): React.ReactElement {
if (Player.hasTixApiAccess) {
return;
}
if (!Player.canAfford(StockMarketConstants.TIXAPICost)) {
if (!Player.canAfford(StockMarketConstants.TixApiCost)) {
return;
}
Player.hasTixApiAccess = true;
Player.loseMoney(StockMarketConstants.TIXAPICost, "stock");
Player.loseMoney(StockMarketConstants.TixApiCost, "stock");
props.rerender();
}
@@ -126,7 +126,7 @@ function PurchaseTixApiAccessButton(props: IProps): React.ReactElement {
</Typography>
);
} else {
const cost = StockMarketConstants.TIXAPICost;
const cost = StockMarketConstants.TixApiCost;
return (
<Button disabled={!Player.canAfford(cost) || !Player.hasWseAccount} onClick={purchaseTixApiAccess}>
Buy Trade Information eXchange (TIX) API Access -&nbsp;

View File

@@ -93,7 +93,7 @@ export const breakingChanges300: VersionBreakingChange = {
"ns.closeTail() was removed.\n" +
'It has been automatically replaced with "ns.ui.closeTail()".\n\n' +
"ns.setTitle() was removed.\n" +
'It has been automatically replaced with "ns.ui.setTailTitle()".\n\n',
'It has been automatically replaced with "ns.ui.setTailTitle()".',
showPopUp: false,
},
{
@@ -108,7 +108,7 @@ export const breakingChanges300: VersionBreakingChange = {
],
info:
"ns.corporation.setAutoJobAssignment() was removed.\n" +
'It has been automatically replaced with "ns.corporation.setJobAssignment()".\n\n',
'It has been automatically replaced with "ns.corporation.setJobAssignment()".',
showPopUp: false,
},
{
@@ -143,5 +143,41 @@ export const breakingChanges300: VersionBreakingChange = {
"This should not be a problem with most scripts. However, if you were catching errors and branching on the result of success/failure, you will need to use the return value instead.",
showPopUp: true,
},
{
brokenAPIs: [
{
name: "ns.stock.getConstants().WSEAccountCost",
migration: { searchValue: "WSEAccountCost", replaceValue: "WseAccountCost" },
},
{
name: "ns.stock.getConstants().TIXAPICost",
migration: { searchValue: "TIXAPICost", replaceValue: "TixApiCost" },
},
{
name: "ns.stock.hasWSEAccount",
migration: { searchValue: "hasWSEAccount", replaceValue: "hasWseAccount" },
},
{
name: "ns.stock.hasTIXAPIAccess",
migration: { searchValue: "hasTIXAPIAccess", replaceValue: "hasTixApiAccess" },
},
{
name: "ns.stock.has4SDataTIXAPI",
migration: { searchValue: "has4SDataTIXAPI", replaceValue: "has4SDataTixApi" },
},
],
info:
"ns.stock.getConstants().WSEAccountCost was removed.\n" +
'It has been automatically replaced with "ns.stock.getConstants().WseAccountCost".\n\n' +
"ns.stock.getConstants().TIXAPICost was removed.\n" +
'It has been automatically replaced with "ns.stock.getConstants().TixApiCost".\n\n' +
"ns.stock.hasWSEAccount() was removed.\n" +
'It has been automatically replaced with "ns.stock.hasWseAccount()".\n\n' +
"ns.stock.hasTIXAPIAccess() was removed.\n" +
'It has been automatically replaced with "ns.stock.hasTixApiAccess()".\n\n' +
"ns.stock.has4SDataTIXAPI() was removed.\n" +
'It has been automatically replaced with "ns.stock.has4SDataTixApi()".',
showPopUp: false,
},
],
};