Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
suyeshs committed Sep 22, 2023
1 parent 2a5edb7 commit d7b3f3b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
18 changes: 12 additions & 6 deletions src/pages/apitest/index.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
import TestComponent from '../../app/components/TestComponent/TestComponent';
//pages/apitest/index.js or any other page

export default function ApiTestPage() {
return <TestComponent />;
}
import WebSocketComponent from '../../app/components/WebSocketComponent';



function SocketApp() {
return (
<div>
{/* You can render other components or content here */}
<WebSocketComponent />
</div>
);
}

export default SocketApp;
2 changes: 1 addition & 1 deletion src/pages/nse-options/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const NseFlatDataOptions = observer(({ initialData, initialStock }: { initialDat
const rowIndex = Number(args.row.getAttribute('aria-rowindex'));
if (store && store.nseFetchStore.atmStrikeIndex !== null) {
if (rowIndex - 1 === (store.nseFetchStore.atmStrikeIndex -
Math.max((store?.nseFetchStore.atmStrikeIndex || 0) - 5, 0))) {
Math.max((store?.nseFetchStore.atmStrikeIndex || 0) - selectedRange, 0))) {
args.row.style.background = 'beige';
}
}
Expand Down
1 change: 1 addition & 0 deletions src/stores/DefaultStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class DefaultStore {
}

setExpiryDate(expiryDate: string) {
console.log('setExpiryDate called with expiryDate:', expiryDate);
this.expiryDate = expiryDate;
}
}
Expand Down
16 changes: 10 additions & 6 deletions src/stores/NseFetchStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ export class NseFetchStore {
intervalId: number | null = null;
symbol: string = 'NIFTY';
expiryDateStore: ExpiryDateStore;
defaultStore: DefaultStore;


constructor(defaultStore: DefaultStore,expiryDateStore: ExpiryDateStore,initialNseData?: NseOptionData[]) {
this.defaultStore = defaultStore;
this.expiryDateStore = expiryDateStore;
makeObservable(this, {
atmStrike: observable,
Expand Down Expand Up @@ -81,6 +83,13 @@ export class NseFetchStore {

// Set expiryDate to the first available expiry date
this.expiryDate = this.expiryDateStore.expiryDates[0] || null;

// Set expiryDate in defaultStore to the first available expiry date
if (this.expiryDate) {
this.defaultStore.setExpiryDate(this.expiryDate);
} else {
console.warn('expiryDate is null, not calling setExpiryDate');
}
console.log('expiryDate after fetchExpiryDatesForSymbol:', this.expiryDate);
// Fetch new data based on the updated symbol and expiryDate
this.fetchData(this.symbol, this.expiryDate || '');
Expand Down Expand Up @@ -129,12 +138,7 @@ export class NseFetchStore {
fetchData = async (userSelectedStock: string = this.symbol || 'NIFTY', firstExpiryDate: string = this.expiryDate || '') => {
this.isLoading = true;

// If we don't have an expiry date, log an error and stop further execution
if (!firstExpiryDate) {
console.error('Expiry date is not available.');
this.isLoading = false;
return [];
}


try {
const response = await axios.get(`https://tradepodapisrv.azurewebsites.net/api/option-chain-copy/?symbol=${encodeURIComponent(this.symbol)}&expiry_date=${encodeURIComponent(firstExpiryDate)}`);
Expand Down

0 comments on commit d7b3f3b

Please sign in to comment.