fyers-apiv3 3.1.6__py3-none-any.whl → 3.1.7__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/FyersWebsocket/tbt_ws.py +1 -1
- {fyers_apiv3-3.1.6.dist-info → fyers_apiv3-3.1.7.dist-info}/METADATA +88 -1
- {fyers_apiv3-3.1.6.dist-info → fyers_apiv3-3.1.7.dist-info}/RECORD +6 -6
- {fyers_apiv3-3.1.6.dist-info → fyers_apiv3-3.1.7.dist-info}/LICENSE.txt +0 -0
- {fyers_apiv3-3.1.6.dist-info → fyers_apiv3-3.1.7.dist-info}/WHEEL +0 -0
- {fyers_apiv3-3.1.6.dist-info → fyers_apiv3-3.1.7.dist-info}/top_level.txt +0 -0
|
@@ -502,7 +502,7 @@ class FyersTbtSocket:
|
|
|
502
502
|
if self.onopen:
|
|
503
503
|
self.onopen()
|
|
504
504
|
open_chans = self._subsinfo.getChannelInfo()
|
|
505
|
-
self.switchChannel(self._subsinfo.getChannelInfo(),
|
|
505
|
+
self.switchChannel(self._subsinfo.getChannelInfo(), set())
|
|
506
506
|
for channel in open_chans:
|
|
507
507
|
self.subscribe(self._subsinfo.getSymbolsInfo(channel), channel, self._subsinfo.getModeInfo(channel))
|
|
508
508
|
except Exception as e:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: fyers_apiv3
|
|
3
|
-
Version: 3.1.
|
|
3
|
+
Version: 3.1.7
|
|
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
|
|
@@ -531,4 +531,91 @@ fyers = order_ws.FyersOrderSocket(
|
|
|
531
531
|
fyers.connect()
|
|
532
532
|
|
|
533
533
|
|
|
534
|
+
```
|
|
535
|
+
|
|
536
|
+
## Getting started with TBT Socket
|
|
537
|
+
|
|
538
|
+
```python
|
|
539
|
+
from fyers_apiv3.FyersWebsocket.tbt_ws import FyersTbtSocket, SubscriptionModes
|
|
540
|
+
|
|
541
|
+
def on_depth_update(ticker, message):
|
|
542
|
+
"""
|
|
543
|
+
Callback function to handle incoming messages from the FyersDataSocket WebSocket.
|
|
544
|
+
|
|
545
|
+
Parameters:
|
|
546
|
+
ticker (str): The symbol for which the message is received.
|
|
547
|
+
message (dict): The received message from the WebSocket.
|
|
548
|
+
|
|
549
|
+
"""
|
|
550
|
+
print("Depth Response:", ticker, message)
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def onerror_message( message):
|
|
554
|
+
"""
|
|
555
|
+
Callback function to handle incoming messages from the FyersDataSocket WebSocket.
|
|
556
|
+
|
|
557
|
+
Parameters:
|
|
558
|
+
message (str): error message from the server
|
|
559
|
+
|
|
560
|
+
"""
|
|
561
|
+
print("server returned error:", message)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
def onerror(message):
|
|
565
|
+
"""
|
|
566
|
+
Callback function to handle WebSocket errors.
|
|
567
|
+
|
|
568
|
+
Parameters:
|
|
569
|
+
message (dict): The error message received from the WebSocket.
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
"""
|
|
573
|
+
print("Error:", message)
|
|
574
|
+
|
|
575
|
+
|
|
576
|
+
def onclose(message):
|
|
577
|
+
"""
|
|
578
|
+
Callback function to handle WebSocket connection close events.
|
|
579
|
+
"""
|
|
580
|
+
print("Connection closed:", message)
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
def onopen():
|
|
584
|
+
"""
|
|
585
|
+
Callback function to subscribe to data type and symbols upon WebSocket connection.
|
|
586
|
+
|
|
587
|
+
"""
|
|
588
|
+
print("Connection opened")
|
|
589
|
+
# Specify the data type and symbols you want to subscribe to
|
|
590
|
+
mode = SubscriptionModes.DEPTH
|
|
591
|
+
Channel = '1'
|
|
592
|
+
# Subscribe to the specified symbols and data type
|
|
593
|
+
symbols = ['NSE:NIFTY25MARFUT']
|
|
594
|
+
|
|
595
|
+
fyers.subscribe(symbol_tickers=symbols, channelNo=Channel, mode=mode)
|
|
596
|
+
fyers.switchChannel(resume_channels=[Channel], pause_channels=[])
|
|
597
|
+
|
|
598
|
+
# Keep the socket running to receive real-time data
|
|
599
|
+
fyers.keep_running()
|
|
600
|
+
|
|
601
|
+
|
|
602
|
+
# Replace the sample access token with your actual access token obtained from Fyers
|
|
603
|
+
access_token = "XCXXXXXXM-100:eyJ0tHfZNSBoLo"
|
|
604
|
+
|
|
605
|
+
fyers = FyersTbtSocket(
|
|
606
|
+
access_token=access_token, # Your access token for authenticating with the Fyers API.
|
|
607
|
+
write_to_file=False, # A boolean flag indicating whether to write data to a log file or not.
|
|
608
|
+
log_path="", # The path to the log file if write_to_file is set to True (empty string means current directory).
|
|
609
|
+
on_open=onopen, # Callback function to be executed upon successful WebSocket connection.
|
|
610
|
+
on_close=onclose, # Callback function to be executed when the WebSocket connection is closed.
|
|
611
|
+
on_error=onerror, # Callback function to handle any WebSocket errors that may occur.
|
|
612
|
+
on_depth_update=on_depth_update, # Callback function to handle depth-related events from the WebSocket
|
|
613
|
+
on_error_message=onerror_message # Callback function to handle server-related erros from the WebSocket.
|
|
614
|
+
)
|
|
615
|
+
|
|
616
|
+
|
|
617
|
+
# Establish a connection to the Fyers WebSocket
|
|
618
|
+
fyers.connect()
|
|
619
|
+
|
|
620
|
+
|
|
534
621
|
```
|
|
@@ -7,9 +7,9 @@ fyers_apiv3/FyersWebsocket/defines.py,sha256=mhKkkQ6FZHFa6e0_83cRYMOucmSn5yHtcod
|
|
|
7
7
|
fyers_apiv3/FyersWebsocket/map.json,sha256=GfAgk-zqzUki5Cu0ZlG08PiMhfKTyGIsPo62mIYotZ4,10075
|
|
8
8
|
fyers_apiv3/FyersWebsocket/msg_pb2.py,sha256=Po6emBFB6aCmt3rkuN6zjDA7JEzsixejfNSOQYtYgnE,6272
|
|
9
9
|
fyers_apiv3/FyersWebsocket/order_ws.py,sha256=npLBtCcpPxclc5YRaVtLvBkRDCF3oV9NabK_y5EwoAk,16998
|
|
10
|
-
fyers_apiv3/FyersWebsocket/tbt_ws.py,sha256
|
|
11
|
-
fyers_apiv3-3.1.
|
|
12
|
-
fyers_apiv3-3.1.
|
|
13
|
-
fyers_apiv3-3.1.
|
|
14
|
-
fyers_apiv3-3.1.
|
|
15
|
-
fyers_apiv3-3.1.
|
|
10
|
+
fyers_apiv3/FyersWebsocket/tbt_ws.py,sha256=rlg0taA9KCS8YbyKZ8UxqRw5rUcqRETz0sbM9KBUcF0,21191
|
|
11
|
+
fyers_apiv3-3.1.7.dist-info/LICENSE.txt,sha256=_a5I4lWvSmoZQxwGSPGVVvUbuYby780N9YevsBqNY3k,1063
|
|
12
|
+
fyers_apiv3-3.1.7.dist-info/METADATA,sha256=JOgjxfBjmTzfhPPt_A0rxaA_ThhD1Tf9_7TZBtKfTro,19232
|
|
13
|
+
fyers_apiv3-3.1.7.dist-info/WHEEL,sha256=jB7zZ3N9hIM9adW7qlTAyycLYW9npaWKLRzaoVcLKcM,91
|
|
14
|
+
fyers_apiv3-3.1.7.dist-info/top_level.txt,sha256=IaT774gXqIM6uJpgCQPvXruJBOINsupO9oTe2ao6pkc,12
|
|
15
|
+
fyers_apiv3-3.1.7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|