fyers-apiv3 3.1.8__py3-none-any.whl → 3.1.9__py3-none-any.whl

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.
fyers_apiv3/fyersModel.py CHANGED
@@ -43,7 +43,19 @@ class Config:
43
43
  logout = "/logout"
44
44
  price_alert ="/price-alert"
45
45
  toggle_alert = "/toggle-alert"
46
- triggered_alerts = "/triggered-alerts"
46
+ create_smartorder_step ="/smart-order/step"
47
+ create_smartorder_limit ="/smart-order/limit"
48
+ create_smartorder_trail ="/smart-order/trail"
49
+ create_smartorder_sip ="/smart-order/sip"
50
+ modify_smartorder="/smart-order/modify"
51
+ cancel_smartorder="/smart-order/cancel"
52
+ pause_smartorder="/smart-order/pause"
53
+ resume_smartorder="/smart-order/resume"
54
+ smartorder_orderbook="/smart-order/orderbook"
55
+ smartexit_trigger="/flows/tc/se"
56
+ activate_smartexit_trigger="/flows/tc/se/activate"
57
+
58
+
47
59
 
48
60
 
49
61
 
@@ -55,12 +67,14 @@ class FyersServiceSync:
55
67
 
56
68
  Args:
57
69
  logger: The logger object used for logging errors.
70
+ request_logger: The logger object used for logging requests.
58
71
  """
59
72
  self.api_logger = logger
60
73
  self.request_logger = request_logger
61
74
  self.content = "application/json"
62
75
  self.error_resp = {"s":"error", "code": 0 , "message":"Bad request"}
63
76
  self.error_message = "invalid input please check your input"
77
+ self.session = requests.Session()
64
78
 
65
79
 
66
80
  def post_call(self, api: str, header: str, data=None) -> dict:
@@ -77,7 +91,7 @@ class FyersServiceSync:
77
91
  """
78
92
  try:
79
93
  URL = Config.API + api
80
- response = requests.post(
94
+ response = self.session.post(
81
95
  URL,
82
96
  data=json.dumps(data),
83
97
  headers={"Authorization": header, "Content-Type": self.content ,"version": "3"},
@@ -133,7 +147,7 @@ class FyersServiceSync:
133
147
  if data is not None:
134
148
  url_params = urllib.parse.urlencode(data)
135
149
  URL = URL + "?" + url_params
136
- response = requests.get(
150
+ response = self.session.get(
137
151
  url=URL,
138
152
  headers={
139
153
  "Authorization": header,
@@ -183,7 +197,7 @@ class FyersServiceSync:
183
197
  """
184
198
  try:
185
199
  URL = Config.API + api
186
- response = requests.delete(
200
+ response = self.session.delete(
187
201
  URL,
188
202
  data=json.dumps(data),
189
203
  headers={"Authorization": header, "Content-Type": self.content ,"version": "3"},
@@ -233,7 +247,7 @@ class FyersServiceSync:
233
247
  """
234
248
  try:
235
249
  URL = Config.API + api
236
- response = requests.patch(
250
+ response = self.session.patch(
237
251
  URL,
238
252
  data=json.dumps(data),
239
253
  headers={"Authorization": header, "Content-Type": self.content ,"version": "3"},
@@ -282,7 +296,7 @@ class FyersServiceSync:
282
296
  """
283
297
  try:
284
298
  URL = Config.API + api
285
- response = requests.put(
299
+ response = self.session.put(
286
300
  URL,
287
301
  data=json.dumps(data),
288
302
  headers={"Authorization": header, "Content-Type": self.content ,"version": "3"},
@@ -324,12 +338,15 @@ class FyersServiceAsync:
324
338
 
325
339
  Args:
326
340
  logger: The logger object used for logging errors.
341
+ request_logger: The logger object used for logging requests.
327
342
  """
328
343
  self.api_logger = logger
329
344
  self.request_logger = request_logger
330
345
  self.content = "application/json"
331
346
  self.error_resp = {"s":"error", "code": 0 , "message":"Bad request"}
332
347
  self.error_message = "invalid input please check your input"
348
+ self.session = None
349
+ self._session_created_here = True
333
350
 
334
351
 
335
352
  async def post_async_call(self, api: str, header: str, data=None) -> dict:
@@ -346,18 +363,20 @@ class FyersServiceAsync:
346
363
  """
347
364
  try:
348
365
  url = Config.API + api
349
- async with aiohttp.ClientSession(
350
- headers={"Authorization": header, "Content-Type": self.content ,"version": "3"}
351
- ) as session:
352
- async with session.post(url, data=json.dumps(data)) as response:
353
- self.request_logger.debug({"Status Code":response.status, "API":api })
354
- content = await response.read()
355
- self.api_logger.debug({"URL": url,"Post Data": json.dumps(data), \
356
- "Response Status Code": response.status, \
357
- "Response": json.loads(content)})
358
- response.raise_for_status()
359
- response = await response.json()
360
- return response
366
+ # Create session on first use if not provided
367
+ if self.session is None:
368
+ self.session = aiohttp.ClientSession()
369
+
370
+ headers = {"Authorization": header, "Content-Type": self.content, "version": "3"}
371
+ async with self.session.post(url, data=json.dumps(data), headers=headers) as response:
372
+ self.request_logger.debug({"Status Code":response.status, "API":api })
373
+ content = await response.read()
374
+ self.api_logger.debug({"URL": url,"Post Data": json.dumps(data), \
375
+ "Response Status Code": response.status, \
376
+ "Response": json.loads(content)})
377
+ response.raise_for_status()
378
+ response = await response.json()
379
+ return response
361
380
 
362
381
  except aiohttp.ClientResponseError as e:
363
382
  self.api_logger.error({"Api": api, "Response": json.loads(content)})
@@ -402,20 +421,22 @@ class FyersServiceAsync:
402
421
  URL = Config.DATA_API + api
403
422
  else:
404
423
  URL = Config.API + api
405
- async with aiohttp.ClientSession(
406
- headers={
407
- "Authorization": header,
408
- "Content-Type": self.content,
409
- "version": "3",
410
- }
411
- ) as session:
412
- async with session.get(URL, params=params) as response:
413
- self.request_logger.debug({"Status Code": response.status, "API":api })
414
- content = await response.read()
415
- self.api_logger.debug({"URL": URL, "Status Code": response.status, "Response": json.loads(content)})
416
- response.raise_for_status()
417
- response = await response.json()
418
- return response
424
+ # Create session on first use if not provided
425
+ if self.session is None:
426
+ self.session = aiohttp.ClientSession()
427
+
428
+ headers = {
429
+ "Authorization": header,
430
+ "Content-Type": self.content,
431
+ "version": "3",
432
+ }
433
+ async with self.session.get(URL, params=params, headers=headers) as response:
434
+ self.request_logger.debug({"Status Code": response.status, "API":api })
435
+ content = await response.read()
436
+ self.api_logger.debug({"URL": URL, "Status Code": response.status, "Response": json.loads(content)})
437
+ response.raise_for_status()
438
+ response = await response.json()
439
+ return response
419
440
 
420
441
  except aiohttp.ClientResponseError as e:
421
442
  self.api_logger.error({"Api": api, "Response": json.loads(content)})
@@ -454,18 +475,20 @@ class FyersServiceAsync:
454
475
  """
455
476
  try:
456
477
  url = Config.API + api
457
- async with aiohttp.ClientSession(
458
- headers={"Authorization": header, "Content-Type": self.content ,"version": "3"}
459
- ) as session:
460
- async with session.delete(url, data=json.dumps(data)) as response:
461
- self.request_logger.debug({"Status Code": response.status, "API":api })
462
- content = await response.read()
463
- self.api_logger.debug({"URL": url, "data": json.dumps(data), \
464
- "Response Status Code": response.status, \
465
- "Response": json.loads(content)})
466
- response.raise_for_status()
467
- response = await response.json()
468
- return response
478
+ # Create session on first use if not provided
479
+ if self.session is None:
480
+ self.session = aiohttp.ClientSession()
481
+
482
+ headers = {"Authorization": header, "Content-Type": self.content, "version": "3"}
483
+ async with self.session.delete(url, data=json.dumps(data), headers=headers) as response:
484
+ self.request_logger.debug({"Status Code": response.status, "API":api })
485
+ content = await response.read()
486
+ self.api_logger.debug({"URL": url, "data": json.dumps(data), \
487
+ "Response Status Code": response.status, \
488
+ "Response": json.loads(content)})
489
+ response.raise_for_status()
490
+ response = await response.json()
491
+ return response
469
492
 
470
493
  except aiohttp.ClientResponseError as e:
471
494
  self.api_logger.error({"Api": api, "Response": json.loads(content)})
@@ -504,20 +527,21 @@ class FyersServiceAsync:
504
527
  """
505
528
  try:
506
529
  url = Config.API + api
507
- async with aiohttp.ClientSession(
508
- headers={"Authorization": header, "Content-Type": self.content ,"version": "3"}
509
- ) as session:
510
- json_data = json.dumps(data).encode("utf-8")
511
-
512
- async with session.patch(url, data=json_data) as response:
513
- self.request_logger.debug({"Status Code": response.status, "API":api })
514
- content = await response.read()
515
- self.api_logger.debug({"URL": url, "data": json.dumps(data), \
516
- "Status Code": response.status, \
517
- "Response": json.loads(content)})
518
- response.raise_for_status()
519
- response = await response.json()
520
- return response
530
+ # Create session on first use if not provided
531
+ if self.session is None:
532
+ self.session = aiohttp.ClientSession()
533
+
534
+ json_data = json.dumps(data).encode("utf-8")
535
+ headers = {"Authorization": header, "Content-Type": self.content, "version": "3"}
536
+ async with self.session.patch(url, data=json_data, headers=headers) as response:
537
+ self.request_logger.debug({"Status Code": response.status, "API":api })
538
+ content = await response.read()
539
+ self.api_logger.debug({"URL": url, "data": json.dumps(data), \
540
+ "Status Code": response.status, \
541
+ "Response": json.loads(content)})
542
+ response.raise_for_status()
543
+ response = await response.json()
544
+ return response
521
545
 
522
546
  except aiohttp.ClientResponseError as e:
523
547
  self.api_logger.error({"Api": api, "Response": json.loads(content)})
@@ -556,20 +580,21 @@ class FyersServiceAsync:
556
580
  """
557
581
  try:
558
582
  url = Config.API + api
559
- async with aiohttp.ClientSession(
560
- headers={"Authorization": header, "Content-Type": self.content ,"version": "3"}
561
- ) as session:
562
- json_data = json.dumps(data).encode("utf-8")
563
-
564
- async with session.put(url, data=json_data) as response:
565
- self.request_logger.debug({"Status Code": response.status, "API":api })
566
- content = await response.read()
567
- self.api_logger.debug({"URL": url, "data": json.dumps(data), \
568
- "Status Code": response.status, \
569
- "Response": json.loads(content)})
570
- response.raise_for_status()
571
- response = await response.json()
572
- return response
583
+ # Create session on first use if not provided
584
+ if self.session is None:
585
+ self.session = aiohttp.ClientSession()
586
+
587
+ json_data = json.dumps(data).encode("utf-8")
588
+ headers = {"Authorization": header, "Content-Type": self.content, "version": "3"}
589
+ async with self.session.put(url, data=json_data, headers=headers) as response:
590
+ self.request_logger.debug({"Status Code": response.status, "API":api })
591
+ content = await response.read()
592
+ self.api_logger.debug({"URL": url, "data": json.dumps(data), \
593
+ "Status Code": response.status, \
594
+ "Response": json.loads(content)})
595
+ response.raise_for_status()
596
+ response = await response.json()
597
+ return response
573
598
 
574
599
  except aiohttp.ClientResponseError as e:
575
600
  self.api_logger.error({"Api": api, "Response": json.loads(content)})
@@ -594,6 +619,15 @@ class FyersServiceAsync:
594
619
  self.api_logger.debug({"URL": url,"data": json.dumps(data),"message": e})
595
620
  return self.error_resp
596
621
 
622
+ async def close(self):
623
+ """
624
+ Closes the aiohttp session if it was created by this instance.
625
+ Should be called when done with the service to properly clean up resources.
626
+ """
627
+ if self.session is not None and self._session_created_here:
628
+ await self.session.close()
629
+ self.session = None
630
+
597
631
 
598
632
 
599
633
  class SessionModel:
@@ -695,7 +729,7 @@ class FyersModel:
695
729
  if is_async:
696
730
  self.service = FyersServiceAsync(self.api_logger, self.request_logger)
697
731
  else:
698
- self.service = FyersServiceSync(self.api_logger,self.request_logger)
732
+ self.service = FyersServiceSync(self.api_logger, self.request_logger)
699
733
 
700
734
  def get_profile(self) -> dict:
701
735
  """
@@ -919,6 +953,7 @@ class FyersModel:
919
953
  - 'limitPrice' (float): Valid price for Limit and Stoplimit orders. Default: 0.
920
954
  - 'stopPrice' (float): Valid price for Stop and Stoplimit orders. Default: 0.
921
955
  - 'offlineOrder' (bool): Specifies if the order is placed when the market is open (False) or as an AMO order (True).
956
+ - 'isSliceOrder' (bool): Specifies if the order is a slice order. Default: False.
922
957
 
923
958
  Returns:
924
959
  The response JSON as a dictionary.
@@ -1246,17 +1281,19 @@ class FyersModel:
1246
1281
 
1247
1282
  Args:
1248
1283
  data (dict): A dictionary containing the alert details.
1249
- - 'agent' (str, optional): Source of alert creation. Eg: "fyers-api"
1250
- - 'alert-type' (int, mandatory): Type of alert. 1 usually means price-based alert.
1251
- - 'name' (str, optional): User-provided name/label for the alert.
1252
- - 'symbol' (str, mandatory): Trading symbol in full format.
1253
- Eg: "NSE:SBIN-EQ", "NSE:SILVERMIC25DECFUT"
1254
- - 'comparisonType' (str, mandatory): Selects the price parameter used for comparison.
1255
- Allowed: "OPEN", "HIGH", "LOW", "CLOSE", "LTP"
1256
- - 'condition' (str, mandatory): Price comparison operator.
1257
- Allowed: "GT" (greater), "LT" (lesser), "EQ" (equal)
1258
- - 'value' (float/int, mandatory): Target price against which comparison is performed.
1259
- - 'notes' (str, optional): Additional notes for the alert.
1284
+ Required:
1285
+ - alert-type (int): Type of alert. 1 usually means price-based alert.
1286
+ - name (str): User-provided name/label for the alert.
1287
+ - symbol (str): Trading symbol in full format.
1288
+ Eg: "NSE:SBIN-EQ", "NSE:SILVERMIC25DECFUT"
1289
+ - comparisonType (str): Price parameter used for comparison.
1290
+ Allowed: "OPEN", "HIGH", "LOW", "CLOSE", "LTP"
1291
+ - condition (str): Price comparison operator.
1292
+ Allowed: "GT" (greater), "LT" (lesser), "EQ" (equal)
1293
+ - value (float/int/str): Target price against which comparison is performed.
1294
+ Optional:
1295
+ - agent (str): Source of alert creation. Eg: "fyers-api"
1296
+ - notes (str): Additional notes for the alert.
1260
1297
 
1261
1298
  Returns:
1262
1299
  The response JSON as a dictionary.
@@ -1274,8 +1311,6 @@ class FyersModel:
1274
1311
 
1275
1312
  Args:
1276
1313
  data (dict, optional): Optional dictionary containing query parameters.
1277
- - 'id' (str, optional): Comma-separated alert IDs to filter.
1278
- Eg: "3870982,3870983" or "3870982"
1279
1314
  - 'archive' (int, optional): Set to 1 to retrieve archived alerts instead of active alerts.
1280
1315
  Default: 0 (active alerts)
1281
1316
 
@@ -1293,11 +1328,14 @@ class FyersModel:
1293
1328
 
1294
1329
  def delete_alert(self, data) -> dict:
1295
1330
  """
1296
- Deletes a price alert by its ID.
1331
+ Deletes a price alert.
1297
1332
 
1298
1333
  Args:
1299
- data (dict): A dictionary containing the alert ID to delete.
1300
- - 'id' (str, mandatory): Alert ID to be deleted.
1334
+ data (dict): A dictionary containing the alert deletion details.
1335
+ Required Attributes:
1336
+ - alertId (str): Alert ID from creation
1337
+ Optional Attributes:
1338
+ - agent (str): Client calling the API (e.g., "fyers-api")
1301
1339
 
1302
1340
  Returns:
1303
1341
  The response JSON as a dictionary.
@@ -1314,18 +1352,20 @@ class FyersModel:
1314
1352
 
1315
1353
  Args:
1316
1354
  data (dict): A dictionary containing the alert modification details.
1317
- - 'alertId' (str, mandatory): ID of the alert to be modified. Eg: "3870991"
1318
- - 'agent' (str, optional): Source of alert creation. Eg: "fyers-api"
1319
- - 'alert-type' (int, optional): Type of alert. 1 usually means price-based alert.
1320
- - 'name' (str, optional): User-provided name/label for the alert.
1321
- - 'symbol' (str, optional): Trading symbol in full format.
1322
- Eg: "NSE:SBIN-EQ", "NSE:SILVERMIC25DECFUT"
1323
- - 'comparisonType' (str, optional): Selects the price parameter used for comparison.
1324
- Allowed: "OPEN", "HIGH", "LOW", "CLOSE", "LTP"
1325
- - 'condition' (str, optional): Price comparison operator.
1326
- Allowed: "GT" (greater), "LT" (lesser), "E" (equal)
1327
- - 'value' (float/int, optional): Target price against which comparison is performed.
1328
- - 'status' (int, optional): Status of the alert.
1355
+ Required Attributes:
1356
+ - alertId (str): ID of the alert to be modified. Eg: "3870991"
1357
+ - alert-type (int): Type of alert. 1 usually means price-based alert.
1358
+ - symbol (str): Trading symbol in full format.
1359
+ Eg: "NSE:SBIN-EQ", "NSE:SILVERMIC25DECFUT"
1360
+ - comparisonType (str): Price parameter used for comparison.
1361
+ Allowed: "OPEN", "HIGH", "LOW", "CLOSE", "LTP"
1362
+ - condition (str): Price comparison operator.
1363
+ Allowed: "GT" (greater), "LT" (lesser), "E" (equal)
1364
+ - value (float/int/str): Target price against which comparison is performed.
1365
+ - name (str): User-provided name/label for the alert.
1366
+ Optional Attributes:
1367
+ - agent (str): Source of alert creation. Eg: "fyers-api"
1368
+
1329
1369
 
1330
1370
  Returns:
1331
1371
  The response JSON as a dictionary.
@@ -1354,28 +1394,439 @@ class FyersModel:
1354
1394
  response = self.service.put_call(Config.toggle_alert, self.header, data)
1355
1395
  return response
1356
1396
 
1357
- def trending_alert(self) -> dict:
1397
+ def create_smart_order_step(self, data: dict) -> dict:
1358
1398
  """
1359
- Retrieves trending alerts - the top 5 most popular alerts based on user activity.
1360
- This endpoint returns alerts that are currently trending with their symbol details,
1361
- price changes, and alert counts.
1399
+ Creates a step smart order based on the provided data.
1400
+
1401
+ Args:
1402
+ data (dict): A dictionary containing the smart order creation details.
1403
+ Required Attributes:
1404
+ - symbol (str): Symbol of the product. Eg: "NSE:SBIN-EQ"
1405
+ - side (int): Side of the order. 1 for Buy, -1 for Sell
1406
+ - qty (int): Total quantity of the product
1407
+ - productType (str): Type of the product. Possible values: 'CNC', 'INTRADAY', 'MARGIN'
1408
+ - avgqty (int): Average quantity per step
1409
+ - avgdiff (int): Average difference between steps
1410
+ - direction (int): Direction of the order
1411
+ - orderType (int): Type of the order
1412
+ - startTime (int): Start time in epoch format
1413
+ - endTime (int): End time in epoch format
1414
+
1415
+ Conditional Attributes:
1416
+ - limitPrice (float): Limit price for the order
1417
+
1418
+ Optional Attributes:
1419
+ - initQty (int): Initial quantity to be placed
1420
+ - hpr (float): Higher price range
1421
+ - lpr (float): Lower price range
1422
+ - mpp (int): Maximum price per order
1362
1423
 
1363
1424
  Returns:
1364
- The response JSON as a dictionary
1365
-
1366
- Each alert in the data array contains:
1367
- - 'symbol' (str): Trading symbol in full format
1368
- - 'description' (str): Description/name of the symbol
1369
- - 'exchange' (str): Exchange name (NSE, BSE, MCX, etc.)
1370
- - 'change' (float): Change in price
1371
- - 'changeInP' (float): Percentage change in price
1372
- - 'ltp' (float): Last traded price
1373
- - 'count' (int): Number of alerts set for this symbol
1425
+ dict: The response JSON as a dictionary.
1426
+ """
1427
+
1428
+
1429
+
1430
+ if self.is_async:
1431
+ response = self.service.post_async_call(Config.create_smartorder_step, self.header, data)
1432
+ else:
1433
+ response = self.service.post_call(Config.create_smartorder_step, self.header, data)
1434
+ return response
1435
+
1436
+ async def close(self):
1437
+ """
1438
+ Closes the HTTP session(s) to properly clean up resources.
1439
+ Should be called when done with the FyersModel instance, especially for async mode.
1440
+ """
1441
+ if self.is_async:
1442
+ if hasattr(self, 'async_session') and self.async_session:
1443
+ await self.async_session.close()
1444
+ self.async_session = None
1445
+ if hasattr(self, 'service') and hasattr(self.service, 'close'):
1446
+ await self.service.close()
1447
+ else:
1448
+ if hasattr(self, 'session') and self.session:
1449
+ self.session.close()
1450
+ self.session = None
1451
+
1452
+
1453
+ def create_smart_order_limit(self,data: dict) -> dict:
1454
+ """
1455
+ Creates a Smart Limit Order based on the provided data.
1456
+
1457
+ Smart Limit Orders allow you to place limit orders that remain active until the specified end time.
1458
+ Once the end time is reached, the order can be converted to an MPP order or cancelled.
1459
+
1460
+ Args:
1461
+ data (dict): A dictionary containing the smart order creation details.
1462
+ Required Attributes:
1463
+ - symbol (str): The instrument's unique identifier, e.g., "NSE:SBIN-EQ"
1464
+ - side (int): Order side: 1 for Buy, -1 for Sell (enum: 1, -1)
1465
+ - qty (int): Order quantity (Min: 1, Max: 999999; must be a multiple of lot size)
1466
+ - productType (str): Must be one of: "CNC", "MARGIN", "INTRADAY", "MTF"
1467
+ - limitPrice (number): The price at which the order should be placed (Min: 0.01)
1468
+ - endTime (int): Order expiry time as a Unix timestamp (epoch)
1469
+ - orderType (int): Order type: 1 for Limit, 4 for Stop-Limit (enum: 1, 4)
1470
+ - onExp (int): Action on expiry: 1 = Cancel, 2 = Market (enum: 1, 2)
1471
+
1472
+ Optional Attributes:
1473
+ - stopPrice (number): Default: 0. Required when orderType is 4 (Stop-Limit)
1474
+ - hpr (number): Default: 0. 0 = no upper price limit. If provided, order executes only below this price
1475
+ - lpr (number): Default: 0. 0 = no lower price limit. If provided, order executes only above this price
1476
+ - mpp (number): Default: 0. 0 = no market protection. Valid values: 0–3 or -1 (disabled)
1477
+
1478
+ Returns:
1479
+ dict: The response JSON as a dictionary.
1480
+ """
1481
+ if self.is_async:
1482
+ response = self.service.post_async_call(Config.create_smartorder_limit, self.header, data)
1483
+ else:
1484
+ response = self.service.post_call(Config.create_smartorder_limit, self.header, data)
1485
+ return response
1486
+
1487
+ def create_smart_order_trail(self, data: dict) -> dict:
1488
+ """
1489
+ Creates a Smart Trail Order (Trailing Stop Loss) based on the provided data.
1490
+
1491
+ A Smart Trail Order is a trailing stop-loss that automatically adjusts the stop price as the market moves
1492
+ in your favour. The stop price trails the market by a specified jump price.
1493
+
1494
+ Args:
1495
+ data (dict): A dictionary containing the smart order creation details.
1496
+ Required Attributes:
1497
+ - symbol (str): The instrument's unique identifier, e.g., "NSE:SBIN-EQ"
1498
+ - side (int): Order side: 1 for Buy, -1 for Sell (enum: 1, -1)
1499
+ - qty (int): Order quantity (Min: 1, Max: 999999; must be a multiple of lot size)
1500
+ - productType (str): Must be one of: "CNC", "MARGIN", "INTRADAY", "MTF"
1501
+ - orderType (int): Order type: 1 for Limit Order, 2 for Market Order (enum: 1, 2)
1502
+ - stopPrice (number): Initial stop/trigger price (must be greater than 0)
1503
+ - jump_diff (number): Jump price — the value by which the stop price trails (Min: 0.2)
1504
+
1505
+ Optional Attributes:
1506
+ - limitPrice (number): Default: 0. If not provided, executes at market price. Required if orderType = 1
1507
+ - target_price (number): Default: 0 (no target). If provided, must be greater than current LTP
1508
+ - mpp (number): Default: 0 (no market protection). Valid values: 0–3 or -1 (disabled)
1509
+
1510
+ Returns:
1511
+ dict: The response JSON as a dictionary.
1374
1512
  """
1375
1513
  if self.is_async:
1376
- response = self.service.get_async_call(Config.trending_alert, self.header)
1514
+ response = self.service.post_async_call(Config.create_smartorder_trail, self.header, data)
1377
1515
  else:
1378
- response = self.service.get_call(Config.trending_alert, self.header)
1516
+ response = self.service.post_call(Config.create_smartorder_trail, self.header, data)
1379
1517
  return response
1380
1518
 
1519
+ def create_smart_order_sip(self, data: dict) -> dict:
1520
+ """
1521
+ Creates a Smart SIP (Systematic Investment Plan) order based on the provided data.
1522
+
1523
+ Smart SIP allows you to automate recurring investments in equity stocks, ETFs, with orders placed automatically
1524
+ at your selected frequency—daily, weekly, monthly, or on custom dates.
1525
+
1526
+ Args:
1527
+ data (dict): A dictionary containing the smart order creation details.
1528
+ Required Attributes:
1529
+ - symbol (str): The instrument's unique identifier (Equity only), e.g., "NSE:SBIN-EQ"
1530
+ - productType (str): Must be one of: "CNC", "MTF"
1531
+ - freq (int): SIP frequency (enum: 1, 2, 3, 6)
1532
+ - sip_day (int): Day of the month for SIP execution (Min: 1, Max: 28)
1533
+ - qty OR amount (int/number): At least one required - Quantity or amount per SIP instalment (Max: 999999)
1534
+
1535
+ Conditional Attributes:
1536
+ - sip_time (int): Required if freq = 1 (Daily). Unix timestamp for SIP execution time (must be within market hours)
1537
+
1538
+ Optional Attributes:
1539
+ - imd_start (bool): Whether to start SIP immediately. true = start now, false = wait for schedule
1540
+ - endTime (int): Default: 0 (no end date). Unix timestamp when the SIP should end
1541
+ - hpr (number): Default: 0. Skips SIP if price is above this upper limit
1542
+ - lpr (number): Default: 0. Skips SIP if price is below this lower limit
1543
+ - step_up_freq (int): Frequency of step-up increase (enum: 3, 5). Default: 0 (no step-up)
1544
+ - step_up_qty (int): Quantity to increase at each step-up (Default: 0; Max: 999999)
1545
+ - step_up_amount (number): Amount to increase at each step-up (Default: 0; Max: 999999)
1546
+ - exp_qty (int): Quantity for expiry/final SIP order (Default: 0; Max: 999999)
1547
+
1548
+ Returns:
1549
+ dict: The response JSON as a dictionary.
1550
+ """
1551
+ if self.is_async:
1552
+ response = self.service.post_async_call(Config.create_smartorder_sip, self.header, data)
1553
+ else:
1554
+ response = self.service.post_call(Config.create_smartorder_sip, self.header, data)
1555
+ return response
1556
+
1557
+
1558
+
1559
+
1560
+ def modify_smart_order(self, data) -> dict:
1561
+ """
1562
+ Modifies a smart order based on the provided data.
1563
+
1564
+ Args:
1565
+ data (dict): A dictionary containing the smart order modification details.
1566
+
1567
+ Required:
1568
+ - flowId (str): Unique identifier of the Smart Order to be modified
1569
+
1570
+ Optional (by order type/flowtype):
1571
+
1572
+ Limit Order (flowtype: 4):
1573
+ - qty (int): To update order quantity
1574
+ - limitPrice (number): To update limit price
1575
+ - stopPrice (number): To update stop/trigger price
1576
+ - endTime (int): To update expiry time (Unix timestamp)
1577
+ - hpr (number): To update upper price limit (High Price Range)
1578
+ - lpr (number): To update lower price limit (Low Price Range)
1579
+ - mpp (number): To update market protection percentage
1580
+ - onExp (int): To update expiry action (1 = Cancel, 2 = Market Order)
1581
+
1582
+ Trail Order (flowtype: 6):
1583
+ - qty (int): To update order quantity
1584
+ - limitPrice (number): To update limit price (required if orderType = 1; must be 0 if orderType = 2)
1585
+ - stopPrice (number): To update stop/trigger price
1586
+ - jump_diff (number): To update jump value for trailing stop
1587
+ - target_price (number): To update target price (optional profit booking)
1588
+ - mpp (number): To update market protection percentage
1589
+
1590
+ Step Order (flowtype: 3):
1591
+ - qty (int): To update total order quantity
1592
+ - startTime (int): To update order start time
1593
+ - endTime (int): To update order end time
1594
+ - hpr (number): To update upper price limit (High Price Range)
1595
+ - lpr (number): To update lower price limit (Low Price Range)
1596
+ - mpp (number): To update market protection percentage
1597
+ - avgqty (int): To update quantity per averaging step
1598
+ - avgdiff (number): To update price gap between steps
1599
+ - initQty (int): To update initial quantity (only before order starts)
1600
+ - limitPrice (number): To update limit price (only before order starts)
1601
+ - direction (int): To update direction for averaging (1 = price drop, -1 = price rise)
1602
+
1603
+ SIP Order (flowtype: 7):
1604
+ - qty (int): To update investment quantity per instalment
1605
+ - amount (number): To update investment amount per instalment
1606
+ - hpr (number): To update upper price limit (skip if price is above this)
1607
+ - lpr (number): To update lower price limit (skip if price is below this)
1608
+ - sip_day (int): To update SIP day (applicable for monthly/custom frequency)
1609
+ - sip_time (int): To update SIP time (required for daily/custom frequency)
1610
+ - step_up_amount (number): To update step-up amount (amount-based SIP only)
1611
+ - step_up_qty (int): To update step-up quantity (qty-based SIP only)
1612
+ - exp_qty (int): To update expiry quantity
1613
+ - exp_amount (number): To update expiry amount
1614
+
1615
+ Returns:
1616
+ The response JSON as a dictionary.
1617
+ """
1618
+ if self.is_async:
1619
+ response = self.service.patch_async_call(Config.modify_smartorder, self.header, data)
1620
+ else:
1621
+ response = self.service.patch_call(Config.modify_smartorder, self.header, data)
1622
+ return response
1623
+
1624
+ def cancel_order(self, data) -> dict:
1625
+ """
1626
+ Cancels a smart order based on the provided data.
1627
+
1628
+ Args:
1629
+ data (dict): A dictionary containing the smart order cancellation details.
1630
+ - flowId (str): Unique identifier of the smart order flow to cancel
1631
+
1632
+ Returns:
1633
+ The response JSON as a dictionary.
1634
+ """
1635
+ if self.is_async:
1636
+ response = self.service.delete_async_call(Config.cancel_smartorder, self.header, data)
1637
+ else:
1638
+ response = self.service.delete_call(Config.cancel_smartorder, self.header, data)
1639
+ return response
1640
+
1641
+ def pause_order(self, data) -> dict:
1642
+ """
1643
+ Pauses a smart order based on the provided data.
1644
+
1645
+ Args:
1646
+ data (dict): A dictionary containing the smart order pause details.
1647
+ - flowId (str): Unique identifier of the smart order flow to pause
1648
+
1649
+ Returns:
1650
+ The response JSON as a dictionary.
1651
+ """
1652
+ if self.is_async:
1653
+ response = self.service.patch_async_call(Config.pause_smartorder, self.header, data)
1654
+ else:
1655
+ response = self.service.patch_call(Config.pause_smartorder, self.header, data)
1656
+ return response
1657
+
1658
+ def resume_order(self, data) -> dict:
1659
+ """
1660
+ Resumes a paused smart order based on the provided data.
1661
+
1662
+ Args:
1663
+ data (dict): A dictionary containing the smart order resume details.
1664
+ - flowId (str): Unique identifier of the smart order flow to resume
1665
+
1666
+ Returns:
1667
+ The response JSON as a dictionary.
1668
+ """
1669
+ if self.is_async:
1670
+ response = self.service.patch_async_call(Config.resume_smartorder, self.header, data)
1671
+ else:
1672
+ response = self.service.patch_call(Config.resume_smartorder, self.header, data)
1673
+ return response
1674
+
1675
+ def smart_orderbook_with_filter(self, data=None) -> dict:
1676
+ """
1677
+ Retrieves smart order book information with optional filters.
1678
+
1679
+ Optional Query Parameters (pass as keys in data dict for GET query params):
1680
+ - flowtype (int[]): Filter by order type (repeatable). 3 = Step, 4 = Limit, 5 = Peg, 6 = Trail, 7 = SIP. Default: all types
1681
+ - messageType (int[]): Filter by order status/message type (repeatable). Default: all
1682
+ - page_no (int): Page number for pagination. Default: 1
1683
+ - page_size (int): Number of records per page. Default: 15
1684
+ - sort_by (str): Sort by field: "CreatedTime", "UpdatedTime", "Alphabet". Default: "UpdatedTime"
1685
+ - ord_by (int): Sort order: 1 for ascending, -1 for descending. Default: -1
1686
+ - side (int[]): Filter by side (repeatable). 1 for buy, -1 for sell. Default: all
1687
+ - exchange (str[]): Filter by exchange (repeatable). "NSE", "BSE", "MCX". Default: all
1688
+ - product (str[]): Filter by product type (repeatable). "CNC", "MARGIN", "INTRADAY", "MTF". Default: all
1689
+ - search (str): Search by symbol name. Default: none
1690
+
1691
+ Args:
1692
+ data (dict, optional): A dictionary containing the optional query parameters above.
1693
+
1694
+ Returns:
1695
+ The response JSON as a dictionary.
1696
+ """
1697
+ if self.is_async:
1698
+ response = self.service.get_async_call(Config.smartorder_orderbook, self.header, data)
1699
+ else:
1700
+ response = self.service.get_call(Config.smartorder_orderbook, self.header, data)
1701
+ return response
1702
+
1703
+
1704
+ def create_smartexit_trigger(self, data) -> dict:
1705
+ """
1706
+ Creates a new smart exit trigger based on the provided data.
1707
+
1708
+ Smart exit triggers support three types of strategies:
1709
+
1710
+ Type 1: Only Alert (notification only, no auto-exit)
1711
+ - Sends notification when profit/loss thresholds are reached
1712
+ - Does not automatically exit positions
1713
+ - Example:
1714
+ {
1715
+ "name": "Alert Only Strategy",
1716
+ "type": 1,
1717
+ "profitRate": 5000,
1718
+ "lossRate": -2000
1719
+ }
1720
+
1721
+ Type 2: Exit with Alert (notification + immediate exit)
1722
+ - Sends notification and immediately exits positions when thresholds are reached
1723
+ - Example:
1724
+ {
1725
+ "name": "Auto Exit Strategy",
1726
+ "type": 2,
1727
+ "profitRate": 5000,
1728
+ "lossRate": -2000
1729
+ }
1730
+
1731
+ Type 3: Exit with Alert + Wait for Recovery (notification + delayed exit)
1732
+ - Sends notification and waits for recovery before exiting
1733
+ - Requires waitTime parameter (in minutes)
1734
+ - Example:
1735
+ {
1736
+ "name": "Recovery Exit Strategy",
1737
+ "type": 3,
1738
+ "profitRate": 10000,
1739
+ "lossRate": -3000,
1740
+ "waitTime": 5
1741
+ }
1742
+
1743
+ Args:
1744
+ data (dict): A dictionary containing the smart exit trigger creation details.
1745
+ - name (str): Name of the smart exit trigger strategy
1746
+ - type (int): Type of the trigger (1: Alert only, 2: Exit with alert, 3: Exit with alert + wait for recovery)
1747
+ - profitRate (float): Profit rate threshold (positive value, e.g., 5000)
1748
+ - lossRate (float): Loss rate threshold (negative value, e.g., -2000)
1749
+ - waitTime (int, optional): Wait time in minutes (required for type 3, default: 0)
1750
+
1751
+ """
1752
+ if self.is_async:
1753
+ response = self.service.post_async_call(Config.smartexit_trigger, self.header, data)
1754
+ else:
1755
+ response = self.service.post_call(Config.smartexit_trigger, self.header, data)
1756
+ return response
1757
+
1758
+ def get_smartexit_triggers(self, data=None) -> dict:
1759
+ """
1760
+ Retrieves smart exit trigger information.
1761
+
1762
+ Args:
1763
+ data (dict, optional): A dictionary containing parameters for filtering smart exit triggers.
1764
+
1765
+ Returns:
1766
+ The response JSON as a dictionary.
1767
+ """
1768
+ if self.is_async:
1769
+ response = self.service.get_async_call(Config.smartexit_trigger, self.header, data)
1770
+ else:
1771
+ response = self.service.get_call(Config.smartexit_trigger, self.header, data)
1772
+ return response
1773
+
1774
+ def update_smartexit_trigger(self, data) -> dict:
1775
+ """
1776
+ Updates an existing smart exit trigger based on the provided data.
1777
+
1778
+ Use this endpoint to modify a Smart Exit trigger. You can update the target values, exit type, or wait time.
1779
+ If the trigger is active, updates are validated against the current P&L.
1780
+ Either a profit target or a loss limit must be provided.
1781
+
1782
+ Exit Types (type field):
1783
+ - Value 1: Only Alert - Notification Only
1784
+ Sends a notification when target is hit. Does NOT exit positions automatically.
1785
+ - Value 2: Exit with Alert - Notification + Immediate Exit
1786
+ Sends notification AND exits all intraday positions immediately.
1787
+ - Value 3: Exit with Alert (Wait for Recovery) - Notification + Delayed Exit
1788
+ Sends notification, waits for waitTime minutes, then exits positions.
1789
+
1790
+ Args:
1791
+ data (dict): A dictionary containing the smart exit trigger update details.
1792
+ Required Attributes:
1793
+ - flowId (str): The unique identifier of the smart exit to update
1794
+
1795
+ Optional Attributes:
1796
+ - name (str): Unique name for your Smart Exit trigger
1797
+ - profitRate (number): Book profit value (positive) or Minimize loss value (negative).
1798
+ (Min: -1,00,00,000, Max: 1,00,00,000)
1799
+ - lossRate (number): Max loss value (negative) or Min profit value (positive).
1800
+ (Min: -1,00,00,000, Max: 1,00,00,000)
1801
+ - type (int): Exit type (enum: 1, 2, 3). Default is 1 if not provided.
1802
+ - waitTime (int): Wait time in minutes (required if type=3). Default: 0 (Min: 0, Max: 60)
1803
+
1804
+ Note: Either profitRate or lossRate must be provided.
1805
+
1806
+ Returns:
1807
+ The response JSON as a dictionary.
1808
+ """
1809
+ if self.is_async:
1810
+ response = self.service.put_async_call(Config.smartexit_trigger, self.header, data)
1811
+ else:
1812
+ response = self.service.put_call(Config.smartexit_trigger, self.header, data)
1813
+ return response
1814
+
1815
+ def activate_deactivate_smartexit_trigger(self, data) -> dict:
1816
+ """
1817
+ Activates a smart exit trigger based on the provided data.
1818
+
1819
+ Args:
1820
+ data (dict): A dictionary containing the smart exit trigger activation details.
1821
+ - flowId (str): Unique identifier of the smart exit trigger flow to activate
1822
+
1823
+ Returns:
1824
+ The response JSON as a dictionary.
1825
+ """
1826
+ if self.is_async:
1827
+ response = self.service.post_async_call(Config.activate_smartexit_trigger, self.header, data)
1828
+ else:
1829
+ response = self.service.post_call(Config.activate_smartexit_trigger, self.header, data)
1830
+ return response
1831
+
1381
1832
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fyers_apiv3
3
- Version: 3.1.8
3
+ Version: 3.1.9
4
4
  Summary: Fyers trading APIs.
5
5
  Home-page: https://github.com/FyersDev/fyers-api-sample-code/tree/sample_v3/v3/python
6
6
  Author: Fyers-Tech
@@ -182,7 +182,8 @@ data = {
182
182
  "disclosedQty":0,
183
183
  "offlineOrder":False,
184
184
  "stopLoss":0,
185
- "takeProfit":0
185
+ "takeProfit":0,
186
+ "isSliceOrder":False
186
187
  } ## This is a sample example to place a limit order you can make the further changes based on your requriements
187
188
 
188
189
  print(fyers.place_order(data))
@@ -350,6 +351,230 @@ data = {"symbol":"NSE:SBIN-EQ","ohlcv_flag":"1"}
350
351
  print(fyers.depth(data))
351
352
 
352
353
 
354
+ #################################################################################################################
355
+
356
+ """
357
+ PRICE ALERTS : This includes following APIs (create_alert, get_alert, update_alert, delete_alert, toggle_alert)
358
+ """
359
+
360
+ ## Create Price Alert
361
+ data = {
362
+ "agent": "fyers-api",
363
+ "alert-type": 1,
364
+ "name": "gold alert",
365
+ "symbol": "NSE:GOLDBEES-EQ",
366
+ "comparisonType": "LTP",
367
+ "condition": "GT",
368
+ "value": "9888",
369
+ "notes": " iji"
370
+ }
371
+
372
+ print(fyers.create_alert(data))
373
+
374
+ ## Get Price Alerts
375
+ # Get all active alerts
376
+ print(fyers.get_alert())
377
+
378
+ # Get archived alerts
379
+ data = {"archive": "1"}
380
+ print(fyers.get_alert(data))
381
+
382
+ ## Update Price Alert
383
+ data = {
384
+ "alertId": "6249977",
385
+ "agent": "fyers-api",
386
+ "alert-type": 1,
387
+ "name": "goldy bees",
388
+ "symbol": "NSE:GOLDBEES-EQ",
389
+ "comparisonType": "OPEN",
390
+ "condition": "GT",
391
+ "value": "10000.00676766767676676667"
392
+ }
393
+
394
+ print(fyers.update_alert(data))
395
+
396
+ ## Delete Price Alert
397
+ data = {"alertId": "6131416", "agent": "fyers-api"}
398
+ print(fyers.delete_alert(data))
399
+
400
+ ## Toggle Price Alert (Enable/Disable)
401
+ data = {"alertId": "3870991"}
402
+ print(fyers.toggle_alert(data))
403
+
404
+
405
+ #################################################################################################################
406
+
407
+ """
408
+ SMART ORDERS : This includes following APIs (create, modify, cancel, pause, resume, orderbook)
409
+ Smart orders support different flow types: step, limit, trail, sip
410
+ """
411
+
412
+ ## Create Smart Order - Step
413
+ data = {
414
+ "symbol": "NSE:SBIN-EQ",
415
+ "qty": 10,
416
+ "type": 1,
417
+ "side": 1,
418
+ "productType": "INTRADAY",
419
+ "limitPrice": 600.00,
420
+ "stopPrice": 0,
421
+ "validity": "DAY",
422
+ "disclosedQty": 0,
423
+ "offlineOrder": False
424
+ }
425
+
426
+ print(fyers.create_smart_order_step(data))
427
+
428
+ ## Create Smart Order - Limit
429
+ data = {
430
+ "symbol": "NSE:SBIN-EQ",
431
+ "qty": 10,
432
+ "type": 1,
433
+ "side": 1,
434
+ "productType": "INTRADAY",
435
+ "limitPrice": 600.00,
436
+ "stopPrice": 0,
437
+ "validity": "DAY",
438
+ "disclosedQty": 0,
439
+ "offlineOrder": False
440
+ }
441
+
442
+ print(fyers.create_smart_order_limit(data))
443
+
444
+ ## Create Smart Order - Trail
445
+ data = {
446
+ "symbol": "NSE:SBIN-EQ",
447
+ "qty": 10,
448
+ "type": 1,
449
+ "side": 1,
450
+ "productType": "INTRADAY",
451
+ "limitPrice": 600.00,
452
+ "stopPrice": 0,
453
+ "validity": "DAY",
454
+ "disclosedQty": 0,
455
+ "offlineOrder": False
456
+ }
457
+
458
+ print(fyers.create_smart_order_trail(data))
459
+
460
+ ## Create Smart Order - SIP
461
+ data = {
462
+ "symbol": "NSE:SBIN-EQ",
463
+ "qty": 10,
464
+ "type": 1,
465
+ "side": 1,
466
+ "productType": "CNC",
467
+ "limitPrice": 600.00,
468
+ "stopPrice": 0,
469
+ "validity": "DAY",
470
+ "disclosedQty": 0,
471
+ "offlineOrder": False
472
+ }
473
+
474
+ print(fyers.create_smart_order_sip(data))
475
+
476
+ ## Modify Smart Order
477
+ data = {
478
+ "flowId": "123456789",
479
+ "limitPrice": 610.00,
480
+ "qty": 15
481
+ }
482
+
483
+ print(fyers.modify_smart_order(data))
484
+
485
+ ## Cancel Smart Order
486
+ data = {"flowId": "123456789"}
487
+ print(fyers.cancel_order(data))
488
+
489
+ ## Pause Smart Order
490
+ data = {"flowId": "123456789"}
491
+ print(fyers.pause_order(data))
492
+
493
+ ## Resume Smart Order
494
+ data = {"flowId": "123456789"}
495
+ print(fyers.resume_order(data))
496
+
497
+ ## Get Smart Order Book with Filter
498
+ # Get all smart orders
499
+ print(fyers.smart_orderbook_with_filter())
500
+
501
+ # Get filtered smart orders
502
+ # Filter by side (1 for Buy, -1 for Sell)
503
+ data = {"side": [1]}
504
+ print(fyers.smart_orderbook_with_filter(data))
505
+
506
+ # Filter by multiple parameters
507
+ data = {
508
+ "exchange": ["NSE"],
509
+ "side": [1, -1],
510
+ "flowtype": [1, 2],
511
+ "product": ["CNC", "INTRADAY"],
512
+ "messageType": [1, 2],
513
+ "search": "SBIN",
514
+ "sort_by": "CreatedTime",
515
+ "ord_by": 1,
516
+ "page_no": 1,
517
+ "page_size": 15
518
+ }
519
+ print(fyers.smart_orderbook_with_filter(data))
520
+
521
+
522
+ #################################################################################################################
523
+
524
+ """
525
+ SMART EXIT TRIGGERS : This includes following APIs (create, get, update, activate)
526
+ """
527
+
528
+ ## Create Smart Exit Trigger
529
+
530
+ # Type 1: Only Alert (notification only, no auto-exit)
531
+ data = {
532
+ "name": "Alert Only Strategy",
533
+ "type": 1,
534
+ "profitRate": 5000,
535
+ "lossRate": -2000
536
+ }
537
+ print(fyers.create_smartexit_trigger(data))
538
+
539
+ # Type 2: Exit with Alert (notification + immediate exit)
540
+ data = {
541
+ "name": "Auto Exit Strategy",
542
+ "type": 2,
543
+ "profitRate": 5000,
544
+ "lossRate": -2000
545
+ }
546
+ print(fyers.create_smartexit_trigger(data))
547
+
548
+ # Type 3: Exit with Alert + Wait for Recovery (notification + delayed exit)
549
+ data = {
550
+ "name": "Recovery Exit Strategy",
551
+ "type": 3,
552
+ "profitRate": 10000,
553
+ "lossRate": -3000,
554
+ "waitTime": 5
555
+ }
556
+ print(fyers.create_smartexit_trigger(data))
557
+
558
+ ## Get Smart Exit Triggers
559
+ # Get all smart exit triggers
560
+ print(fyers.get_smartexit_triggers())
561
+
562
+
563
+ ## Update Smart Exit Trigger
564
+ data = {
565
+ "flowId": "123456789",
566
+ "triggerPrice": 610.00,
567
+ "stopLoss": 600.00,
568
+ "takeProfit": 630.00
569
+ }
570
+
571
+ print(fyers.update_smartexit_trigger(data))
572
+
573
+ ## Activate Smart Exit Trigger
574
+ data = {"flowId": "123456789"}
575
+ print(fyers.activate_smartexit_trigger(data))
576
+
577
+
353
578
  ```
354
579
 
355
580
  ## Getting started with Data Socket
@@ -437,43 +662,61 @@ from fyers_apiv3.FyersWebsocket import order_ws
437
662
 
438
663
  def onTrade(message):
439
664
  """
440
- Callback function to handle incoming messages from the FyersDataSocket WebSocket.
665
+ Callback function to handle incoming trade messages from the FyersOrderSocket WebSocket.
441
666
 
442
667
  Parameters:
443
668
  message (dict): The received message from the WebSocket.
444
-
669
+ - message["trades"]: Contains trade data including id_fyers field if present
670
+ - message["s"]: Status of the message
671
+
672
+ Note: The message may contain an "id_fyers" field in the trades data, which is a unique identifier
673
+ for Fyers-specific trade tracking.
445
674
  """
446
675
  print("Trade Response:", message)
447
676
 
677
+
448
678
  def onOrder(message):
449
679
  """
450
- Callback function to handle incoming messages from the FyersDataSocket WebSocket.
680
+ Callback function to handle incoming order messages from the FyersOrderSocket WebSocket.
451
681
 
452
682
  Parameters:
453
683
  message (dict): The received message from the WebSocket.
454
-
684
+ - message["orders"]: Contains order data including id_fyers field if present
685
+ - message["s"]: Status of the message
686
+
687
+ Note: The message may contain an "id_fyers" field in the orders data, which is a unique identifier
688
+ for Fyers-specific order tracking.
455
689
  """
456
690
  print("Order Response:", message)
457
691
 
692
+
458
693
  def onPosition(message):
459
694
  """
460
- Callback function to handle incoming messages from the FyersDataSocket WebSocket.
695
+ Callback function to handle incoming position messages from the FyersOrderSocket WebSocket.
461
696
 
462
697
  Parameters:
463
698
  message (dict): The received message from the WebSocket.
464
-
699
+ - message["positions"]: Contains position data including id_fyers field if present
700
+ - message["s"]: Status of the message
701
+
465
702
  """
466
703
  print("Position Response:", message)
467
704
 
705
+
468
706
  def onGeneral(message):
469
707
  """
470
- Callback function to handle incoming messages from the FyersDataSocket WebSocket.
708
+ Callback function to handle incoming general messages from the FyersOrderSocket WebSocket.
709
+ This includes eDIS updates, price alerts, and login events.
471
710
 
472
711
  Parameters:
473
712
  message (dict): The received message from the WebSocket.
713
+ - May contain price alerts with id_fyers field if present
714
+ - May contain eDIS updates
715
+ - May contain login events
474
716
 
475
717
  """
476
718
  print("General Response:", message)
719
+
477
720
  def onerror(message):
478
721
  """
479
722
  Callback function to handle WebSocket errors.
@@ -1,5 +1,5 @@
1
1
  fyers_apiv3/__init__.py,sha256=1vA_F8dAtLKcyOqrmdUOkw1Syl8gIFUtxDoLde8y94E,18
2
- fyers_apiv3/fyersModel.py,sha256=YeztWqabCf0PTdIYEcDWaBaSM_u6uFqchjbcs2pPh6k,56119
2
+ fyers_apiv3/fyersModel.py,sha256=ov1YZqRAtrE6nP7GG19nK8b2jHABHPMSBwbm9YTFGdY,78536
3
3
  fyers_apiv3/fyers_logger.py,sha256=S_WiIwBLytQ_tyHd9bUC8gZo7GHpANCJO0CS6rCJE90,3795
4
4
  fyers_apiv3/FyersWebsocket/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
5
  fyers_apiv3/FyersWebsocket/data_ws.py,sha256=fSNfsUB_I5-MkWX4hQZvklRQhuQ9n3w5hMDRFrMaBE8,68105
@@ -8,8 +8,8 @@ fyers_apiv3/FyersWebsocket/map.json,sha256=GfAgk-zqzUki5Cu0ZlG08PiMhfKTyGIsPo62m
8
8
  fyers_apiv3/FyersWebsocket/msg_pb2.py,sha256=Po6emBFB6aCmt3rkuN6zjDA7JEzsixejfNSOQYtYgnE,6272
9
9
  fyers_apiv3/FyersWebsocket/order_ws.py,sha256=B0ioHcFinlu40zIYWiU6nLpiEmID3317R_9gdmiPh5M,17451
10
10
  fyers_apiv3/FyersWebsocket/tbt_ws.py,sha256=rlg0taA9KCS8YbyKZ8UxqRw5rUcqRETz0sbM9KBUcF0,21191
11
- fyers_apiv3-3.1.8.dist-info/licenses/LICENSE.txt,sha256=_a5I4lWvSmoZQxwGSPGVVvUbuYby780N9YevsBqNY3k,1063
12
- fyers_apiv3-3.1.8.dist-info/METADATA,sha256=UZIdnpxu2i9mnjMvru1a0CefJ0B9nfXcIgPZgUi4RgQ,19256
13
- fyers_apiv3-3.1.8.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
14
- fyers_apiv3-3.1.8.dist-info/top_level.txt,sha256=IaT774gXqIM6uJpgCQPvXruJBOINsupO9oTe2ao6pkc,12
15
- fyers_apiv3-3.1.8.dist-info/RECORD,,
11
+ fyers_apiv3-3.1.9.dist-info/licenses/LICENSE.txt,sha256=_a5I4lWvSmoZQxwGSPGVVvUbuYby780N9YevsBqNY3k,1063
12
+ fyers_apiv3-3.1.9.dist-info/METADATA,sha256=oNJNLy6DpYePTpsdn9B5s-K-tA7UqlkGO3TKw8i8vdg,25190
13
+ fyers_apiv3-3.1.9.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
14
+ fyers_apiv3-3.1.9.dist-info/top_level.txt,sha256=IaT774gXqIM6uJpgCQPvXruJBOINsupO9oTe2ao6pkc,12
15
+ fyers_apiv3-3.1.9.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.9.0)
2
+ Generator: setuptools (80.10.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5