firstock 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Readme.md ADDED
@@ -0,0 +1,290 @@
1
+ # The Firstock Developer API Nodejs client -
2
+
3
+ To communicate with the Firstock Developer API using Nodejs, you can use the official Nodejs client library provided by Firstock.
4
+ `<br />` Licensed under the MIT License.
5
+
6
+
7
+ [Version - 1.0.0](https://www.npmjs.com/package/firstock)
8
+
9
+
10
+ ## Documentation
11
+
12
+ * Nodejs client documentation
13
+
14
+ ## v3 - Changes
15
+
16
+ * Error code response structured has been changed
17
+ * Renamed
18
+
19
+ ## Installing the client
20
+
21
+ Use the package manager [npm](https://www.npmjs.com/) to install thefirstock.
22
+
23
+ ```bash
24
+ npm install firstock
25
+ ```
26
+
27
+ ## API usage
28
+
29
+ ```javascript
30
+ const Firstock = require("firstock");
31
+
32
+ const firstock = new Firstock();
33
+
34
+ // Login
35
+ firstock.login({
36
+ userId: "",
37
+ password: "",
38
+ TOTP: "",
39
+ DOBnPAN: "",
40
+ vendorCode: "",
41
+ apiKey: ""
42
+ }, (err, result) => {
43
+ console.log("login Error, ", err);
44
+ console.log("login Result: ", result);
45
+ });
46
+
47
+ // Place an Order
48
+ firstock.placeOrder({
49
+ userId: "",
50
+ exchange: "",
51
+ tradingSymbol: "",
52
+ quantity: "",
53
+ price: "",
54
+ product: "",
55
+ transactionType: "",
56
+ priceType: "",
57
+ retention: "",
58
+ triggerPrice: "",
59
+ remarks: "",
60
+ }, (err, result) => {
61
+ console.log("placeOrder Error, ", err);
62
+ console.log("placeOrder Result: ", result);
63
+ });
64
+
65
+ // Modify an Order
66
+ firstock.modifyOrder({
67
+ userId: "",
68
+ orderNumber: "",
69
+ price: "",
70
+ quantity: "",
71
+ triggerPrice: "",
72
+ tradingSymbol: "",
73
+ exchange: "",
74
+ priceType: "",
75
+ product: "",
76
+ retention: ""
77
+ }, (err, result) => {
78
+ console.log("modifyOrder Error, ", err);
79
+ console.log("modifyOrder Result: ", result);
80
+ });
81
+
82
+ // Cancel an Order
83
+ firstock.cancelOrder({
84
+ userId: "",
85
+ orderNumber: ""
86
+ }, (err, result) => {
87
+ console.log("cancelOrder Error, ", err);
88
+ console.log("cancelOrder Result: ", result);
89
+ });
90
+
91
+ // Single Order History
92
+ firstock.singleOrderHistory({
93
+ userId: "",
94
+ orderNumber: ""
95
+ }, (err, result) => {
96
+ console.log("singleOrderHistory Error, ", err);
97
+ console.log("singleOrderHistory Result: ", result);
98
+ });
99
+
100
+ // Order Book
101
+ firstock.orderBook({ userId: "" }, (err, result) => {
102
+ console.log("orderBook Error, ", err);
103
+ console.log("orderBook Result: ", result);
104
+ });
105
+
106
+ // Trade Book
107
+ firstock.tradeBook({ userId: "" }, (err, result) => {
108
+ console.log("tradeBook Error, ", err);
109
+ console.log("tradeBook Result: ", result);
110
+ });
111
+
112
+ // Position Book
113
+ firstock.positionBook({ userId: "" }, (err, result) => {
114
+ console.log("positionBook Error, ", err);
115
+ console.log("positionBook Result: ", result);
116
+ });
117
+
118
+ // Holdings
119
+ firstock.holdings({ userId: "" }, (err, result) => {
120
+ console.log("holdings Error, ", err);
121
+ console.log("holdings Result: ", result);
122
+ });
123
+
124
+ // Limits
125
+ firstock.limit({ userId: "" }, (err, result) => {
126
+ console.log("limit Error, ", err);
127
+ console.log("limit Result: ", result);
128
+ });
129
+
130
+ // Order Margin
131
+ firstock.orderMargin({
132
+ userId: "",
133
+ exchange: "",
134
+ tradingSymbol: "",
135
+ quantity: "",
136
+ price: "",
137
+ product: "",
138
+ transactionType: "",
139
+ priceType: ""
140
+ }, (err, result) => {
141
+ console.log("orderMargin Error, ", err);
142
+ console.log("orderMargin Result: ", result);
143
+ });
144
+
145
+ // Basket Margin
146
+ firstock.basketMargin({
147
+ userId: "",
148
+ exchange: "",
149
+ transactionType: "",
150
+ product: "",
151
+ tradingSymbol: "",
152
+ quantity: "",
153
+ priceType: "",
154
+ price: "",
155
+ BasketList_Params: [ /* array of order objects */ ]
156
+ }, (err, result) => {
157
+ console.log("basketMargin Error, ", err);
158
+ console.log("basketMargin Result: ", result);
159
+ });
160
+
161
+ // Product Conversion
162
+ firstock.productConversion({
163
+ userId: "",
164
+ exchange: "",
165
+ tradingSymbol: "",
166
+ quantity: "",
167
+ product: "",
168
+ previousProduct: ""
169
+ }, (err, result) => {
170
+ console.log("productConversion Error, ", err);
171
+ console.log("productConversion Result: ", result);
172
+ });
173
+
174
+ // Brokerage Calculator
175
+ firstock.brokerageCalculator({
176
+ userId: "",
177
+ exchange: "",
178
+ tradingSymbol: "",
179
+ transactionType: "",
180
+ Product: "",
181
+ quantity: "",
182
+ price: "",
183
+ strike_price: "",
184
+ inst_name: "",
185
+ lot_size: ""
186
+ }, (err, result) => {
187
+ console.log("brokerageCalculator Error, ", err);
188
+ console.log("brokerageCalculator Result: ", result);
189
+ });
190
+
191
+ // Get Quote
192
+ firstock.getQuote({
193
+ userId: "",
194
+ exchange: "",
195
+ tradingSymbol: ""
196
+ }, (err, result) => {
197
+ console.log("getQuote Error, ", err);
198
+ console.log("getQuote Result: ", result);
199
+ });
200
+
201
+ // Get LTP
202
+ firstock.getQuoteltp({
203
+ userId: "",
204
+ exchange: "",
205
+ tradingSymbol: ""
206
+ }, (err, result) => {
207
+ console.log("getQuoteltp Error, ", err);
208
+ console.log("getQuoteltp Result: ", result);
209
+ });
210
+
211
+ // Get Multi Quotes
212
+ firstock.getMultiQuotes({
213
+ userId: "",
214
+ data: [
215
+ { exchange: "", tradingSymbol: "" },
216
+ // more symbols
217
+ ]
218
+ }, (err, result) => {
219
+ console.log("getMultiQuotes Error, ", err);
220
+ console.log("getMultiQuotes Result: ", result);
221
+ });
222
+
223
+ // Get Multi Quotes LTP
224
+ firstock.getMultiQuotesltp({
225
+ userId: "",
226
+ data: [
227
+ { exchange: "", tradingSymbol: "" },
228
+ // more symbols
229
+ ]
230
+ }, (err, result) => {
231
+ console.log("getMultiQuotesltp Error, ", err);
232
+ console.log("getMultiQuotesltp Result: ", result);
233
+ });
234
+
235
+ // Get Index List
236
+ firstock.indexList({ userId: "", exchange: "" }, (err, result) => {
237
+ console.log("indexList Error, ", err);
238
+ console.log("indexList Result: ", result);
239
+ });
240
+
241
+ // Get Expiry
242
+ firstock.getExpiry({
243
+ userId: "",
244
+ exchange: "",
245
+ tradingSymbol: ""
246
+ }, (err, result) => {
247
+ console.log("getExpiry Error, ", err);
248
+ console.log("getExpiry Result: ", result);
249
+ });
250
+
251
+ // Option Chain
252
+ firstock.optionChain({
253
+ userId: "",
254
+ exchange: "",
255
+ symbol: "",
256
+ expiry: "",
257
+ count: "",
258
+ strikePrice: ""
259
+ }, (err, result) => {
260
+ console.log("optionChain Error, ", err);
261
+ console.log("optionChain Result: ", result);
262
+ });
263
+
264
+ // Search Scrips
265
+ firstock.searchScrips({ userId: "", stext: "" }, (err, result) => {
266
+ console.log("searchScrips Error, ", err);
267
+ console.log("searchScrips Result: ", result);
268
+ });
269
+
270
+ // Historical Data
271
+ firstock.timePriceSeries({
272
+ userId: "",
273
+ exchange: "",
274
+ tradingSymbol: "",
275
+ startTime: "",
276
+ endTime: "",
277
+ interval: ""
278
+ }, (err, result) => {
279
+ console.log("timePriceSeries Error, ", err);
280
+ console.log("timePriceSeries Result: ", result);
281
+ });
282
+ ```
283
+
284
+ Refer to the [Firstock Connect Documentation](https://connect.thefirstock.com/) for the complete list of supported methods.
285
+
286
+
287
+
288
+ ## Changelog
289
+
290
+ Check release notes.
package/config.json ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+
3
+ }
@@ -0,0 +1,227 @@
1
+ interface Response {
2
+ data: {
3
+ [key: string]: any;
4
+ };
5
+ }
6
+ interface LoginParams {
7
+ userId: string;
8
+ password: string;
9
+ TOTP: string;
10
+ vendorCode: string;
11
+ apiKey: string;
12
+ [key: string]: any;
13
+ }
14
+ interface PlaceOrderParams {
15
+ userId: string;
16
+ exchange: string;
17
+ tradingSymbol: string;
18
+ quantity: string | number;
19
+ price: string | number;
20
+ product: string;
21
+ transactionType: string;
22
+ priceType: string;
23
+ retention: string;
24
+ remarks: string;
25
+ triggerPrice: string;
26
+ [key: string]: any;
27
+ }
28
+ interface CancelOrderParams {
29
+ userId: string;
30
+ orderNumber: string;
31
+ [key: string]: any;
32
+ }
33
+ interface ModifyOrderParams {
34
+ userId: string;
35
+ orderNumber: string;
36
+ price: string | number;
37
+ quantity: string | number;
38
+ triggerPrice: string | number;
39
+ tradingSymbol: string;
40
+ exchange: string;
41
+ priceType: string;
42
+ product: string;
43
+ retention: string;
44
+ [key: string]: any;
45
+ }
46
+ interface BasketItem {
47
+ exchange: string;
48
+ transactionType: string;
49
+ product: string;
50
+ tradingSymbol: string;
51
+ quantity: string | number;
52
+ priceType: string;
53
+ price: string | number;
54
+ [key: string]: any;
55
+ }
56
+ interface BasketMarginParams {
57
+ userId: string;
58
+ BasketList_Params: BasketItem[];
59
+ [key: string]: any;
60
+ }
61
+ interface SingleOrderHistoryParams {
62
+ userId: string;
63
+ orderNumber: string;
64
+ [key: string]: any;
65
+ }
66
+ interface UserDetailsParams {
67
+ userId: string;
68
+ [key: string]: any;
69
+ }
70
+ interface OrderMarginParams {
71
+ userId: string;
72
+ exchange: string;
73
+ tradingSymbol: string;
74
+ quantity: string | number;
75
+ price: string | number;
76
+ product: string;
77
+ transactionType: string;
78
+ priceType: string;
79
+ [key: string]: any;
80
+ }
81
+ interface ProductConversionParams {
82
+ userId: string;
83
+ exchange: string;
84
+ tradingSymbol: string;
85
+ quantity: string | number;
86
+ product: string;
87
+ previousProduct: string;
88
+ transactionType?: string;
89
+ positionType?: string;
90
+ [key: string]: any;
91
+ }
92
+ interface OrderBookParams {
93
+ userId: string;
94
+ [key: string]: any;
95
+ }
96
+ interface TradeBookParams {
97
+ userId: string;
98
+ [key: string]: any;
99
+ }
100
+ interface PositionsBookParams {
101
+ userId: string;
102
+ [key: string]: any;
103
+ }
104
+ interface MultiQuoteItem {
105
+ exchange: string;
106
+ tradingSymbol: string;
107
+ [key: string]: any;
108
+ }
109
+ interface GetMultiQuotesParams {
110
+ userId: string;
111
+ data: MultiQuoteItem[];
112
+ [key: string]: any;
113
+ }
114
+ interface GetQuoteLTPParams {
115
+ userId: string;
116
+ exchange: string;
117
+ tradingSymbol: string;
118
+ [key: string]: any;
119
+ }
120
+ interface GetMultiQuotesLTPParams {
121
+ userId: string;
122
+ data: MultiQuoteItem[];
123
+ [key: string]: any;
124
+ }
125
+ interface SearchScriptsParams {
126
+ userId: string;
127
+ stext: string;
128
+ [key: string]: any;
129
+ }
130
+ interface GetSecurityInfoParams {
131
+ userId: string;
132
+ exchange: string;
133
+ tradingSymbol: string;
134
+ [key: string]: any;
135
+ }
136
+ interface HoldingsParams {
137
+ userId: string;
138
+ product?: string;
139
+ [key: string]: any;
140
+ }
141
+ interface LimitsParams {
142
+ userId: string;
143
+ [key: string]: any;
144
+ }
145
+ interface GetQuotesParams {
146
+ userId: string;
147
+ exchange: string;
148
+ tradingSymbol: string;
149
+ [key: string]: any;
150
+ }
151
+ interface GetIndexListParams {
152
+ userId: string;
153
+ exchange: string;
154
+ [key: string]: any;
155
+ }
156
+ interface GetOptionChainParams {
157
+ userId: string;
158
+ exchange: string;
159
+ symbol: string;
160
+ strikePrice: string | number;
161
+ count: string | number;
162
+ expiry?: string;
163
+ [key: string]: any;
164
+ }
165
+ interface TimePriceSeriesParams {
166
+ userId: string;
167
+ exchange: string;
168
+ tradingSymbol: string;
169
+ endTime: string;
170
+ startTime: string;
171
+ interval: string | number;
172
+ [key: string]: any;
173
+ }
174
+ interface BrokerageCalculatorParams {
175
+ userId: string;
176
+ exchange: string;
177
+ tradingSymbol: string;
178
+ transactionType: string;
179
+ Product: string;
180
+ quantity: string | number;
181
+ price: string | number;
182
+ strike_price: string | number;
183
+ inst_name: string;
184
+ lot_size: string | number;
185
+ [key: string]: any;
186
+ }
187
+ interface GetExpiryParams {
188
+ userId: string;
189
+ exchange: string;
190
+ tradingSymbol: string;
191
+ [key: string]: any;
192
+ }
193
+ declare abstract class AFirstock {
194
+ constructor();
195
+ abstract getPosts(): Promise<any>;
196
+ abstract getUsers(): any;
197
+ abstract getPostByUserId(): any;
198
+ abstract login(params: LoginParams, callBack: (error: Error | null, result: Response | null) => void): void;
199
+ abstract logout(params: {
200
+ userId: string;
201
+ }, callBack: (error: Error | string | null, result: Response | null) => void): void;
202
+ abstract userDetails(params: UserDetailsParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
203
+ abstract placeOrder(params: PlaceOrderParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
204
+ abstract orderMargin(params: OrderMarginParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
205
+ abstract cancelOrder(params: CancelOrderParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
206
+ abstract modifyOrder(params: ModifyOrderParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
207
+ abstract singleOrderHistory(params: SingleOrderHistoryParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
208
+ abstract orderBook(params: OrderBookParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
209
+ abstract tradeBook(params: TradeBookParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
210
+ abstract positionBook(params: PositionsBookParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
211
+ abstract productConversion(params: ProductConversionParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
212
+ abstract holdings(params: HoldingsParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
213
+ abstract limit(params: LimitsParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
214
+ abstract basketMargin(params: BasketMarginParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
215
+ abstract getQuote(params: GetQuotesParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
216
+ abstract getQuoteltp(params: GetQuoteLTPParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
217
+ abstract getMultiQuotesltp(params: GetMultiQuotesLTPParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
218
+ abstract getMultiQuotes(params: GetMultiQuotesParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
219
+ abstract searchScrips(params: SearchScriptsParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
220
+ abstract securityInfo(params: GetSecurityInfoParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
221
+ abstract indexList(params: GetIndexListParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
222
+ abstract optionChain(params: GetOptionChainParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
223
+ abstract timePriceSeries(params: TimePriceSeriesParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
224
+ abstract getExpiry(params: GetExpiryParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
225
+ abstract brokerageCalculator(params: BrokerageCalculatorParams, callBack: (error: Error | string | null, result: Response | null) => void): void;
226
+ }
227
+ export default AFirstock;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class AFirstock {
4
+ constructor() {
5
+ if (this.constructor === AFirstock) {
6
+ throw new Error("Abstract classes can't be instantiated.");
7
+ }
8
+ }
9
+ }
10
+ exports.default = AFirstock;