mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-03 14:27:03 +02:00
80 lines
1.1 KiB
Markdown
80 lines
1.1 KiB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||
|
||
[Home](./index.md) > [bitburner](./bitburner.md) > [Stock](./bitburner.stock.md) > [getPrice](./bitburner.stock.getprice.md)
|
||
|
||
## Stock.getPrice() method
|
||
|
||
Returns the price of a stock.
|
||
|
||
**Signature:**
|
||
|
||
```typescript
|
||
getPrice(sym: string): number;
|
||
```
|
||
|
||
## Parameters
|
||
|
||
<table><thead><tr><th>
|
||
|
||
Parameter
|
||
|
||
|
||
</th><th>
|
||
|
||
Type
|
||
|
||
|
||
</th><th>
|
||
|
||
Description
|
||
|
||
|
||
</th></tr></thead>
|
||
<tbody><tr><td>
|
||
|
||
sym
|
||
|
||
|
||
</td><td>
|
||
|
||
string
|
||
|
||
|
||
</td><td>
|
||
|
||
Stock symbol.
|
||
|
||
|
||
</td></tr>
|
||
</tbody></table>
|
||
|
||
**Returns:**
|
||
|
||
number
|
||
|
||
The price of a stock.
|
||
|
||
## Remarks
|
||
|
||
RAM cost: 2 GB
|
||
|
||
The stock’s price is the average of its bid and ask prices. This function requires that you have the following:
|
||
|
||
- WSE Account
|
||
|
||
- TIX API Access
|
||
|
||
## Example
|
||
|
||
|
||
```js
|
||
const fourSigmaStockPrice = ns.stock.getPrice("FSIG");
|
||
|
||
// Choose the first stock symbol from the array of stock symbols. Get the price
|
||
// of the corresponding stock.
|
||
const sym = ns.stock.getSymbols()[0];
|
||
ns.tprint("Stock symbol: " + sym);
|
||
ns.tprint("Stock price: " + ns.stock.getPrice(sym));
|
||
```
|
||
|