finvasia-extra
Advanced tools
Comparing version 1.2.1 to 1.2.2
@@ -1,2 +0,2 @@ | ||
export type FinvasiaOriginalOrderType = 'MKT'; | ||
export declare type FinvasiaOriginalOrderType = 'MKT'; | ||
export declare function TransformOrderType(): PropertyDecorator; |
import ApiRequest from './ApiRequest'; | ||
import { CreateOrderParams, ExchangeType, ModifyOrderParams, OrderType, PositionResponseItem, ProductType, TransactionType } from './types'; | ||
import { CreateOrderParams, ExchangeType, GetTimeSeriesParams, GetTimeSeriesResponse, ModifyOrderParams, OrderType, PositionResponseItem, ProductType, TransactionType } from './types'; | ||
export interface SearchParams { | ||
@@ -65,3 +65,3 @@ exchange: ExchangeType; | ||
} | ||
type OrderHistoryResponse = OrderHistoryResponseItem[]; | ||
declare type OrderHistoryResponse = OrderHistoryResponseItem[]; | ||
declare class RestAPI { | ||
@@ -78,2 +78,3 @@ static routes: { | ||
"positions.book": string; | ||
"market.series": string; | ||
}; | ||
@@ -95,2 +96,3 @@ static baseURL: string; | ||
getOrders(): Promise<OrderHistoryResponse>; | ||
getTimeSeries(params: GetTimeSeriesParams): Promise<GetTimeSeriesResponse>; | ||
getOrderHistory(orderId: string): Promise<any>; | ||
@@ -97,0 +99,0 @@ getPositionsBook(): Promise<PositionResponseItem[]>; |
@@ -121,2 +121,16 @@ "use strict"; | ||
} | ||
getTimeSeries(params) { | ||
var _a, _b; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const data = yield this.apiRequest.post('market.series', {}, { | ||
uid: this.userId, | ||
exch: params.exchange, | ||
token: params.token, | ||
st: (_a = params.startTime) === null || _a === void 0 ? void 0 : _a.toString(), | ||
et: (_b = params.endTime) === null || _b === void 0 ? void 0 : _b.toString(), | ||
intrv: params.interval, | ||
}); | ||
return data.map((item) => new types_1.GetTimeSeriesResponseItem(item)); | ||
}); | ||
} | ||
getOrderHistory(orderId) { | ||
@@ -167,2 +181,3 @@ return __awaiter(this, void 0, void 0, function* () { | ||
placeOrder(params) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -184,5 +199,5 @@ let parsed; | ||
trantype: parsed.transactionType, | ||
qty: parsed.quantity, | ||
prc: parsed.price, | ||
trgprc: parsed.triggerPrice, | ||
qty: parsed.quantity.toString(), | ||
prc: parsed.price.toString(), | ||
trgprc: (_a = parsed.triggerPrice) === null || _a === void 0 ? void 0 : _a.toString(), | ||
dscqty: parsed.disclosedQuantity, | ||
@@ -189,0 +204,0 @@ prd: parsed.product, |
@@ -10,3 +10,4 @@ { | ||
"market.search": "/SearchScrip", | ||
"positions.book": "/PositionBook" | ||
"positions.book": "/PositionBook", | ||
"market.series": "/TPSeries" | ||
} |
@@ -1,3 +0,3 @@ | ||
export type ExchangeType = 'NSE' | 'NFO' | 'BSE'; | ||
export type TransactionType = 'S' | 'B'; | ||
export declare type ExchangeType = 'NSE' | 'NFO' | 'BSE'; | ||
export declare type TransactionType = 'S' | 'B'; | ||
/** | ||
@@ -8,3 +8,3 @@ * NRML - M | ||
*/ | ||
export type ProductType = 'M' | 'I' | 'C'; | ||
export type OrderType = 'MKT' | 'LMT' | 'SL-LMT' | 'SL-MKT'; | ||
export declare type ProductType = 'M' | 'I' | 'C'; | ||
export declare type OrderType = 'MKT' | 'LMT' | 'SL-LMT' | 'SL-MKT'; |
export * from './common'; | ||
export * from './order'; | ||
export * from './timeseries.types'; |
@@ -19,1 +19,2 @@ "use strict"; | ||
__exportStar(require("./order"), exports); | ||
__exportStar(require("./timeseries.types"), exports); |
@@ -40,3 +40,3 @@ { | ||
"types": "dist/index.d.ts", | ||
"version": "1.2.1" | ||
"version": "1.2.2" | ||
} |
@@ -8,2 +8,6 @@ import { string, z } from 'zod'; | ||
ExchangeType, | ||
GetOriginalTimeSeriesResponseItem, | ||
GetTimeSeriesParams, | ||
GetTimeSeriesResponse, | ||
GetTimeSeriesResponseItem, | ||
ModifyOrderParams, | ||
@@ -221,2 +225,19 @@ OrderType, | ||
async getTimeSeries(params: GetTimeSeriesParams): Promise<GetTimeSeriesResponse> { | ||
const data = await this.apiRequest.post( | ||
'market.series', | ||
{}, | ||
{ | ||
uid: this.userId, | ||
exch: params.exchange, | ||
token: params.token, | ||
st: params.startTime?.toString(), | ||
et: params.endTime?.toString(), | ||
intrv: params.interval, | ||
} | ||
); | ||
return data.map((item: GetOriginalTimeSeriesResponseItem) => new GetTimeSeriesResponseItem(item)); | ||
} | ||
async getOrderHistory(orderId: string) { | ||
@@ -281,5 +302,5 @@ if (!orderId) { | ||
trantype: parsed.transactionType, | ||
qty: parsed.quantity, | ||
prc: parsed.price, | ||
trgprc: parsed.triggerPrice, | ||
qty: parsed.quantity.toString(), | ||
prc: parsed.price.toString(), | ||
trgprc: parsed.triggerPrice?.toString(), | ||
dscqty: parsed.disclosedQuantity, | ||
@@ -286,0 +307,0 @@ prd: parsed.product, |
@@ -10,3 +10,4 @@ { | ||
"market.search": "/SearchScrip", | ||
"positions.book": "/PositionBook" | ||
"positions.book": "/PositionBook", | ||
"market.series": "/TPSeries" | ||
} |
export * from './common'; | ||
export * from './order'; | ||
export * from './timeseries.types'; |
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
72859
70
2100