mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
STOCK: ns.stock.getOrganization added for getting org from stock symbol (#234)
Authored-by: SamuraiNinjaGuy <branmiller+bitburner@gmail.com>
This commit is contained in:
parent
837c6bd1c2
commit
0fb7200b4b
@ -127,6 +127,7 @@ const stock = {
|
||||
has4SDataTIXAPI: 0.05,
|
||||
getSymbols: RamCostConstants.ScriptGetStockRamCost,
|
||||
getPrice: RamCostConstants.ScriptGetStockRamCost,
|
||||
getOrganization: RamCostConstants.ScriptGetStockRamCost,
|
||||
getAskPrice: RamCostConstants.ScriptGetStockRamCost,
|
||||
getBidPrice: RamCostConstants.ScriptGetStockRamCost,
|
||||
getPosition: RamCostConstants.ScriptGetStockRamCost,
|
||||
|
@ -60,6 +60,13 @@ export function NetscriptStockMarket(): InternalAPI<TIX> {
|
||||
|
||||
return stock.price;
|
||||
},
|
||||
getOrganization: (ctx) => (_symbol) => {
|
||||
const symbol = helpers.string(ctx, "symbol", _symbol);
|
||||
checkTixApiAccess(ctx);
|
||||
const stock = getStockFromSymbol(ctx, symbol);
|
||||
|
||||
return stock.name;
|
||||
},
|
||||
getAskPrice: (ctx) => (_symbol) => {
|
||||
const symbol = helpers.string(ctx, "symbol", _symbol);
|
||||
checkTixApiAccess(ctx);
|
||||
|
40
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
40
src/ScriptEditor/NetscriptDefinitions.d.ts
vendored
@ -1061,6 +1061,46 @@ export interface TIX {
|
||||
*/
|
||||
getPrice(sym: string): number;
|
||||
|
||||
/**
|
||||
* Returns the organization associated with a stock symbol.
|
||||
*
|
||||
* @remarks
|
||||
* RAM cost: 2 GB
|
||||
*
|
||||
* The organization associated with the corresponding stock symbol. This function
|
||||
* requires that you have the following:
|
||||
*
|
||||
* 1. WSE Account
|
||||
*
|
||||
* 1. TIX API Access
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // NS1
|
||||
* stock.getOrganization("FSIG");
|
||||
*
|
||||
* // Choose the first stock symbol from the array of stock symbols. Get the
|
||||
* // organization associated with the corresponding stock symbol
|
||||
* var sym = stock.getSymbols()[0];
|
||||
* tprint("Stock symbol: " + sym);
|
||||
* tprint("Stock organization: " + stock.getOrganization(sym));
|
||||
* ```
|
||||
* @example
|
||||
* ```ts
|
||||
* // NS2
|
||||
* ns.stock.getOrganization("FSIG");
|
||||
*
|
||||
* // Choose the first stock symbol from the array of stock symbols. Get the
|
||||
* // organization associated with the corresponding stock symbol.
|
||||
* const sym = ns.stock.getSymbols()[0];
|
||||
* ns.tprint("Stock symbol: " + sym);
|
||||
* ns.tprint("Stock organization: " + ns.stock.getOrganization(sym));
|
||||
* ```
|
||||
* @param sym - Stock symbol.
|
||||
* @returns The organization assicated with the stock symbol.
|
||||
*/
|
||||
getOrganization(sym: string): string;
|
||||
|
||||
/**
|
||||
* Returns the ask price of that stock.
|
||||
* @remarks RAM cost: 2 GB
|
||||
|
Loading…
Reference in New Issue
Block a user