Skip to content

Commit

Permalink
removed ztsd
Browse files Browse the repository at this point in the history
  • Loading branch information
suyeshs committed Apr 18, 2024
1 parent 06b27f1 commit b6b9618
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
41 changes: 41 additions & 0 deletions src/app/lib/mongoBreeze.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { MongoClient } from 'mongodb';
import { ChartData } from '../utils/dataAggregation';

export async function fetchHistoricalData(specificStrikePrice: number, startDate: Date, endDate: Date) {
const uri = "mongodb://127.0.0.1:27017/";

//const uri = "mongodb://ns3151328.ip-151-106-34.eu:27017/";
const client = new MongoClient(uri);

try {
console.log("Connecting to MongoDB");
await client.connect();
console.log("Connected correctly to server");
const db = client.db('tradepod');

// Define the query object with your criteria
const query = {
strikePrice: specificStrikePrice,
date: {
$gte: startDate,
$lte: endDate
}
};

console.log("Query object:", query);

// Use the query object in the find method
const chartRecords: ChartData[] = (await db.collection('historicalDataBreeze').find(query).toArray()).map(doc => ({
date: doc.datetime,
openInterest: doc.open_interest,
strikePrice: doc.strike_price,
ltp: doc.close,
optionType: doc.right,

}));
console.log("Chart Records",chartRecords)
return chartRecords;
} finally {
client.close();
}
}
2 changes: 2 additions & 0 deletions src/hooks/useSocketMobx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export const useWebSocketMobX = () => {
const socket = useRef<WebSocket | null>(null);
const accumulatedData = useRef<OptionData[]>([]);
const url = 'ws://tradepodsocket-vzpocpxkaa-uc.a.run.app/tradepod';
//const url = 'ws://127.0.0.1:8888/tradepod';


const connectWebSocket = useCallback(() => {
// Close existing socket connection if any
Expand Down

0 comments on commit b6b9618

Please sign in to comment.