firstock 1.0.0 → 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Firstock Broking Private Limited
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/Readme.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # The Firstock Developer API Nodejs client -
2
2
 
3
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.
4
+ Licensed under the MIT License.
5
5
 
6
6
 
7
7
  [Version - 1.0.0](https://www.npmjs.com/package/firstock)
@@ -11,11 +11,6 @@ To communicate with the Firstock Developer API using Nodejs, you can use the off
11
11
 
12
12
  * Nodejs client documentation
13
13
 
14
- ## v3 - Changes
15
-
16
- * Error code response structured has been changed
17
- * Renamed
18
-
19
14
  ## Installing the client
20
15
 
21
16
  Use the package manager [npm](https://www.npmjs.com/) to install thefirstock.
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
36
36
  return (mod && mod.__esModule) ? mod : { "default": mod };
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.Firstock = void 0;
39
40
  const axios_1 = __importDefault(require("axios"));
40
41
  const sha256 = __importStar(require("sha256"));
41
42
  const AFirstock_1 = __importDefault(require("./AFirstock"));
@@ -1767,4 +1768,4 @@ class Firstock extends AFirstock_1.default {
1767
1768
  });
1768
1769
  }
1769
1770
  }
1770
- exports.default = Firstock;
1771
+ exports.Firstock = Firstock;
package/dist/index.js CHANGED
@@ -1,7 +1,3 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const Firstock_1 = __importDefault(require("./Classes/Firstock"));
7
- exports.default = Firstock_1.default;
2
+ const Firstock_1 = require("./Classes/Firstock");
3
+ module.exports = Firstock_1.Firstock;
@@ -45,7 +45,20 @@ const readData = (callback) => {
45
45
  const path = "./config.json";
46
46
  fs.readFile(path, "utf-8", (err, jsonString) => {
47
47
  if (err) {
48
- callback(err, null);
48
+ if (err.code === "ENOENT") {
49
+ // File not found: create it with "{}"
50
+ fs.writeFile(path, "{}", "utf-8", (writeErr) => {
51
+ if (writeErr) {
52
+ callback(writeErr, null);
53
+ }
54
+ else {
55
+ callback(null, {}); // Return an empty object
56
+ }
57
+ });
58
+ }
59
+ else {
60
+ callback(err, null);
61
+ }
49
62
  }
50
63
  else {
51
64
  try {
package/dist/test.js CHANGED
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const Firstock_1 = __importDefault(require("./Classes/Firstock"));
7
- const firstock = new Firstock_1.default();
6
+ const index_1 = __importDefault(require("./index"));
7
+ const firstock = new index_1.default();
8
8
  let orderNumber = "";
9
9
  const userDetails = {
10
10
  userId: "",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firstock",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Node js package for using firstock developer apis",
5
5
  "main": "dist/index.js",
6
6
  "type": "commonjs",
@@ -1,371 +0,0 @@
1
- interface Response {
2
- data: {
3
- [key: string]: any;
4
- };
5
- }
6
-
7
- interface LoginParams {
8
- userId: string;
9
- password: string;
10
- TOTP: string;
11
- vendorCode: string;
12
- apiKey: string;
13
- [key: string]: any;
14
- }
15
-
16
- interface ConfigData {
17
- [key: string]: {
18
- jKey: string;
19
- };
20
- }
21
-
22
- interface PlaceOrderParams {
23
- userId: string;
24
- exchange: string;
25
- tradingSymbol: string;
26
- quantity: string | number;
27
- price: string | number;
28
- product: string;
29
- transactionType: string;
30
- priceType: string;
31
- retention: string;
32
- remarks: string;
33
- triggerPrice: string;
34
- [key: string]: any;
35
- }
36
-
37
- interface CancelOrderParams {
38
- userId: string;
39
- orderNumber: string;
40
- [key: string]: any;
41
- }
42
-
43
- interface ModifyOrderParams {
44
- userId: string;
45
- orderNumber: string;
46
- price: string | number;
47
- quantity: string | number;
48
- triggerPrice: string | number;
49
- tradingSymbol: string;
50
- exchange: string;
51
- priceType: string;
52
- product: string;
53
- retention: string;
54
- [key: string]: any;
55
- }
56
-
57
- interface BasketItem {
58
- exchange: string;
59
- transactionType: string;
60
- product: string;
61
- tradingSymbol: string;
62
- quantity: string | number;
63
- priceType: string;
64
- price: string | number;
65
- [key: string]: any;
66
- }
67
-
68
- interface BasketMarginParams {
69
- userId: string;
70
- BasketList_Params: BasketItem[];
71
- [key: string]: any;
72
- }
73
-
74
- interface SingleOrderHistoryParams {
75
- userId: string;
76
- orderNumber: string;
77
- [key: string]: any;
78
- }
79
-
80
- interface UserDetailsParams {
81
- userId: string;
82
- [key: string]: any;
83
- }
84
-
85
- interface OrderMarginParams {
86
- userId: string;
87
- exchange: string;
88
- tradingSymbol: string;
89
- quantity: string | number;
90
- price: string | number;
91
- product: string;
92
- transactionType: string;
93
- priceType: string;
94
- [key: string]: any;
95
- }
96
-
97
- interface ProductConversionParams {
98
- userId: string;
99
- exchange: string;
100
- tradingSymbol: string;
101
- quantity: string | number;
102
- product: string;
103
- previousProduct: string;
104
- transactionType?: string;
105
- positionType?: string;
106
- [key: string]: any;
107
- }
108
-
109
- interface OrderBookParams {
110
- userId: string;
111
- [key: string]: any;
112
- }
113
-
114
- interface TradeBookParams {
115
- userId: string;
116
- [key: string]: any;
117
- }
118
-
119
- interface PositionsBookParams {
120
- userId: string;
121
- [key: string]: any;
122
- }
123
-
124
- interface MultiQuoteItem {
125
- exchange: string;
126
- tradingSymbol: string;
127
- [key: string]: any;
128
- }
129
-
130
- interface GetMultiQuotesParams {
131
- userId: string;
132
- data: MultiQuoteItem[];
133
- [key: string]: any;
134
- }
135
-
136
- interface GetQuoteLTPParams {
137
- userId: string;
138
- exchange: string;
139
- tradingSymbol: string;
140
- [key: string]: any;
141
- }
142
-
143
- interface GetMultiQuotesLTPParams {
144
- userId: string;
145
- data: MultiQuoteItem[];
146
- [key: string]: any;
147
- }
148
-
149
- interface SearchScriptsParams {
150
- userId: string;
151
- stext: string;
152
- [key: string]: any;
153
- }
154
-
155
- interface GetSecurityInfoParams {
156
- userId: string;
157
- exchange: string;
158
- tradingSymbol: string;
159
- [key: string]: any;
160
- }
161
-
162
- interface HoldingsParams {
163
- userId: string;
164
- product?: string;
165
- [key: string]: any;
166
- }
167
-
168
- interface LimitsParams {
169
- userId: string;
170
- [key: string]: any;
171
- }
172
-
173
- interface GetQuotesParams {
174
- userId: string;
175
- exchange: string;
176
- tradingSymbol: string;
177
- [key: string]: any;
178
- }
179
-
180
- interface GetIndexListParams {
181
- userId: string;
182
- exchange: string;
183
- [key: string]: any;
184
- }
185
-
186
- interface GetOptionChainParams {
187
- userId: string;
188
- exchange: string;
189
- symbol: string;
190
- strikePrice: string | number;
191
- count: string | number;
192
- expiry?: string;
193
- [key: string]: any;
194
- }
195
-
196
- interface TimePriceSeriesParams {
197
- userId: string;
198
- exchange: string;
199
- tradingSymbol: string;
200
- endTime: string;
201
- startTime: string;
202
- interval: string | number;
203
- [key: string]: any;
204
- }
205
-
206
- interface BrokerageCalculatorParams {
207
- userId: string;
208
- exchange: string;
209
- tradingSymbol: string;
210
- transactionType: string;
211
- Product: string;
212
- quantity: string | number;
213
- price: string | number;
214
- strike_price: string | number;
215
- inst_name: string;
216
- lot_size: string | number;
217
- [key: string]: any;
218
- }
219
-
220
- interface GetExpiryParams {
221
- userId: string;
222
- exchange: string;
223
- tradingSymbol: string;
224
- [key: string]: any;
225
- }
226
-
227
-
228
- abstract class AFirstock {
229
- constructor() {
230
- if (this.constructor === AFirstock) {
231
- throw new Error("Abstract classes can't be instantiated.");
232
- }
233
- }
234
-
235
- abstract getPosts(): Promise<any>;
236
-
237
- abstract getUsers(): any;
238
-
239
- abstract getPostByUserId(): any;
240
-
241
- abstract login(
242
- params: LoginParams,
243
- callBack: (error: Error | null, result: Response | null) => void
244
- ): void;
245
-
246
- abstract logout(
247
- params: { userId: string },
248
- callBack: (error: Error | string | null, result: Response | null) => void
249
- ): void;
250
-
251
- abstract userDetails(
252
- params: UserDetailsParams,
253
- callBack: (error: Error | string | null, result: Response | null) => void
254
- ): void;
255
-
256
- abstract placeOrder(
257
- params: PlaceOrderParams,
258
- callBack: (error: Error | string | null, result: Response | null) => void
259
- ): void;
260
-
261
- abstract orderMargin(
262
- params: OrderMarginParams,
263
- callBack: (error: Error | string | null, result: Response | null) => void
264
- ): void;
265
-
266
- abstract cancelOrder(
267
- params: CancelOrderParams,
268
- callBack: (error: Error | string | null, result: Response | null) => void
269
- ): void;
270
-
271
- abstract modifyOrder(
272
- params: ModifyOrderParams,
273
- callBack: (error: Error | string | null, result: Response | null) => void
274
- ): void;
275
-
276
- abstract singleOrderHistory(
277
- params: SingleOrderHistoryParams,
278
- callBack: (error: Error | string | null, result: Response | null) => void
279
- ): void;
280
- abstract orderBook(
281
- params: OrderBookParams,
282
- callBack: (error: Error | string | null, result: Response | null) => void
283
- ): void;
284
-
285
- abstract tradeBook(
286
- params: TradeBookParams,
287
- callBack: (error: Error | string | null, result: Response | null) => void
288
- ): void;
289
-
290
- abstract positionBook(
291
- params: PositionsBookParams,
292
- callBack: (error: Error | string | null, result: Response | null) => void
293
- ): void;
294
-
295
- abstract productConversion(
296
- params: ProductConversionParams,
297
- callBack: (error: Error | string | null, result: Response | null) => void
298
- ): void;
299
-
300
- abstract holdings(
301
- params: HoldingsParams,
302
- callBack: (error: Error | string | null, result: Response | null) => void
303
- ): void;
304
-
305
- abstract limit(
306
- params: LimitsParams,
307
- callBack: (error: Error | string | null, result: Response | null) => void
308
- ): void;
309
-
310
- abstract basketMargin(
311
- params: BasketMarginParams,
312
- callBack: (error: Error | string | null, result: Response | null) => void
313
- ): void;
314
-
315
- abstract getQuote(
316
- params: GetQuotesParams,
317
- callBack: (error: Error | string | null, result: Response | null) => void
318
- ): void;
319
-
320
- abstract getQuoteltp(
321
- params: GetQuoteLTPParams,
322
- callBack: (error: Error | string | null, result: Response | null) => void
323
- ): void;
324
-
325
- abstract getMultiQuotesltp(
326
- params: GetMultiQuotesLTPParams,
327
- callBack: (error: Error | string | null, result: Response | null) => void
328
- ): void;
329
-
330
- abstract getMultiQuotes(
331
- params: GetMultiQuotesParams,
332
- callBack: (error: Error | string | null, result: Response | null) => void
333
- ): void;
334
-
335
- abstract searchScrips(
336
- params: SearchScriptsParams,
337
- callBack: (error: Error | string | null, result: Response | null) => void
338
- ): void;
339
-
340
- abstract securityInfo(
341
- params: GetSecurityInfoParams,
342
- callBack: (error: Error | string | null, result: Response | null) => void
343
- ): void;
344
-
345
- abstract indexList(
346
- params: GetIndexListParams,
347
- callBack: (error: Error | string | null, result: Response | null) => void
348
- ): void;
349
-
350
- abstract optionChain(
351
- params: GetOptionChainParams,
352
- callBack: (error: Error | string | null, result: Response | null) => void
353
- ): void;
354
-
355
- abstract timePriceSeries(
356
- params: TimePriceSeriesParams,
357
- callBack: (error: Error | string | null, result: Response | null) => void
358
- ): void;
359
-
360
- abstract getExpiry(
361
- params: GetExpiryParams,
362
- callBack: (error: Error | string | null, result: Response | null) => void
363
- ): void;
364
-
365
- abstract brokerageCalculator(
366
- params: BrokerageCalculatorParams,
367
- callBack: (error: Error | string | null, result: Response | null) => void
368
- ): void;
369
- }
370
-
371
- export default AFirstock;