Skip to content

Commit

Permalink
fixed .env issues
Browse files Browse the repository at this point in the history
  • Loading branch information
suyeshs committed Oct 6, 2023
1 parent 861d7d2 commit 7bb3943
Show file tree
Hide file tree
Showing 15 changed files with 649 additions and 275 deletions.
3 changes: 1 addition & 2 deletions .env.development
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
REACT_APP_BASE_URL=http://127.0.0.1:8000
axios.defaults.baseURL = process.env.REACT_APP_BASE_URL;
REACT_APP_BASE_URL=http://127.0.0.1:8000/


2 changes: 2 additions & 0 deletions declarations.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare module 'black-scholes';
declare module '*';
70 changes: 62 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@
"grommet": "^2.32.2",
"grommet-icons": "^4.10.0",
"install": "^0.13.0",
"lightweight-charts": "^4.1.0",
"luxon": "^3.3.0",
"micro-cors": "^0.1.1",
"mobx": "^6.9.0",
"mobx-react": "^7.6.0",
"mobx-react-lite": "^3.4.3",
"mongodb": "^5.7.0",
"mongodb": "^5.9.0",
"mongoose": "^7.4.1",
"next": "^13.4.9",
"npm": "^9.7.1",
Expand Down
60 changes: 60 additions & 0 deletions src/app/components/WebSocketComponent.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import React, { useEffect, useState } from 'react';

interface MessageData {
message: string;
}

function WebSocketComponent() {
const [socket, setSocket] = useState<WebSocket | null>(null);
const [error, setError] = useState<string | null>(null);

useEffect(() => {
const socketInstance = new WebSocket('ws://localhost:8000/ws/tradepodapi/');

socketInstance.onopen = function(e) {
console.log('Connection established successfully');
};

socketInstance.onerror = function(e) {
console.error('Error connecting to WebSocket');
setError('Error connecting to WebSocket');
};

socketInstance.onmessage = function(e) {
const data: MessageData = JSON.parse(e.data);
console.log(data.message);
};

socketInstance.onclose = function(e) {
console.error('Chat socket closed unexpectedly');
};

setSocket(socketInstance);

return () => {
if (socket) {
socket.close();
}
};
}, [socket]);

const sendMessage = () => {
if (socket && !error) {
socket.send(JSON.stringify({
'message': 'Hello, world!'
}));
}
};

if (error) {
return <div>Error: {error}</div>;
}

return (
<div>
<button onClick={sendMessage}>Send Message</button>
</div>
);
}

export default WebSocketComponent;
21 changes: 0 additions & 21 deletions src/nifty-expiry-dates.json

This file was deleted.

47 changes: 35 additions & 12 deletions src/pages/breeze/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { useEffect, useState, useRef } from 'react';
import { GridComponent, ColumnsDirective, ColumnDirective } from '@syncfusion/ej2-react-grids';
import styles from './syncoptions.module.css';
import { BreezeOptionData } from '../../types';
import { DataManager, UrlAdaptor, } from '@syncfusion/ej2-data';
import { DataManager, UrlAdaptor } from '@syncfusion/ej2-data';
import { initializeBreezeFetchStore, BreezeFetchStore } from '../../stores/BreezeStore';
import { DropDownListComponent, MultiSelectComponent} from '@syncfusion/ej2-react-dropdowns';
import { DropDownListComponent, MultiSelectComponent } from '@syncfusion/ej2-react-dropdowns';
import { initializeExpiryDateStore, ExpiryDateStore } from '../../stores/ExpiryDateStore';

import { initializeSymbolStore, SymbolStore } from '../../stores/SymbolsStore';
import { DefaultStore } from '../../stores/DefaultStore';
import symbols from './symbols.json';



const BreezeFlatDataOptions = observer(({ initialData, initialStock }: { initialData: BreezeOptionData[], initialStock: string }) => {
Expand All @@ -20,25 +20,48 @@ const BreezeFlatDataOptions = observer(({ initialData, initialStock }: { initial
const [expiryDateStore, setExpiryDateStore] = useState<ExpiryDateStore | null>(null);
const [expiryDate, setExpiryDate] = useState('');
const [userSelectedStock, setUserSelectedStock] = useState(initialStock || '');
// Add a new state to store the selected expiry dates
const [selectedExpiryDates, setSelectedExpiryDates] = useState<string[]>([]);
const [prevInstrumentValue, setPrevInstrumentValue] = useState<number | null>(null);

const dataManager = new DataManager({
const [isFetchingExpiryDates, setIsFetchingExpiryDates] = useState(false);
const dataManager = new DataManager({
json: initialData,
adaptor: new UrlAdaptor(),
});


const [symbolStore, setSymbolStore] = useState<{ symbolStore: SymbolStore } | null>(null);
const symbols = symbolStore?.symbolStore.symbols || [];
const onUserSelectDate = (newDate: string) => {
console.log(`Expiry date changed to: ${newDate}`); // Log the new expiry date
// Update expiryDate in the store
console.log(`Expiry date changed to: ${newDate}`);
store?.breezeFetchStore.setExpiryDate(newDate);

// Fetch new data based on the updated expiryDate and the currently selected stock
store?.breezeFetchStore.fetchData(userSelectedStock, newDate);
};

useEffect(() => {
const symbolStoreInstance = initializeSymbolStore();
symbolStoreInstance.symbolStore.fetchSymbols().then(() => {
setSymbolStore({ symbolStore: symbolStoreInstance.symbolStore });
});
}, []);

const fetchExpiryDatesAndData = async (symbol: string, expiryDateStore: ExpiryDateStore, breezeFetchStore: BreezeFetchStore) => {
await expiryDateStore.fetchExpiryDatesForSymbol(symbol);
const firstExpiryDate = expiryDateStore.expiryDates[0] || '';
setExpiryDate(firstExpiryDate);
breezeFetchStore.setExpiryDate(firstExpiryDate);
if (firstExpiryDate) {
await breezeFetchStore.fetchData(symbol, firstExpiryDate);
dataManager.dataSource.json = breezeFetchStore.data;
setIsLoading(false);
}
};

useEffect(() => {
const breezeFetchStore = initializeBreezeFetchStore(new DefaultStore(), new ExpiryDateStore());
const expiryDateStore = initializeExpiryDateStore();
setStore({ breezeFetchStore });
setExpiryDateStore(expiryDateStore);
fetchExpiryDatesAndData(userSelectedStock, expiryDateStore, breezeFetchStore);
}, [userSelectedStock]);


useEffect(() => {
Expand Down
Loading

1 comment on commit 7bb3943

@vercel
Copy link

@vercel vercel bot commented on 7bb3943 Oct 6, 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-suyeshs.vercel.app
tradepod-git-master-suyeshs.vercel.app
tradepod.vercel.app

Please sign in to comment.