Skip to content

Commit

Permalink
fix the close price
Browse files Browse the repository at this point in the history
  • Loading branch information
mnsrulz committed Apr 12, 2024
1 parent dbee9a5 commit 443971f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/close-trade.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,12 @@ const SubComp = (props: { t: Trade }) => {
const [contractPriceAtClose] = useWatch({
name: ['contractPriceAtClose'],
});

const [transactionEndDate] = useWatch({
name: ['transactionEndDate'],
});

const t1 = mapTradeToView({ ...props.t, lastContractPrice: contractPriceAtClose });
const t1 = mapTradeToView({ ...props.t, contractPriceAtClose, transactionEndDate });
return (
<>
<Stack>
Expand Down Expand Up @@ -113,7 +117,7 @@ export const CloseTradeDialog = (props: ITickerProps) => {
<TextFieldElement fullWidth name={'transactionStartDate'} label={'Purchase date'} disabled />
</Grid>
</Grid> */}
<DatePickerElement label="Transaction End Date" name="transactionEndDate" required disableFuture={true} disablePast={false} />
<DatePickerElement label="Transaction End Date" name="transactionEndDate" required disableFuture={false} disablePast={false} />
<TextFieldElement name={'contractPriceAtClose'} label={'Contract Price at close'} required
InputProps={{ startAdornment: <InputAdornment position="start">$</InputAdornment> }} />
<TextareaAutosizeElement label="Notes" name="notes" rows={5} />
Expand Down
2 changes: 1 addition & 1 deletion src/lib/useTrades.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ITradeView } from "./types";

const SellContracts = ['PUT_SELL', 'CALL_SELL'];

export const mapTradeToView = (trade: Trade): ITradeView => {
export const mapTradeToView = (trade: Trade): ITradeView => {
const isSellContract = SellContracts.includes(trade.contractType);
const sellCost = isSellContract ? (Number(trade.contractPrice) * 100 * trade.numberOfContracts) : 0;
const buyCost = (isSellContract && trade.contractPriceAtClose) ? (Number(trade.contractPriceAtClose) * 100 * trade.numberOfContracts) : NaN;
Expand Down

0 comments on commit 443971f

Please sign in to comment.