diff --git a/public/index.html b/public/index.html
index a4a7ee1..263871e 100644
--- a/public/index.html
+++ b/public/index.html
@@ -328,12 +328,9 @@ async function loadMarket(){
{key:'USDINR', label:'INR/USD', unit:'\u20b9'},
];
const map=Object.fromEntries(data.map(q=>[q.key,q]));
- grid.innerHTML=SLOTS.map(slot=>{
+ if(!window._mktCache)window._mktCache={};(data||[]).forEach(function(q){window._mktCache[q.key]=q;});grid.innerHTML=SLOTS.map(slot=>{
const q=map[slot.key];
- if(!q){
- // Placeholder — keep slot, show last known or dash
- return '
'+slot.label+'
'+
diff --git a/src/angel/client.ts b/src/angel/client.ts
index 6003b8d..a77021c 100644
--- a/src/angel/client.ts
+++ b/src/angel/client.ts
@@ -61,9 +61,9 @@ function normalisePosition(p: AngelPosition): Position | null {
const ltp = parseFloat(p.ltp) || 0;
const unrealised = parseFloat(p.unrealised) || 0;
const realised = parseFloat(p.realised) || 0;
- const netAmount = parseFloat(p.netamount) || 0;
- // avgPrice = total cost / qty (approximate, fine for display)
- const avgPrice = netqty !== 0 ? Math.abs(netAmount / netqty) : 0;
+ const netprice = parseFloat(p.netprice) || 0;
+ const cfAvg = netqty > 0 ? (parseFloat(p.cfbuyavgprice)||0) : (parseFloat(p.cfsellavgprice)||0);
+ const avgPrice = netprice || Math.abs(cfAvg) || 0;
return {
key: `${p.exchange}:${p.tradingsymbol}`,
diff --git a/src/angel/market.ts b/src/angel/market.ts
index 3dc4257..6873f1d 100644
--- a/src/angel/market.ts
+++ b/src/angel/market.ts
@@ -15,6 +15,8 @@ const INDEX_TOKENS = [
{ key: 'NIFTY50', exchange: 'NSE', token: '26000', label: 'NIFTY 50', unit: 'pts' },
{ key: 'BANKNIFTY', exchange: 'NSE', token: '26009', label: 'BANK NIFTY', unit: 'pts' },
{ key: 'INDIAVIX', exchange: 'NSE', token: '26017', label: 'INDIA VIX', unit: '%' },
+ { key: 'CRUDEOIL', exchange: 'MCX', token: '234230', label: 'Crude Oil', unit: '₹/bbl' },
+ { key: 'USDINR', exchange: 'CDS', token: '1', label: 'INR/USD', unit: '₹' },
];
async function searchToken(exchange: string, query: string): Promise
{
@@ -49,19 +51,14 @@ function loadFromCache(): MarketQuote[] {
async function fetchFromAngel(): Promise {
const headers = await getAuthHeaders();
- const [crudeToken, usdinrToken] = await Promise.all([
- searchToken('MCX', 'CRUDEOIL'),
- searchToken('CDS', 'USDINR'),
- ]);
-
- const tokenMap: Record = { NSE: [], BSE: [] };
+ // All tokens hardcoded - build token map directly
+ const tokenMap: Record = {};
const tokenIndex: Record = {};
for (const idx of INDEX_TOKENS) {
+ if (!tokenMap[idx.exchange]) tokenMap[idx.exchange] = [];
tokenMap[idx.exchange].push(idx.token);
tokenIndex[idx.token] = idx.key;
}
- if (crudeToken) { tokenMap['MCX'] = [crudeToken]; tokenIndex[crudeToken] = 'CRUDEOIL'; }
- if (usdinrToken) { tokenMap['CDS'] = [usdinrToken]; tokenIndex[usdinrToken] = 'USDINR'; }
const r = await axios.post(BASE + '/rest/secure/angelbroking/market/v1/quote/',
{ mode: 'FULL', exchangeTokens: tokenMap }, { headers, timeout: 8000 });