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/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- import Firstock from "./Classes/Firstock";
2
- export default Firstock;
@@ -1,26 +0,0 @@
1
- interface BasketMarginObject {
2
- exchange?: string;
3
- tradingSymbol?: string;
4
- quantity?: string | number;
5
- transactionType?: string;
6
- [key: string]: any;
7
- }
8
- interface JsonData {
9
- [key: string]: {
10
- jKey: string;
11
- [key: string]: any;
12
- };
13
- }
14
- declare const saveData: (data: any, file: string, callback: (err: NodeJS.ErrnoException | null) => void) => void;
15
- declare const readData: (callback: (err: Error | string | null, data: JsonData | null) => void) => void;
16
- declare const checkifUserLoggedIn: ({ userId, jsonData }: {
17
- userId: string;
18
- jsonData: JsonData;
19
- }, callback: (err: string | null, jKey: string | null) => void) => void;
20
- declare const errorMessageMapping: (jsonData: {
21
- message?: string;
22
- }) => string;
23
- declare const validateBasketMarginObject: (data: BasketMarginObject) => boolean;
24
- declare const validateBasketMargin: (data: BasketMarginObject[]) => boolean;
25
- declare const handleError: (error: any) => any;
26
- export { saveData, readData, validateBasketMarginObject, validateBasketMargin, handleError, checkifUserLoggedIn, errorMessageMapping, };
@@ -1,2 +0,0 @@
1
- declare const API_LINK = "https://api.firstock.in/V1";
2
- export { API_LINK };
package/dist/test.d.ts DELETED
@@ -1 +0,0 @@
1
- export {};
package/index.js DELETED
@@ -1,4 +0,0 @@
1
- const Firstock = require("./Classes/Firstock");
2
-
3
-
4
- module.exports = Firstock;
package/index.ts DELETED
@@ -1,4 +0,0 @@
1
- import Firstock from "./Classes/Firstock";
2
-
3
-
4
- export default Firstock;
@@ -1,99 +0,0 @@
1
- import * as fs from "fs";
2
-
3
- interface BasketMarginObject {
4
- exchange?: string;
5
- tradingSymbol?: string;
6
- quantity?: string | number;
7
- transactionType?: string;
8
- [key: string]: any;
9
- }
10
-
11
- interface JsonData {
12
- [key: string]: {
13
- jKey: string;
14
- [key: string]: any;
15
- };
16
- }
17
-
18
- const saveData = (data: any, file: string, callback: (err: NodeJS.ErrnoException | null) => void): void => {
19
- const path = "./config.json";
20
- const jsonData = JSON.stringify(data, null, 2);
21
- fs.writeFile(path, jsonData, callback);
22
- };
23
-
24
- const readData = (callback: (err: Error | string | null, data: JsonData | null) => void): void => {
25
- const path = "./config.json";
26
- fs.readFile(path, "utf-8", (err: NodeJS.ErrnoException | null, jsonString: string) => {
27
- if (err) {
28
- callback(err, null);
29
- } else {
30
- try {
31
- const data = JSON.parse(jsonString);
32
- callback(null, data);
33
- } catch (error) {
34
- callback(error as Error, null);
35
- }
36
- }
37
- });
38
- };
39
-
40
- const checkifUserLoggedIn = (
41
- { userId, jsonData }: { userId: string; jsonData: JsonData },
42
- callback: (err: string | null, jKey: string | null) => void
43
- ): void => {
44
- if (jsonData[userId]) {
45
- const jKey = jsonData[userId].jKey;
46
- callback(null, jKey);
47
- } else {
48
- callback("Please login to Firstock", null);
49
- }
50
- };
51
-
52
- const jsonErrorMessage: { [key: string]: string } = {
53
- "Unexpected end of JSON input": "Please login to Firstock",
54
- };
55
-
56
- const errorMessageMapping = (jsonData: { message?: string }): string => {
57
- return jsonErrorMessage[jsonData.message || ""] ?? jsonData.message ?? "Unknown error";
58
- };
59
-
60
- const validateBasketMarginObject = (data: BasketMarginObject): boolean => {
61
- if (
62
- data["exchange"] &&
63
- data["tradingSymbol"] &&
64
- data["quantity"] &&
65
- data["transactionType"]
66
- ) {
67
- return true;
68
- }
69
- return false;
70
- };
71
-
72
- const validateBasketMargin = (data: BasketMarginObject[]): boolean => {
73
- return data.every((a) => validateBasketMarginObject(a));
74
- };
75
-
76
- const handleError = (error: any): any => {
77
- if (error) {
78
- if (error.response) {
79
- if (error.response.data) {
80
- return error.response.data;
81
- } else {
82
- return error.response;
83
- }
84
- } else {
85
- return error;
86
- }
87
- }
88
- return "error";
89
- };
90
-
91
- export {
92
- saveData,
93
- readData,
94
- validateBasketMarginObject,
95
- validateBasketMargin,
96
- handleError,
97
- checkifUserLoggedIn,
98
- errorMessageMapping,
99
- };
@@ -1,4 +0,0 @@
1
- const API_LINK = "https://api.firstock.in/V1";
2
-
3
-
4
- export { API_LINK };
package/test.ts DELETED
@@ -1,367 +0,0 @@
1
- import Firstock from "./Classes/Firstock";
2
-
3
- const firstock = new Firstock();
4
-
5
- let orderNumber: string = "";
6
- const userDetails = {
7
- userId: "",
8
- password: "",
9
- TOTP: "",
10
- vendorCode: "",
11
- apiKey: "",
12
- };
13
- // Login and user Details start
14
- // firstock.login(
15
- // {
16
- // userId: userDetails.userId,
17
- // password: userDetails.password,
18
- // TOTP: userDetails.TOTP,
19
- // vendorCode: userDetails.vendorCode,
20
- // apiKey: userDetails.apiKey,
21
- // },
22
- // (err: Error | null, result: any) => {
23
- // console.log("Error: ", err);
24
- // console.log("Result: ", result);
25
- // }
26
- // );
27
-
28
- // // Order and report start
29
- // firstock.placeOrder(
30
- // {
31
- // userId: userDetails.userId,
32
- // exchange: "NSE",
33
- // tradingSymbol: "IDEA-EQ",
34
- // quantity: "1",
35
- // price: "7.00",
36
- // product: "C",
37
- // transactionType: "B",
38
- // priceType: "LMT",
39
- // retention: "DAY",
40
- // triggerPrice: "0",
41
- // remarks: "Add market protection",
42
- // },
43
- // (err: Error | string | null, result: any) => {
44
- // console.log("Error, ", err);
45
- // console.log("placeOrder Result: ", result);
46
- // if (result?.data?.orderNumber) {
47
- // orderNumber = result.data.orderNumber;
48
- // modifyOrder(orderNumber);
49
- // } else {
50
- // console.log("No orderNumber returned");
51
- // }
52
- // }
53
- // );
54
-
55
- // const modifyOrder = (orderNumber: string) => {
56
- // firstock.modifyOrder(
57
- // {
58
- // userId: userDetails.userId,
59
- // orderNumber: orderNumber,
60
- // price: "7.01",
61
- // quantity: "1",
62
- // triggerPrice: "0",
63
- // tradingSymbol: "IDEA-EQ",
64
- // exchange: "NSE",
65
- // priceType: "LMT",
66
- // product:"C",
67
- // retention:"DAY"
68
- // },
69
- // (err: Error | string | null, result: any) => {
70
- // console.log("Error, ", err);
71
- // console.log("modifyOrder Result: ", result);
72
- // if (!err) {
73
- // singleOrderHistory(orderNumber);
74
- // }
75
- // }
76
- // );
77
- // }
78
-
79
- // const singleOrderHistory = (orderNumber: string) => {
80
- // firstock.singleOrderHistory({ userId: userDetails.userId, orderNumber: orderNumber }, (err: Error | string | null, result: any) => {
81
- // console.log("Error, ", err);
82
- // console.log("singleOrderHistory Result: ", result);
83
- // if (!err) {
84
- // cancelOrder(orderNumber);
85
- // }
86
- // });
87
- // };
88
-
89
- // const cancelOrder = (orderNumber: string) => {
90
- // firstock.cancelOrder({ userId: userDetails.userId, orderNumber: orderNumber }, (err: Error | string | null, result: any) => {
91
- // console.log("Error, ", err);
92
- // console.log("Cancel Result: ", result);
93
- // });
94
- // };
95
-
96
- // // Get User Details
97
- // firstock.userDetails(
98
- // { userId: userDetails.userId },
99
- // (err: Error | string | null, result: any) => {
100
- // console.log("getUserDetails Error, ", err);
101
- // console.log("getUserDetails Result: ", result);
102
- // }
103
- // );
104
-
105
- // // Order Margin
106
- // firstock.orderMargin(
107
- // {
108
- // userId: userDetails.userId,
109
- // exchange: "NSE",
110
- // tradingSymbol: "IDEA-EQ",
111
- // quantity: "1",
112
- // price: "10.00",
113
- // product: "C",
114
- // transactionType: "B",
115
- // priceType: "LMT",
116
- // },
117
- // (err: Error | string | null, result: any) => {
118
- // console.log("orderMargin Error, ", err);
119
- // console.log("orderMargin Result: ", result);
120
- // }
121
- // );
122
-
123
- // // Order Book
124
- // firstock.orderBook(
125
- // { userId: userDetails.userId },
126
- // (err: Error | string | null, result: any) => {
127
- // console.log("Error, ", err);
128
- // console.log("orderBook Result: ", result);
129
- // }
130
- // );
131
-
132
- // // Trade Book
133
- // firstock.tradeBook(
134
- // { userId: userDetails.userId },
135
- // (err: Error | string | null, result: any) => {
136
- // console.log("tradeBook Error, ", err);
137
- // console.log("tradeBook Result: ", result);
138
- // }
139
- // );
140
-
141
- // // Positions Book
142
- // firstock.positionBook(
143
- // { userId: userDetails.userId },
144
- // (err: Error | string | null, result: any) => {
145
- // console.log("positionsBook Error, ", err);
146
- // console.log("positionsBook Result: ", result);
147
- // }
148
- // );
149
-
150
- // Product Conversion
151
- // firstock.productConversion(
152
- // {
153
- // userId: userDetails.userId,
154
- // exchange: "NFO",
155
- // tradingSymbol: "NIFTY",
156
- // quantity: "250",
157
- // product: "C",
158
- // previousProduct: "I"
159
- // },
160
- // (err: Error | string | null, result: any) => {
161
- // console.log("productConversion Error, ", err);
162
- // console.log("productConversion Result: ", result);
163
- // }
164
- // );
165
-
166
- // Holdings
167
- // firstock.holdings(
168
- // { userId: userDetails.userId},//, product: "C"
169
- // (err: Error | string | null, result: any) => {
170
- // console.log("holdings Error, ", err);
171
- // console.log("holdings Result: ", result);
172
- // }
173
- // );
174
-
175
- // Limits
176
- // firstock.limit(
177
- // { userId: userDetails.userId },
178
- // (err: Error | string | null, result: any) => {
179
- // console.log("Error, ", err);
180
- // console.log("limits Result: ", result);
181
- // }
182
- // );
183
-
184
- // Basket Margin
185
- // firstock.basketMargin(
186
- // {
187
- // userId: userDetails.userId,
188
- // exchange: "NSE",
189
- // transactionType: "B",
190
- // product: "C",
191
- // tradingSymbol: "RELIANCE-EQ",
192
- // quantity: "1",
193
- // priceType: "MKT",
194
- // price: "0",
195
- // BasketList_Params: [
196
- // {
197
- // exchange: "NSE",
198
- // transactionType: "B",
199
- // product: "C",
200
- // tradingSymbol: "IDEA-EQ",
201
- // quantity: "1",
202
- // priceType: "MKT",
203
- // price: "0"
204
- // }
205
- // ],
206
- // },
207
- // (err: Error | string | null, result: any) => {
208
- // console.log("basketMargin Error, ", err);
209
- // console.log("basketMargin Result: ", result);
210
- // }
211
- // );
212
- // Get Quotes
213
- // firstock.getQuote(
214
- // {
215
- // userId: userDetails.userId,
216
- // exchange: "NSE",
217
- // tradingSymbol: "IDEA-EQ",
218
- // },
219
- // (err: Error | string | null, result: any) => {
220
- // console.log("getQuotes Error, ", err);
221
- // console.log("getQuotes Result: ", result);
222
- // }
223
- // );
224
-
225
- // Get Quote LTP
226
- // firstock.getQuoteltp(
227
- // {
228
- // userId: userDetails.userId,
229
- // exchange: "NSE",
230
- // tradingSymbol: "RELIANCE-EQ",
231
- // },
232
- // (err: Error | string | null, result: any) => {
233
- // console.log("getQuoteltp Error, ", err);
234
- // console.log("getQuoteltp Result: ", result);
235
- // }
236
- // );
237
-
238
- // Get Multi Quotes
239
- // firstock.getMultiQuotes(
240
- // {
241
- // userId: userDetails.userId,
242
- // data: [
243
- // { exchange: "NSE", tradingSymbol: "Nifty 50" },
244
- // { exchange: "NSE", tradingSymbol: "NIFTY03APR25C23500" },
245
- // { exchange: "NFO", tradingSymbol: "Nifty 50" },
246
- // { exchange: "NFO", tradingSymbol: "NIFTY03APR25C23500" },
247
- // ],
248
- // },
249
- // (err: Error | string | null, result: any) => {
250
- // console.log("getMultiQuotes Error, ", err);
251
- // console.log("getMultiQuotes Result: ", result);
252
- // }
253
- // );
254
-
255
- // Get Multi Quotes LTP
256
- // firstock.getMultiQuotesltp(
257
- // {
258
- // userId: userDetails.userId,
259
- // data: [{ exchange: "NSE", tradingSymbol: "Nifty 50" }],
260
- // },
261
- // (err: Error | string | null, result: any) => {
262
- // console.log("getMultiQuotesltp Error, ", err);
263
- // console.log("getMultiQuotesltp Result: ", result);
264
- // }
265
- // );
266
-
267
- // Search Scripts
268
- // firstock.searchScrips(
269
- // { userId: userDetails.userId, stext: "ITC" },
270
- // (err: Error | string | null, result: any) => {
271
- // console.log("searchScripts Error, ", err);
272
- // console.log("searchScripts Result: ", result);
273
- // }
274
- // );
275
-
276
- // firstock.securityInfo(
277
- // {
278
- // userId: userDetails.userId,
279
- // exchange: "NSE",
280
- // tradingSymbol: "NIFTY",
281
- // },
282
- // (err: Error | string | null, result: any) => {
283
- // console.log("getSecurityInfo Error, ", err);
284
- // console.log("getSecurityInfo Result: ", result);
285
- // }
286
- // );
287
-
288
- // Get Index List
289
- // firstock.indexList(
290
- // { userId: userDetails.userId, exchange: "NSE" },
291
- // (err: Error | string | null, result: any) => {
292
- // console.log("getIndexList Error, ", err);
293
- // console.log("getIndexList Result: ", result);
294
- // }
295
- // );
296
-
297
- // Get Option Chain
298
- // firstock.optionChain(
299
- // {
300
- // userId: userDetails.userId,
301
- // exchange: "NFO",
302
- // symbol: "NIFTY",
303
- // expiry: "17APR25",
304
- // count: "5",
305
- // strikePrice: "23150"
306
- // },
307
- // (err: Error | string | null, result: any) => {
308
- // console.log("optionChain Error, ", err);
309
- // console.log("optionChain Result: ", result);
310
- // }
311
- // );
312
-
313
-
314
- // firstock.timePriceSeries(
315
- // {
316
- // userId: userDetails.userId,
317
- // exchange: "NSE",
318
- // tradingSymbol: "NIFTY",
319
- // startTime: "09:15:00 23-04-2025",
320
- // endTime: "15:29:00 23-04-2025",
321
- // interval: "1mi",
322
- // },
323
- // (err: Error | string | null, result: any) => {
324
- // console.log("timePriceSeries Error, ", err);
325
- // console.log("timePriceSeries Result: ", result);
326
- // }
327
- // );
328
-
329
- // firstock.getExpiry(
330
- // {
331
- // userId: userDetails.userId,
332
- // exchange: "NSE",
333
- // tradingSymbol: "NIFTY"
334
- // },
335
- // (err: Error | string | null, result: any) => {
336
- // console.log("getExpiry Error, ", err);
337
- // console.log("getExpiry Result: ", result);
338
- // }
339
- // );
340
-
341
- // firstock.brokerageCalculator(
342
- // {
343
- // userId: userDetails.userId,
344
- // exchange: "NFO",
345
- // tradingSymbol: "RELIANCE27FEB25F",
346
- // transactionType: "B",
347
- // Product: "M",
348
- // quantity: "500",
349
- // price: "125930",
350
- // strike_price: "0",
351
- // inst_name: "FUTSTK",
352
- // lot_size: "1"
353
- // },
354
- // (err: Error | string | null, result: any) => {
355
- // console.log("brokerageCalculator Error, ", err);
356
- // console.log("brokerageCalculator Result: ", result)
357
- // }
358
- // )
359
-
360
- // Logout
361
- // firstock.logout(
362
- // { userId: userDetails.userId },
363
- // (err: Error | string | null, result: any) => {
364
- // console.log("Error, ", err);
365
- // console.log("Result: ", result);
366
- // }
367
- // );
package/tsconfig.json DELETED
@@ -1,15 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "declaration": true,
4
- "target": "es6",
5
- "module": "commonjs",
6
- "outDir": "./dist",
7
- "rootDir": "./",
8
- "strict": true,
9
- "esModuleInterop": true, // Add or enable this
10
- "skipLibCheck": true,
11
- "resolveJsonModule": true
12
- },
13
- "include": ["**/*.ts", "test.ts"],
14
- "exclude": ["node_modules"]
15
- }