Schwab-API-Python icon indicating copy to clipboard operation
Schwab-API-Python copied to clipboard

The stream socket is closed abruptly, with a SSL error

Open kartikdjax opened this issue 7 months ago • 10 comments

Description of Bug The stream socket is closed abruptly, with a SSL error. The error message is,

Here is the main function executing async def main(): global main_loop main_loop = asyncio.get_running_loop() await startSocket()

Initialize Schwab API client

client = schwabdev.Client('adaad', 'adasda', 'https://127.0.0.1:8841/')

define a variable for the steamer:

global streamer

Define the streamer

streamer = client.stream

Manual start the stream with the handler

streamer.start(handler_wrapper)

Auto start the stream with the handler

start_time = datetime.time(9, 29, 50) # Create a time object stop_time = datetime.time(16, 0, 0) # Create a time object

streamer.start_auto( receiver=handler_wrapper, start_time=start_time, # Hours and minutes are passed as integers stop_time=stop_time, # Hours and minutes as integers on_days=(0, 1, 2, 3, 4), now_timezone=zoneinfo.ZoneInfo("America/New_York"), daemon=True )

Subscribe to the desired data stream

await streamer.send_async(streamer.level_one_futures("/ES", fields=list(range(0, 43)))) await streamer.send_async(streamer.level_one_futures("/MES", fields=list(range(0, 43))))

await subscribe_to_equities(streamer, "$SPX", "SPXW") await subscribe_to_equities(streamer, "SPY", "SPY ")

await generate_custom_instruments()

Schedule the dynamic adjustment of the middle strike price every 2 minutes

schedule.every(15).minutes.do(adjust_middle_strike)

Schedule the dynamic adjustment of the middle strike price every 2 minutes

schedule.every(15).minutes.do(run_async_job) asyncio.create_task(scheduler_loop()) #await scheduler_loop() # Start the scheduling loop

import time

try: while True: # time.sleep(1) # Sleep to reduce CPU usage in the loop await asyncio.sleep(1) # Non-blocking sleep to keep the event loop alive except KeyboardInterrupt: # Handle clean shutdown on Ctrl+C logging.info("Shutting down streamer...") streamer.stop(clear_subscriptions=False)

Stop the stream after 60 seconds for demo purposes

time.sleep(60)

streamer.stop()

rror/Exception Log ERROR:asyncio:Fatal error on SSL protocol protocol: <asyncio.sslproto.SSLProtocol object at 0x7454f5c938d0> transport: <_SelectorSocketTransport closing fd=11 read=idle write=<idle, bufsize=0>> Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 694, in _write_appdata self._do_write() File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 709, in _do_write del self._write_backlog[0]

IndexError: deque index out of range
ERROR:Schwabdev:no close frame received or sent
INFO:Schwabdev:Stream is not active, request queued.
ERROR:Schwabdev:Stream connection Error. Reconnecting in 2.0 seconds...
INFO:Schwabdev:Stream is not active, request queued.
INFO:Schwabdev:Stream is not active, request queued.

kartikdjax avatar Jun 25 '25 06:06 kartikdjax

Are you on MacOS?

tylerebowers avatar Jun 25 '25 15:06 tylerebowers

Nope, the server is Ubuntu 24.04 LTS.

kartikdjax avatar Jun 26 '25 05:06 kartikdjax

If you just use one of the examples does it work? Try processing streming data: https://tylerebowers.github.io/Schwabdev/?source=pages%2Fexamples.html

tylerebowers avatar Jun 29 '25 22:06 tylerebowers

Yes, i'm following the similar to as below, streamer.start_auto( receiver=handler_wrapper, start_time=start_time, # Hours and minutes are passed as integers stop_time=stop_time, # Hours and minutes as integers on_days=(0, 1, 2, 3, 4), now_timezone=zoneinfo.ZoneInfo("America/New_York"), daemon=True )

# Subscribe to the desired data stream
await streamer.send_async(streamer.level_one_futures("/ES", fields=list(range(0, 43))))
await streamer.send_async(streamer.level_one_futures("/MES", fields=list(range(0, 43)))

kartikdjax avatar Jun 30 '25 12:06 kartikdjax

No, I mean download the file and run it so we can reduce environment differences.

tylerebowers avatar Jun 30 '25 13:06 tylerebowers

Yes, actually i have installed through Python lib, and it's working. We are processing stream data. But the mentioned error facing in some times, in rare case. The thing is we couldn't handle with exceptions, and streams stops.

kartikdjax avatar Jul 07 '25 05:07 kartikdjax

stream data is {"service": "LEVELONE_OPTIONS", "timestamp": 1753983923937, "content": [{"key": "SPXW 250731P06370000", "3": 8.1, "11": -4.35, "16": 45, "17": 17, "35": 6374.35, "37": 8.05, "38": 1753983923828, "45": -16.6028, "46": -67.34650831}, {"key": "SPXW 250731P06450000", "3": 75.7, "11": 75.65, "17": 4, "25": 3.35, "35": 6374.35, "37": 75.4, "38": 1753983923829, "45": -11.8595, "46": -13.59107031}, {"key": "SPY 250731P00625000", "11": -10.52, "16": 647, "35": 635.52, "38": 1753983923880}, {"key": "SPY 250731C00630000", "11": 5.52, "16": 113, "25": -2e-08, "35": 635.52, "38": 1753983923737}, {"key": "SPY 250731P00648000", "16": 22, "38": 1753983923021}, {"key": "SPXW 250731P06290000", "10": 28.27773821, "11": -84.35, "17": 187, "28": -0.01851143, "29": 0.00111216, "30": -0.27500162, "31": 0.06535786, "32": -0.00060492, "34": 0.27500162, "35": 6374.35, "38": 1753983923620}, {"key": "SPY 250731P00631000", "4": 0.18, "8": 67004, "11": -4.52, "16": 4522, "17": 531, "19": -1.01, "25": 0.18000001, "35": 635.52, "38": 1753983923861, "39": 1753983923404, "44": -84.87394958}, {"key": "SPXW 250731P06335000", "11": -39.35, "16": 192, "17": 87, "35": 6374.35, "38": 1753983923618}, {"key": "SPXW 250731C06180000", "2": 194.4, "11": 194.35, "16": 5, "17": 6, "25": 20.92999878, "35": 6374.35, "37": 194.75, "38": 1753983923620, "45": 10.95, "46": 5.95756257}, {"key": "SPXW 250731C06345000", "2": 31.8, "3": 32.2, "11": 29.35, "17": 29, "25": 0.04999962, "35": 6374.35, "37": 32, "38": 1753983923808, "45": -0.5474, "46": -1.68185477}, {"key": "SPXW 250731P06255000", "11": -119.35, "17": 440, "35": 6374.35, "38": 1753983923632}, {"key": "SPXW 250731C06265000", "2": 109.5, "3": 110.2, "11": 109.35, "16": 3, "17": 3, "25": 14.37000122, "35": 6374.35, "38": 1753983923728}, {"key": "SPXW 250731C06305000", "3": 70.3, "11": 69.35, "16": 7, "17": 1, "25": 1.05000153, "35": 6374.35, "37": 70.05, "38": 1753983923837, "45": 6.1653, "46": 9.65066753}, {"key": "SPXW 250731C06185000", "2": 189.5, "3": 190.2, "11": 189.35, "16": 3, "17": 3, "25": 28.47000732, "35": 6374.35, "37": 189.85, "38": 1753983923729, "45": 11.0172, "46": 6.16061483}, {"key": "SPXW 250731C06225000", "2": 149.5, "3": 150.2, "11": 149.35, "17": 3, "25": 14.87999573, "35": 6374.35, "37": 149.85, "38": 1753983923729, "45": 10.7119, "46": 7.69875397}, {"key": "SPY 250731P00643000", "17": 102, "38": 1753983923105}, {"key": "SPY 250731C00612000", "11": 23.52, "25": 0.11999939, "35": 635.52, "38": 1753983923447}, {"key": "SPXW 250731P06375000", "11": 0.65, "16": 69, "17": 60, "25": 9.6, "35": 6374.35, "38": 1753983923827}, {"key": "SPXW 250731C06425000", "4": 0.29, "8": 43374, "10": 17.9344266, "16": 771, "17": 972, "18": 1, "19": -2.0418, "25": 0.28999999, "28": 0.0255646, "29": 0.00230325, "30": -0.25011222, "31": 0.08584483, "32": 0.00083218, "34": 0.25011222, "38": 1753983923011, "39": 1753983923011, "44": -87.56325585}, {"key": "SPXW 250731P06415000", "3": 41, "11": 40.65, "16": 1, "25": 2.19999847, "35": 6374.35, "37": 40.8, "38": 1753983923847, "45": -14.1836, "46": -25.79605555}, {"key": "SPY 250731P00637000", "2": 2.11, "3": 2.14, "11": 1.48, "16": 213, "17": 32, "25": 0.6700001, "35": 635.52, "37": 2.125, "38": 1753983923860, "45": -1.5985, "46": -42.93003894}, {"key": "SPXW 250731C06340000", "2": 36.3, "3": 36.7, "11": 34.35, "16": 3, "17": 29, "25": -0.85, "35": 6374.35, "37": 36.5, "38": 1753983923727, "45": 0.6732, "46": 1.87904027}, {"key": "SPXW 250731C06295000", "2": 79.8, "3": 80.3, "11": 79.35, "17": 5, "25": -6.15000305, "35": 6374.35, "37": 80.05, "38": 1753983923852, "45": 7.3797, "46": 10.15504271}, {"key": "SPXW 250731C06310000", "11": 64.35, "17": 1, "25": -0.32000122, "35": 6374.35, "38": 1753983923810}, {"key": "SPXW 250731C06385000", "4": 5.44, "8": 19086, "11": -10.65, "16": 84, "17": 24, "19": -6.1122, "25": 5.44000006, "35": 6374.35, "38": 1753983923828, "39": 1753983923442, "44": -52.90940254}, {"key": "SPY 250731C00617000", "17": 26, "38": 1753983923020}, {"key": "SPY 250731P00632000", "4": 0.29, "8": 112341, "11": -3.52, "16": 911, "17": 638, "19": -1.205, "25": 0.28999999, "35": 635.52, "38": 1753983923900, "39": 1753983923821, "44": -80.60200669}, {"key": "SPXW 250731C06230000", "2": 144.5, "3": 145.2, "11": 144.35, "17": 3, "25": 1.15999451, "35": 6374.35, "37": 144.85, "38": 1753983923729, "45": 10.6363, "46": 7.92489887}, {"key": "SPXW 250731P06410000", "11": 35.65, "16": 2, "17": 13, "25": 1.64999924, "35": 6374.35, "38": 1753983923827}, {"key": "SPY 250731C00636000", "11": -0.48, "16": 318, "17": 134, "35": 635.52, "38": 1753983923861}, {"key": "SPXW 250731P06215000", "10": 44.65828791, "11": -159.35, "17": 313, "28": -0.00601468, "29": 0.00026468, "30": -0.12500279, "31": 0.02456459, "32": -0.00019673, "34": 0.12500279, "35": 6374.35, "38": 1753983923641}, {"key": "SPXW 250731P06305000", "10": 25.41313742, "11": -69.35, "28": -0.02835942, "29": 0.00177249, "30": -0.40004155, "31": 0.09361116, "32": -0.00092663, "34": 0.40004155, "35": 6374.35, "38": 1753983923620}, {"key": "SPXW 250731C06380000", "11": -5.65, "16": 77, "17": 2, "35": 6374.35, "38": 1753983923828}, {"key": "SPXW 250731P06285000", "11": -89.35, "35": 6374.35, "38": 1753983923609}, {"key": "SPXW 250731P06260000", "16": 719, "38": 1753983923019}, {"key": "SPY 250731P00624000", "11": -11.52, "17": 10950, "35": 635.52, "38": 1753983923798}, {"key": "SPY 250731C00631000", "11": 4.52, "16": 77, "17": 22, "25": 0.11000011, "35": 635.52, "38": 1753983923889}, {"key": "SPY 250731P00618000", "11": -17.52, "35": 635.52, "38": 1753983923541}, {"key": "SPY 250731C00642000", "11": -6.48, "16": 6666, "17": 8391, "35": 635.52, "38": 1753983923772}, {"key": "SPXW 250731P06455000", "3": 80.7, "11": 80.65, "16": 5, "17": 4, "25": 3.75000153, "35": 6374.35, "37": 80.4, "38": 1753983923829, "45": -11.6839, "46": -12.68832011}, {"key": "SPXW 250731P06425000", "2": 50.2, "3": 50.9, "11": 50.65, "16": 6, "17": 4, "25": 0.50999985, "35": 6374.35, "37": 50.55, "38": 1753983923829, "45": -13.3694, "46": -20.91602862}, {"key": "SPY 250731C00634000", "4": 2.2, "8": 22457, "11": 1.52, "16": 30, "17": 36, "19": -0.3765, "25": 0.68000005, "35": 635.52, "38": 1753983923808, "39": 1753983923320, "44": -14.61284689}, {"key": "SPY 250731P00644000", "2": 8.49, "11": 8.48, "16": 20, "25": 0.48000004, "35": 635.52, "37": 8.52, "38": 1753983923736, "45": -1.1802, "46": -12.16675945}, {"key": "SPXW 250731C06350000", "2": 27.5, "11": 24.35, "16": 3, "17": 5, "25": 2.75000038, "35": 6374.35, "37": 27.65, "38": 1753983923828, "45": -1.618, "46": -5.52822195}, {"key": "SPXW 250731P06460000", "3": 85.7, "11": 85.65, "16": 4, "17": 4, "25": -15.55000153, "35": 6374.35, "37": 85.4, "38": 1753983923829, "45": -11.5356, "46": -11.90027193}, {"key": "SPY 250731C00640000", "11": -4.48, "17": 3630, "35": 635.52, "38": 1753983923769}, {"key": "SPY 250731C00628000", "2": 7.53, "11": 7.52, "16": 102, "17": 106, "25": -0.09000017, "35": 635.52, "37": 7.565, "38": 1753983923589, "45": 0.5826, "46": 8.34383593}, {"key": "SPXW 250731C06175000", "2": 199.4, "3": 200.1, "11": 199.35, "16": 3, "17": 3, "25": 28.65, "35": 6374.35, "38": 1753983923729}, {"key": "SPY 250731P00638000", "11": 2.48, "16": 248, "17": 122, "25": 0.45000007, "35": 635.52, "38": 1753983923834}, {"key": "SPXW 250731P06360000", "3": 4.9, "11": -14.35, "16": 174, "17": 10, "35": 6374.35, "37": 4.85, "38": 1753983923739, "45": -14.5471, "46": -74.99626233}, {"key": "SPXW 250731C06355000", "2": 23.4, "3": 23.6, "11": 19.35, "16": 2, "17": 2, "25": 3.94999924, "35": 6374.35, "37": 23.5, "38": 1753983923828, "45": -2.4887, "46": -9.57608499}, {"key": "SPXW 250731C06200000", "2": 174.5, "3": 175.1, "11": 174.35, "16": 2, "17": 5, "25": 5.64000549, "35": 6374.35, "37": 174.8, "38": 1753983923829, "45": 10.8652, "46": 6.62775689}, {"key": "SPXW 250731C06290000", "2": 84.8, "3": 85.3, "11": 84.35, "17": 6, "25": -5.25000153, "35": 6374.35, "37": 85.05, "38": 1753983923839, "45": 7.9869, "46": 10.36410422}, {"key": "SPY 250731P00633000", "11": -2.52, "16": 130, "17": 1713, "35": 635.52, "38": 1753983923890}, {"key": "SPXW 250731C06235000", "11": 139.35, "16": 4, "17": 4, "25": -13.35, "35": 6374.35, "38": 1753983923829}, {"key": "SPY 250731C00623000", "17": 20, "38": 1753983923021}, {"key": "SPXW 250731P06520000", "3": 145.7, "10": 34.19152329, "28": -0.99823169, "29": 0.00011447, "30": -0.08301524, "31": 0.00813356, "32": -0.03328975, "34": 145.70301524, "37": 145.35, "38": 1753983923033, "45": -11.2897, "46": -7.20743209}, {"key": "SPXW 250731P06365000", "2": 6.2, "4": 6.3, "8": 46567, "11": -9.35, "16": 150, "17": 110, "19": -15.725, "25": 6.30000019, "35": 6374.35, "37": 6.3, "38": 1753983923839, "39": 1753983923620, "44": -71.39614075, "45": -15.725, "46": -71.39614075}, {"key": "SPXW 250731P06210000", "10": 45.91670239, "11": -164.35, "17": 447, "28": -0.0058637, "29": 0.00025169, "30": -0.12500178, "31": 0.02401705, "32": -0.00019181, "34": 0.12500178, "35": 6374.35, "38": 1753983923641}, {"key": "SPXW 250731C06415000", "11": -40.65, "16": 204, "17": 184, "35": 6374.35, "38": 1753983923739}, {"key": "SPXW 250731C06170000", "2": 204.5, "3": 205.1, "11": 204.35, "25": 16.95000305, "35": 6374.35, "37": 204.8, "38": 1753983923827, "45": 11.021, "46": 5.68740679}, {"key": "SPY 250731P00623000", "11": -12.52, "16": 11948, "17": 12727, "35": 635.52, "38": 1753983923798}, {"key": "SPXW 250731P06205000", "10": 47.17272253, "11": -169.35, "17": 594, "28": -0.00572068, "29": 0.00023968, "30": -0.12500187, "31": 0.02349657, "32": -0.00018715, "34": 0.12500187, "35": 6374.35, "38": 1753983923641}, {"key": "SPXW 250731P06465000", "3": 90.7, "11": 90.65, "16": 5, "17": 4, "25": 3.85, "35": 6374.35, "37": 90.4, "38": 1753983923829, "45": -11.4773, "46": -11.26580701}, {"key": "SPXW 250731P06310000", "11": -64.35, "17": 311, "35": 6374.35, "38": 1753983923810}, {"key": "SPXW 250731C06240000", "2": 134.5, "3": 135.2, "11": 134.35, "17": 3, "25": -5.1, "35": 6374.35, "37": 134.85, "38": 1753983923729, "45": 10.4851, "46": 8.4309158}, {"key": "SPY 250731C00613000", "11": 22.52, "17": 26, "25": 0.50000046, "35": 635.52, "38": 1753983923619}, {"key": "SPXW 250731C06395000", "11": -20.65, "16": 75, "17": 2, "35": 6374.35, "38": 1753983923828}, {"key": "SPXW 250731C06410000", "11": -35.65, "35": 6374.35, "38": 1753983923456}, {"key": "SPY 250731C00641000", "8": 156700, "11": -5.48, "16": 8297, "17": 4822, "35": 635.52, "38": 1753983923852, "39": 1753983923675}, {"key": "SPY 250731C00629000", "11": 6.52, "16": 108, "25": 0.07000015, "35": 635.52, "38": 1753983923841}, {"key": "SPXW 250731P06315000", "11": -59.35, "16": 33, "35": 6374.35, "38": 1753983923633}, {"key": "SPXW 250731C06390000", "4": 3.83, "8": 35109, "11": -15.65, "16": 158, "17": 2, "18": 8, "19": -6.1813, "25": 3.82999992, "35": 6374.35, "38": 1753983923828, "39": 1753983923625, "44": -61.74323015}, {"key": "SPXW 250731P06420000", "2": 45.3, "11": 45.65, "16": 9, "17": 7, "25": 3.76999817, "35": 6374.35, "37": 45.65, "38": 1753983923829, "45": -13.8015, "46": -23.21472124}, {"key": "SPY 250731P00639000", "2": 3.67, "11": 3.48, "16": 124, "17": 252, "25": 0.26000001, "35": 635.52, "37": 3.695, "38": 1753983923804, "45": -1.4946, "46": -28.79990751}, {"key": "SPXW 250731C06300000", "2": 74.9, "3": 75.3, "11": 74.35, "16": 3, "17": 5, "25": -0.35, "35": 6374.35, "37": 75.1, "38": 1753983923847, "45": 6.8225, "46": 9.99231079}, {"key": "SPY 250731C00635000", "8": 62738, "11": 0.52, "16": 161, "17": 92, "18": 2, "25": 1.03999994, "35": 635.52, "38": 1753983923898, "39": 1753983923328}, {"key": "SPXW 250731C06285000", "2": 89.6, "3": 90.3, "11": 89.35, "16": 4, "17": 6, "25": -9.04999695, "35": 6374.35, "37": 89.95, "38": 1753983923829, "45": 8.4513, "46": 10.36985866}, {"key": "SPXW 250731C06245000", "2": 129.5, "3": 130.2, "11": 129.35, "25": 7.06000366, "35": 6374.35, "37": 129.85, "38": 1753983923728, "45": 10.3845, "46": 8.6924677}, {"key": "SPY 250731C00609000", "17": 20, "38": 1753983923020}, {"key": "SPXW 250731C06325000", "2": 50.4, "3": 50.8, "11": 49.35, "16": 2, "17": 7, "25": 0.24999847, "35": 6374.35, "37": 50.6, "38": 1753983923828, "45": 3.6779, "46": 7.83831073}, {"key": "SPXW 250731C06360000", "11": 14.35, "16": 26, "17": 2, "25": 5.25000038, "35": 6374.35, "38": 1753983923828}, {"key": "SPXW 250731C06440000", "10": 20.17554329, "11": -65.65, "17": 592, "28": 0.01240541, "29": 0.00110525, "30": -0.12501932, "31": 0.04634152, "32": 0.0004038, "34": 0.12501932, "35": 6374.35, "38": 1753983923174}, {"key": "SPXW 250731C06405000", "11": -30.65, "17": 179, "35": 6374.35, "38": 1753983923632}, {"key": "SPXW 250731P06200000", "10": 48.42642541, "11": -174.35, "16": 477, "17": 580, "28": -0.00558496, "29": 0.00022855, "30": -0.12500197, "31": 0.02300096, "32": -0.00018272, "34": 0.12500197, "35": 6374.35, "38": 1753983923641}, {"key": "SPY 250731P00634000", "11": -1.52, "16": 424, "17": 189, "35": 635.52, "38": 1753983923879}, {"key": "SPXW 250731P06355000", "11": -19.35, "16": 124, "17": 69, "35": 6374.35, "38": 1753983923836}, {"key": "SPY 250731P00657000", "16": 16, "38": 1753983923621}, {"key": "SPY 250731P00628000", "11": -7.52, "16": 519, "17": 9581, "35": 635.52, "38": 1753983923852}, {"key": "SPY 250731C00638000", "11": -2.48, "16": 346, "17": 1329, "35": 635.52, "38": 1753983923841}, {"key": "SPXW 250731P06435000", "2": 60.1, "3": 60.8, "11": 60.65, "16": 8, "17": 6, "25": 0.96000061, "35": 6374.35, "37": 60.45, "38": 1753983923829, "45": -12.6424, "46": -17.29646311}, {"key": "SPXW 250731C06280000", "2": 94.6, "11": 94.35, "16": 6, "17": 5, "25": 7.62000122, "35": 6374.35, "37": 94.9, "38": 1753983923829, "45": 8.7258, "46": 10.1257685}, {"key": "SPY 250731C00633000", "11": 2.52, "16": 140, "17": 116, "25": 0.36000011, "35": 635.52, "38": 1753983923905}, {"key": "SPY 250731P00616000", "11": -19.52, "35": 635.52, "38": 1753983923841}, {"key": "SPY 250731C00627000", "11": 8.52, "25": -0.55000021, "35": 635.52, "38": 1753983923857}, {"key": "SPXW 250731P06350000", "11": -24.35, "16": 202, "17": 98, "35": 6374.35, "38": 1753983923837}, {"key": "SPXW 250731C06210000", "2": 164.5, "11": 164.35, "16": 6, "25": 2.81000366, "35": 6374.35, "37": 164.8, "38": 1753983923620, "45": 10.7924, "46": 7.00770611}, {"key": "SPXW 250731C06365000", "2": 16, "4": 16.1, "8": 4823, "11": 9.35, "16": 9, "17": 5, "19": -4.3301, "25": 6.75000038, "35": 6374.35, "37": 16.05, "38": 1753983923828, "39": 1753983923717, "44": -21.19470781, "45": -4.3801, "46": -21.43944474}, {"key": "SPXW 250731P06470000", "2": 95, "3": 95.7, "11": 95.65, "16": 7, "17": 7, "25": 1.00000153, "35": 6374.35, "37": 95.35, "38": 1753983923791, "45": -11.469, "46": -10.73685393}, {"key": "SPY 250731P00640000", "11": 4.48, "16": 16, "17": 101, "25": 0.1700001, "35": 635.52, "38": 1753983923738}, {"key": "SPXW 250731P06320000", "11": -54.35, "16": 257, "17": 97, "35": 6374.35, "38": 1753983923810}, {"key": "SPXW 250731P06395000", "2": 22.7, "3": 23.1, "11": 20.65, "16": 36, "25": 3.97000084, "35": 6374.35, "37": 22.9, "38": 1753983923827, "45": -17.1616, "46": -42.83802943}, {"key": "SPY 250731C00603000", "11": 32.51, "25": 2.12999939, "35": 635.51, "38": 1753983922906}, {"key": "SPXW 250731C06400000", "8": 66912, "11": -25.65, "16": 36, "17": 83, "18": 2, "35": 6374.35, "38": 1753983923810, "39": 1753983923694}, {"key": "SPY 250731C00622000", "17": 20, "38": 1753983923021}, {"key": "SPXW 250731P06475000", "2": 100, "3": 100.7, "11": 100.65, "16": 5, "25": 1.65000305, "35": 6374.35, "37": 100.35, "38": 1753983923829, "45": -11.4265, "46": -10.22263177}, {"key": "SPXW 250731P06430000", "2": 55.2, "3": 55.8, "11": 55.65, "16": 4, "17": 4, "25": 4.25000153, "35": 6374.35, "37": 55.5, "38": 1753983923829, "45": -13.0059, "46": -18.98508012}, {"key": "SPXW 250731C06250000", "2": 124.5, "11": 124.35, "16": 7, "17": 7, "25": -2.08000336, "35": 6374.35, "37": 124.85, "38": 1753983923728, "45": 10.2589, "46": 8.95261499}, {"key": "SPXW 250731C06445000", "4": 0.09, "8": 25105, "10": 20.88442661, "11": -70.65, "16": 1286, "17": 773, "18": 1, "19": -0.785, "25": 0.09, "28": 0.00984197, "29": 0.00087302, "30": -0.10010633, "31": 0.03789075, "32": 0.00032036, "34": 0.10010633, "35": 6374.35, "38": 1753983923837, "39": 1753983923011, "44": -89.71428571}, {"key": "SPXW 250731P06390000", "2": 19, "3": 19.3, "11": 15.65, "16": 5, "17": 28, "25": 4.24999962, "35": 6374.35, "37": 19.15, "38": 1753983923828, "45": -17.4531, "46": -47.68202693}, {"key": "SPXW 250731C06275000", "2": 99.6, "11": 99.35, "16": 7, "17": 4, "25": -8.44999847, "35": 6374.35, "37": 99.9, "38": 1753983923829, "45": 9.0504, "46": 9.96195911}, {"key": "SPY 250731P00635000", "11": -0.52, "16": 289, "17": 171, "35": 635.52, "38": 1753983923862}, {"key": "SPXW 250731C06205000", "2": 169.5, "11": 169.35, "16": 6, "25": 19.92000427, "35": 6374.35, "37": 169.8, "38": 1753983923620, "45": 10.8288, "46": 6.81179987}, {"key": "SPY 250731P00629000", "11": -6.52, "17": 5222, "35": 635.52, "38": 1753983923808}, {"key": "SPY 250731C00639000", "8": 236580, "11": -3.48, "16": 2344, "17": 905, "35": 635.52, "38": 1753983923864, "39": 1753983923664}, {"key": "SPXW 250731P06325000", "3": 0.85, "11": -49.35, "16": 377, "17": 19, "35": 6374.35, "37": 0.825, "38": 1753983923810, "45": -7.6969, "46": -90.3190603}, {"key": "SPXW 250731P06600000", "3": 225.7, "10": 50.67707589, "11": 225.62, "25": -40.06999695, "28": -0.99876798, "29": 5.542e-05, "30": -0.08300754, "31": 0.00583644, "32": -0.0337164, "34": 225.70300754, "35": 6374.38, "37": 225.35, "38": 1753983923044, "45": -11.2169, "46": -4.741534}, {"key": "SPXW 250731P06345000", "2": 2.15, "11": -29.35, "16": 226, "17": 69, "35": 6374.35, "37": 2.2, "38": 1753983923828, "45": -11.9447, "46": -84.44647112}, {"key": "SPXW 250731C06270000", "2": 104.6, "3": 105.2, "11": 104.35, "16": 4, "17": 6, "25": -3.85, "35": 6374.35, "37": 104.9, "38": 1753983923829, "45": 9.3749, "46": 9.81406981}, {"key": "SPY 250731C00611000", "11": 24.52, "17": 26, "25": 1.70999954, "35": 635.52, "38": 1753983923619}, {"key": "SPXW 250731C06335000", "2": 40.9, "3": 41.3, "11": 39.35, "16": 4, "25": 1.05000153, "35": 6374.35, "37": 41.1, "38": 1753983923810, "45": 1.8485, "46": 4.70937416}, {"key": "SPXW 250731P06280000", "17": 126, "38": 1753983923057}, {"key": "SPXW 250731C06255000", "2": 119.5, "3": 120.2, "11": 119.35, "16": 3, "25": -2.12999878, "35": 6374.35, "38": 1753983923729}, {"key": "SPY 250731C00620000", "11": 15.52, "17": 28, "25": -0.12999966, "35": 635.52, "38": 1753983923619}, {"key": "SPY 250731C00643000", "11": -7.48, "16": 9137, "35": 635.52, "38": 1753983923835}, {"key": "SPXW 250731P06440000", "2": 65.1, "3": 65.6, "11": 65.65, "16": 4, "25": 7.04999695, "35": 6374.35, "37": 65.35, "38": 1753983923839, "45": -12.4108, "46": -15.96022675}, {"key": "SPXW 250731C06370000", "3": 12.9, "11": 4.35, "16": 48, "17": 46, "25": 8.34999981, "35": 6374.35, "37": 12.8, "38": 1753983923827, "45": -5.2586, "46": -29.11964383}, {"key": "SPXW 250731C06315000", "2": 60.1, "4": 60.3, "8": 157, "11": 59.35, "16": 1, "18": 1, "19": 5.201, "25": 0.94999924, "35": 6374.35, "37": 60.3, "38": 1753983923810, "39": 1753983923019, "44": 9.43937277, "45": 5.201, "46": 9.43937277}, {"key": "SPY 250731P00641000", "3": 5.58, "11": 5.48, "17": 18, "25": 0.23000004, "35": 635.52, "37": 5.55, "38": 1753983923320, "45": -1.3301, "46": -19.33256784}, {"key": "SPXW 250731C06190000", "2": 184.5, "3": 185.2, "11": 184.35, "16": 3, "17": 3, "25": 26.70000305, "35": 6374.35, "37": 184.85, "38": 1753983923729, "45": 10.9844, "46": 6.31775348}, {"key": "SPXW 250731C06330000", "2": 45.6, "11": 44.35, "16": 4, "17": 4, "25": -0.05000076, "35": 6374.35, "37": 45.8, "38": 1753983923828, "45": 2.9663, "46": 6.92515473}, {"key": "SPXW 250731P06405000", "11": 30.65, "16": 2, "17": 17, "25": 3.35, "35": 6374.35, "38": 1753983923852}, {"key": "SPY 250731P00626000", "11": -9.52, "16": 10342, "17": 8347, "35": 635.52, "38": 1753983923772}, {"key": "SPXW 250731C06485000", "8": 7717, "10": 26.67532144, "11": -110.65, "18": 8, "28": 0.00218285, "29": 0.0001785, "30": -0.02464799, "31": 0.00989544, "32": 7.104e-05, "34": 0.02464799, "35": 6374.35, "39": 1753983923625}, {"key": "SPY 250731P00630000", "4": 0.12, "8": 83636, "11": -5.52, "17": 4876, "18": 3, "19": -0.845, "25": 0.12, "35": 635.52, "38": 1753983923841, "39": 1753983923166, "44": -87.56476684}, {"key": "SPXW 250731P06495000", "11": 120.65, "25": -26.05000153, "35": 6374.35, "38": 1753983923829}, {"key": "SPY 250731C00637000", "2": 0.63, "3": 0.64, "4": 0.64, "8": 149190, "11": -1.48, "16": 214, "17": 536, "19": -0.45, "25": 0.63999999, "35": 635.52, "37": 0.635, "38": 1753983923875, "39": 1753983922849, "44": -41.28440367, "45": -0.455, "46": -41.74311927}, {"key": "SPXW 250731C06195000", "2": 179.5, "3": 180.2, "11": 179.35, "16": 3, "17": 3, "25": 15.84999695, "35": 6374.35, "37": 179.85, "38": 1753983923729, "45": 10.9516, "46": 6.48413484}, {"key": "SPY 250731C00616000", "11": 19.52, "17": 20, "25": -1.33999969, "35": 635.52, "38": 1753983923736}, {"key": "SPXW 250731P06340000", "2": 1.65, "4": 1.7, "8": 41325, "11": -34.35, "16": 217, "17": 125, "18": 1, "19": -10.7247, "25": 1.70000005, "35": 6374.35, "37": 1.7, "38": 1753983923827, "39": 1753983923740, "44": -86.31757708, "45": -10.7247, "46": -86.31757708}, {"key": "SPY 250731C00632000", "2": 3.78, "11": 3.52, "16": 96, "17": 214, "25": 0.14000009, "35": 635.52, "37": 3.8, "38": 1753983923771, "45": -0.0679, "46": -1.75547455}, {"key": "SPXW 250731C06375000", "11": -0.65, "16": 106, "17": 50, "35": 6374.35, "38": 1753983923827}, {"key": "SPXW 250731C06220000", "2": 154.5, "3": 155.2, "11": 154.35, "17": 3, "25": 5.61000671, "35": 6374.35, "37": 154.85, "38": 1753983923728, "45": 10.7625, "46": 7.46941962}, {"key": "SPXW 250731P06400000", "2": 26.9, "11": 25.65, "16": 7, "17": 16, "25": 1.55999908, "35": 6374.35, "37": 27.1, "38": 1753983923828, "45": -16.6663, "46": -38.0802124}, {"key": "SPY 250731C00626000", "2": 9.5, "11": 9.52, "25": -0.29000046, "35": 635.52, "37": 9.535, "38": 1753983923857, "45": 0.7716, "46": 8.80480179}, {"key": "SPXW 250731P06330000", "3": 1.05, "11": -44.35, "16": 370, "17": 1, "35": 6374.35, "37": 1.025, "38": 1753983923714, "45": -8.4078, "46": -89.13366127}, {"key": "SPXW 250731C06320000", "4": 55.4, "8": 1388, "11": 54.35, "16": 2, "17": 1, "19": 4.3894, "25": 1.05000153, "35": 6374.35, "38": 1753983923847, "39": 1753983923019, "44": 8.6048782}, {"key": "SPXW 250731P06500000", "2": 124.8, "3": 125.7, "11": 125.65, "17": 1, "25": -9.45000305, "35": 6374.35, "37": 125.25, "38": 1753983923829, "45": -11.4282, "46": -8.36139194}, {"key": "SPXW 250731P06385000", "2": 15.6, "3": 15.8, "4": 15.77, "8": 39783, "11": 10.65, "16": 17, "17": 6, "18": 1, "19": -17.3746, "25": 5.12000046, "35": 6374.35, "37": 15.7, "38": 1753983923808, "39": 1753983923442, "44": -52.42060547, "45": -17.4446, "46": -52.63180126}, {"key": "SPY 250731P00636000", "3": 1.53, "11": 0.48, "16": 167, "17": 67, "25": 1.03999998, "35": 635.52, "37": 1.525, "38": 1753983923900, "45": -1.5776, "46": -50.84767614}, {"key": "SPXW 250731P06230000", "10": 40.86687193, "11": -144.35, "17": 137, "28": -0.00652245, "29": 0.00031076, "30": -0.1250015, "31": 0.02639217, "32": -0.00021329, "34": 0.1250015, "35": 6374.35, "38": 1753983923779}, {"key": "SPY 250731P00620000", "11": -15.52, "16": 384, "35": 635.52, "38": 1753983923604}, {"key": "SPXW 250731P06490000", "3": 115.9, "10": 27.75236159, "11": 115.65, "25": -14.24999847, "28": -0.99788838, "29": 0.00016582, "30": -0.08263551, "31": 0.00956375, "32": -0.03312512, "34": 115.70263551, "35": 6374.35, "37": 115.3, "38": 1753983923452, "45": -11.3974, "46": -8.99576471}, {"key": "SPY 250731C00604000", "11": 31.52, "16": 42, "17": 28, "25": 1.70000122, "35": 635.52, "38": 1753983923619}, {"key": "SPY 250731C00595000", "11": 40.52, "17": 32, "25": -0.93999817, "35": 635.52, "38": 1753983923620}, {"key": "SPY 250731P00670000", "38": 1753983922757}, {"key": "SPXW 250731P06445000", "2": 70.1, "3": 70.7, "11": 70.65, "16": 5, "17": 2, "25": 5.18000183, "35": 6374.35, "37": 70.4, "38": 1753983923829, "45": -12.0602, "46": -14.62547993}, {"key": "SPXW 250731C06215000", "2": 159.5, "3": 160.2, "11": 159.35, "16": 3, "17": 3, "25": -24.93999634, "35": 6374.35, "37": 159.85, "38": 1753983923729, "45": 10.8061, "46": 7.25027995}, {"key": "SPXW 250731P06380000", "2": 12.6, "3": 12.8, "4": 12.81, "8": 57361, "11": 5.65, "16": 53, "17": 4, "19": -17.0986, "25": 7.16000042, "35": 6374.35, "37": 12.7, "38": 1753983923847, "39": 1753983923442, "44": -57.16950977, "45": -17.2086, "46": -57.53729696}, {"key": "SPXW 250731C06260000", "2": 114.5, "3": 115.2, "11": 114.35, "16": 3, "25": 21.9, "35": 6374.35, "38": 1753983923729}, {"key": "SPY 250731P00642000", "3": 6.56, "11": 6.48, "17": 69, "25": 0.19999983, "35": 635.52, "37": 6.53, "38": 1753983923808, "45": -1.2602, "46": -16.17673487}]}ERROR:asyncio:Fatal error on SSL protocol protocol: <asyncio.sslproto.SSLProtocol object at 0x72bfce1e4110> transport: <_SelectorSocketTransport closing fd=11 read=idle write=<idle, bufsize=0>> Traceback (most recent call last): File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 739, in _do_read self._do_write() File "/usr/local/lib/python3.11/asyncio/sslproto.py", line 709, in _do_write del self._write_backlog[0] ~~~~~~~~~~~~~~~~~~~^^^ IndexError: deque index out of range WARNING:asyncio:socket.send() raised exception.

Facing the same issue again, the thing is, we have written a restart mechanism as well, but this issues blocks the script execution, so the restart method as well doesn't executed propery.

Since we hold to move on production due to few issues, one of them is this issue as well. Kindly support us to move forward.

kartikdjax avatar Aug 01 '25 06:08 kartikdjax

I haven't been active for quite some time... Do you still have this issue?

tylerebowers avatar Sep 22 '25 02:09 tylerebowers

Yes, but not in all the time, quite often in sometime.

kartikdjax avatar Sep 22 '25 11:09 kartikdjax

This seems like an issue with connection in the websocket lib which is unrecoverable. How many synbols are you subscribing to?

tylerebowers avatar Nov 03 '25 17:11 tylerebowers