Skip to content

Commit

Permalink
added volume mode in optios viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Oct 10, 2024
1 parent 18e31f2 commit b3437fc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/components/StockOptionsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface ITickerProps {
export type IStrikePriceSliderPorps = { allStrikePricesValues: number[], onChange: (v: NumberRange) => void, currentPrice: number, strikePriceRange: NumberRange }

type PriceModeType = 'LAST_PRICE' | 'BID_PRICE' | 'ASK_PRICE' | 'AVG_PRICE'
type ValueModeType = 'PRICE' | 'ANNUAL_RETURN' | 'TOTAL_RETURN' | 'PCR'
type ValueModeType = 'PRICE' | 'ANNUAL_RETURN' | 'TOTAL_RETURN' | 'PCR' | 'VOLUME'
// type PutCallType = 'PUT' | 'CALL';
enum PutCallType {
'PUT' = 'PUT',
Expand Down Expand Up @@ -72,8 +72,8 @@ export const StockOptionsView = (props: ITickerProps) => {
columns.push({
field: s.strikePrice,
width: 10, headerName: `${parseFloat(s.strikePrice)}`,
valueFormatter: ['PRICE', 'PCR'].includes(valueMode) ? numberFormatter : percentageFormatter, type: 'number',
renderCell: ['PRICE'].includes(valueMode) ? undefined : (p) => <ConditionalFormattingBox value={p.value * (valueMode == 'PCR' ? 1 : 1000)} formattedValue={p.formattedValue} />
valueFormatter: ['PRICE', 'PCR', 'VOLUME'].includes(valueMode) ? numberFormatter : percentageFormatter, type: 'number',
renderCell: ['PRICE', 'VOLUME'].includes(valueMode) ? undefined : (p) => <ConditionalFormattingBox value={p.value * (valueMode == 'PCR' ? 1 : 1000)} formattedValue={p.formattedValue} />
})
})

Expand Down Expand Up @@ -119,6 +119,8 @@ export const StockOptionsView = (props: ITickerProps) => {
}
case 'PCR':
return po.oi;
case 'VOLUME':
return po.v;
default:
return price?.toFixed(2);
}
Expand Down Expand Up @@ -158,6 +160,7 @@ export const StockOptionsView = (props: ITickerProps) => {
<MenuItem value="ANNUAL_RETURN">ANNUAL_RETURN</MenuItem>
<MenuItem value="TOTAL_RETURN">TOTAL_RETURN</MenuItem>
<MenuItem value="PCR">PCR</MenuItem>
<MenuItem value="VOLUME">VOLUME</MenuItem>
</Select>
</FormControl>
<FormControl sx={{ m: 1 }} variant="standard">
Expand Down

0 comments on commit b3437fc

Please sign in to comment.