Skip to content

Commit

Permalink
Updated PE Lot size calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
suyeshs committed Oct 9, 2023
1 parent 9a79dd6 commit c679118
Showing 1 changed file with 20 additions and 9 deletions.
29 changes: 20 additions & 9 deletions src/pages/nse-options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,18 +340,18 @@ const NseFlatDataOptions = observer(

// const oi = isDividedByLotSize && lot_size && lot_size !== 0 ? rowData['CE_openInterest'] / lot_size : rowData['CE_openInterest'];
//const changeInOI = isDividedByLotSize && lot_size && lot_size !== 0 ? rowData['CE_changeinOpenInterest'] / lot_size : rowData['CE_changeinOpenInterest'];
const oi =
const ce_oi =
isDividedByLotSize && lot_size && lot_size !== 0
? Math.abs(rowData["CE_openInterest"] / lot_size)
: rowData["CE_openInterest"];

const changeInOI =
const CE_changeInOI =
isDividedByLotSize && lot_size && lot_size !== 0
? Math.abs(rowData["CE_changeinOpenInterest"] / lot_size)
: Math.abs(rowData["CE_changeinOpenInterest"]);
const maxSize = isDividedByLotSize ? 200000 / (lot_size || 1) : 200000; // Adjust this line
//const maxSize = 200000; // Adjust this value as needed
const size = Math.min((changeInOI / maxSize) * 5, 100);
const size = Math.min((CE_changeInOI / maxSize) * 5, 100);
const progressStyle = {
backgroundColor: color === "green" ? "#77AE57" : "#ff0000",
width: `${size}%`,
Expand All @@ -378,7 +378,7 @@ const NseFlatDataOptions = observer(
textAlign: "center",
}}
>
{oi.toLocaleString()} ({changeInOI.toLocaleString()})
{ce_oi.toLocaleString()} ({CE_changeInOI.toLocaleString()})
</div>
<div className={styles.greekNumbers}>Vega: {rowData["CE_vega"]}</div>
</div>
Expand All @@ -387,9 +387,21 @@ const NseFlatDataOptions = observer(

const peVega = (rowData: any) => {
const color = rowData["PE_changeinOpenInterest"] > 0 ? "green" : "red";
const changeInOI = Math.abs(rowData["PE_changeinOpenInterest"]);
const maxSize = 200000; // Adjust this value as needed
const size = Math.min((changeInOI / maxSize) * 5, 100);
const lot_size = store?.nseFetchStore?.lot_size;

// const oi = isDividedByLotSize && lot_size && lot_size !== 0 ? rowData['CE_openInterest'] / lot_size : rowData['CE_openInterest'];
//const changeInOI = isDividedByLotSize && lot_size && lot_size !== 0 ? rowData['CE_changeinOpenInterest'] / lot_size : rowData['CE_changeinOpenInterest'];
const pe_oi =
isDividedByLotSize && lot_size && lot_size !== 0
? Math.abs(rowData["PE_openInterest"] / lot_size)
: rowData["PE_openInterest"];

const PE_changeInOI =
isDividedByLotSize && lot_size && lot_size !== 0
? Math.abs(rowData["PE_changeinOpenInterest"] / lot_size)
: Math.abs(rowData["PE_changeinOpenInterest"]);
const maxSize = isDividedByLotSize ? 200000 / (lot_size || 1) : 200000; // Adjust this line
const size = Math.min((PE_changeInOI / maxSize) * 5, 100);
const progressStyle = {
backgroundColor: color === "green" ? "#77AE57" : "#ff0000",
width: `${size}%`,
Expand All @@ -416,8 +428,7 @@ const NseFlatDataOptions = observer(
textAlign: "center",
}}
>
{rowData["PE_openInterest"].toLocaleString()} (
{rowData["PE_changeinOpenInterest"].toLocaleString()})
{pe_oi.toLocaleString()} ({PE_changeInOI.toLocaleString()})
</div>
<div className={styles.greekNumbers}>Vega: {rowData["PE_vega"]}</div>
</div>
Expand Down

1 comment on commit c679118

@vercel
Copy link

@vercel vercel bot commented on c679118 Oct 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

tradepod – ./

tradepod.vercel.app
tradepod-suyeshs.vercel.app
tradepod-git-master-suyeshs.vercel.app

Please sign in to comment.