finvasia-extra
Advanced tools
Comparing version 1.1.9 to 1.2.0
@@ -1,2 +0,2 @@ | ||
export { default as RestAPI } from './src/RestAPI'; | ||
export { default as RestAPI, ModifyOrderParams, OrderParams } from './src/RestAPI'; | ||
export { default as WebSocket } from './src/WebSocket'; |
import ApiRequest from './ApiRequest'; | ||
interface OrderParams { | ||
export type ExchangeType = 'NSE' | 'NFO' | 'BSE'; | ||
export interface SearchParams { | ||
exchange: ExchangeType; | ||
text: string; | ||
} | ||
interface SearchResponseItem { | ||
cname: string; | ||
exch: ExchangeType; | ||
instname: string; | ||
ls: string; | ||
pp: string; | ||
ti: string; | ||
token: string; | ||
tsym: string; | ||
} | ||
interface SearchResponse { | ||
values: SearchResponseItem[]; | ||
} | ||
export interface OrderResponse { | ||
request_time: string; | ||
stat: 'Ok'; | ||
orderId: string; | ||
} | ||
export interface OrderParams { | ||
/** | ||
* NSE / NFO / CDS / MCX / BSE | ||
*/ | ||
exchange: 'NSE' | 'NFO' | 'CDS' | 'MCX' | 'BSE'; | ||
exchange: ExchangeType; | ||
tradingSymbol: string; | ||
@@ -13,9 +36,9 @@ transactionType: 'S' | 'B'; | ||
disclosedQuantity: number; | ||
product: 'C' | 'M' | 'H'; | ||
orderType: 'LMT' | 'MKT' | 'SL-LMT' | 'SL-MKT'; | ||
product: 'NRML' | 'MIS' | 'CNC'; | ||
orderType: 'M' | 'L' | 'SL' | 'SL-M'; | ||
validity?: string; | ||
tag?: string; | ||
} | ||
interface ModifyOrderParams { | ||
exchange: 'NSE' | 'NFO' | 'CDS' | 'MCX' | 'BSE'; | ||
export interface ModifyOrderParams { | ||
exchange: ExchangeType; | ||
tradingSymbol: string; | ||
@@ -25,3 +48,3 @@ quantity: number; | ||
triggerPrice?: number; | ||
orderType: 'LMT' | 'MKT' | 'SL-LMT' | 'SL-MKT'; | ||
orderType: 'M' | 'L' | 'SL' | 'SL-M'; | ||
validity?: string; | ||
@@ -38,2 +61,3 @@ } | ||
"market.quote": string; | ||
"market.search": string; | ||
}; | ||
@@ -57,3 +81,4 @@ static baseURL: string; | ||
getQuote(exchange: string, token: string): Promise<any>; | ||
placeOrder(params: OrderParams): Promise<any>; | ||
searchScript(params: SearchParams): Promise<SearchResponse>; | ||
placeOrder(params: OrderParams): Promise<OrderResponse>; | ||
cancelOrder(orderId: string): Promise<any>; | ||
@@ -60,0 +85,0 @@ modifyOrder(orderId: string, params: ModifyOrderParams): Promise<any>; |
@@ -201,2 +201,7 @@ "use strict"; | ||
} | ||
searchScript(params) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.apiRequest.post('market.search', {}, { uid: this.userId, exch: params.exchange, stext: params.text }); | ||
}); | ||
} | ||
placeOrder(params) { | ||
@@ -203,0 +208,0 @@ return __awaiter(this, void 0, void 0, function* () { |
@@ -8,3 +8,4 @@ { | ||
"orders.cancel": "/CancelOrder", | ||
"market.quote": "/GetQuotes" | ||
"market.quote": "/GetQuotes", | ||
"market.search": "/SearchScrip" | ||
} |
@@ -1,2 +0,2 @@ | ||
export { default as RestAPI } from './src/RestAPI'; | ||
export { default as RestAPI, ModifyOrderParams, OrderParams } from './src/RestAPI'; | ||
export { default as WebSocket } from './src/WebSocket'; |
@@ -33,2 +33,3 @@ { | ||
"build": "tsc", | ||
"watch:build": "tsc --watch", | ||
"prepare": "npm run build", | ||
@@ -39,3 +40,3 @@ "prepublish": "tsc", | ||
"types": "dist/index.d.ts", | ||
"version": "1.1.9" | ||
"version": "1.2.0" | ||
} |
@@ -1,2 +0,2 @@ | ||
import { z } from 'zod'; | ||
import { string, z } from 'zod'; | ||
import { sha256 } from './util'; | ||
@@ -8,7 +8,35 @@ import routes from './routes.json'; | ||
interface OrderParams { | ||
export type ExchangeType = 'NSE' | 'NFO' | 'BSE'; | ||
export interface SearchParams { | ||
exchange: ExchangeType; | ||
text: string; | ||
} | ||
interface SearchResponseItem { | ||
cname: string; | ||
exch: ExchangeType; | ||
instname: string; | ||
ls: string; | ||
pp: string; | ||
ti: string; | ||
token: string; | ||
tsym: string; | ||
} | ||
interface SearchResponse { | ||
values: SearchResponseItem[]; | ||
} | ||
export interface OrderResponse { | ||
request_time: string; | ||
stat: 'Ok'; | ||
orderId: string; | ||
} | ||
export interface OrderParams { | ||
/** | ||
* NSE / NFO / CDS / MCX / BSE | ||
*/ | ||
exchange: 'NSE' | 'NFO' | 'CDS' | 'MCX' | 'BSE'; | ||
exchange: ExchangeType; | ||
tradingSymbol: string; | ||
@@ -21,6 +49,4 @@ // S | B | ||
disclosedQuantity: number; | ||
// C / M / H | ||
product: 'C' | 'M' | 'H'; | ||
// LMT, MKT, SL-LMT, SL-MKT | ||
orderType: 'LMT' | 'MKT' | 'SL-LMT' | 'SL-MKT'; | ||
product: 'NRML' | 'MIS' | 'CNC'; | ||
orderType: 'M' | 'L' | 'SL' | 'SL-M'; | ||
validity?: string; | ||
@@ -30,4 +56,4 @@ tag?: string; | ||
interface ModifyOrderParams { | ||
exchange: 'NSE' | 'NFO' | 'CDS' | 'MCX' | 'BSE'; | ||
export interface ModifyOrderParams { | ||
exchange: ExchangeType; | ||
tradingSymbol: string; | ||
@@ -37,3 +63,3 @@ quantity: number; | ||
triggerPrice?: number; | ||
orderType: 'LMT' | 'MKT' | 'SL-LMT' | 'SL-MKT'; | ||
orderType: 'M' | 'L' | 'SL' | 'SL-M'; | ||
validity?: string; | ||
@@ -255,3 +281,7 @@ } | ||
async placeOrder(params: OrderParams) { | ||
async searchScript(params: SearchParams): Promise<SearchResponse> { | ||
return this.apiRequest.post('market.search', {}, { uid: this.userId, exch: params.exchange, stext: params.text }); | ||
} | ||
async placeOrder(params: OrderParams): Promise<OrderResponse> { | ||
let parsed; | ||
@@ -258,0 +288,0 @@ try { |
@@ -8,3 +8,4 @@ { | ||
"orders.cancel": "/CancelOrder", | ||
"market.quote": "/GetQuotes" | ||
"market.quote": "/GetQuotes", | ||
"market.search": "/SearchScrip" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
45417
1294