Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unsub cmds and lock for websocket.recv #256

Merged
merged 18 commits into from
Oct 28, 2021

Conversation

httran13
Copy link
Contributor

@httran13 httran13 commented Sep 18, 2021

This PR adds an async.lock to streaming.py.

This lock achieves 2 goals:

  1. Prevent websocket.recv() from being called from another coroutine while awaiting, so the locks are placed when retreiving response from the stream: https://websockets.readthedocs.io/en/stable/topics/design.html#concurrency

  2. Ensures when making requests that sending requests and awaiting for responses occur synchronously.

With the lock in place, we can run, from our main program, concurrent programs without running into RuntimeError thrown by websocket.

I've also updated the timesales.py streaming example for a concurrent program to randomly make requests while an infinite loop is running to handle messages.

I've added unit tests for each unsub cmds and did not need to change any existing tests.

tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
tda/streaming.py Outdated Show resolved Hide resolved
Copy link
Contributor

@pssolanki111 pssolanki111 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think use of an asyncio.Lock is quite appropriate and combined with the fact that websocket clients have an in-memory queue (defaults to about 128 MB of objects - which is hard to hit btw unless you are processing stuff on a potato :D ), and the queue would ensure the messages don't get dropped.

Either way, this certainly won't have that big of an impact overall on performance unless someone hitting the API concurrently which doesn't happen with websockets people.

We can always give it out with a soft warning that before you use the unsub methods, be careful of what you're getting yourself into.

@@ -81,14 +86,84 @@ async def handle_queue(self):
msg = await self.queue.get()
pprint.pprint(msg)

async def _dynamic_request(self, service, cmd, symbols):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on our offline conversation, let's cut the example from this PR.

tests/streaming_test.py Show resolved Hide resolved
socket = await self.login_and_get_socket(ws_connect)

socket.recv.side_effect = [json.dumps(self.success_response(
1, 'ACCT_ACTIVITY', 'UNSUBS'))]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That being said, let's investigate what TDA does when you login in and immediately unsub from a stream to which you're not already subbed. My gut tells me this is 1. something people will probably do by mistake and 2. a potentially interesting corner case that we don't understand and should test.

@@ -535,6 +559,18 @@ async def test_account_activity_subs_failure(self, ws_connect):
with self.assertRaises(tda.streaming.UnexpectedResponseCode):
await self.client.account_activity_sub()

@no_duplicates
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one might also be unrealistic. If you can figure out a way to trigger this, great.

tests/streaming_test.py Show resolved Hide resolved
@httran13
Copy link
Contributor Author

httran13 commented Oct 9, 2021

Adding a sample log run here for unsub/sub scenarios. I've executed the below json array cmd, service, and symbols in sequential order and allowed some time for stream data incoming.

Find my comments in =======, the first 2 scenario, i wanted to know td response if i unsubscribe from a service that hasn't been subscribed, the rest are just sub then unsub.

Noticed that once I unsub from a service with the same symbol, I no longer receive data from that service for that symbol. If there's. Its not proven here but if you have a set of subscribe symbols and you unsub another set of symbols, its acts as Set difference.

the client > and client < are the streaming logs that show raw data from the stream, look at these lines for the series of events.

I left my application logs there which pipes all of the data to my sqs services.

[
  {
    "cmd": "subs",
    "service": "chart_equity",
    "symbols": ["SPY"]
  },
  {
    "cmd": "unsubs",
    "service": "chart_equity",
    "symbols": ["SPY"]
  },
  {
    "cmd": "subs",
    "service": "chart_futures",
    "symbols": ["/ES"]
  },
  {
    "cmd": "unsubs",
    "service": "chart_futures",
    "symbols": ["/ES"]
  },
  {
    "cmd": "subs",
    "service": "level_one_equity",
    "symbols": ["SPY"]
  },
  {
    "cmd": "unsubs",
    "service": "level_one_equity",
    "symbols": ["SPY"]
  },
  {
    "cmd": "subs",
    "service": "level_one_option",
    "symbols": ["NET_102221C55"]
  },
  {
    "cmd": "unsubs",
    "service": "level_one_option",
    "symbols": ["NET_102221C55"]
  },
  {
    "cmd": "subs",
    "service": "level_one_futures",
    "symbols": ["/ES"]
  },
  {
    "cmd": "unsubs",
    "service": "level_one_futures",
    "symbols": ["/ES"]
  }

]

And for the logs, starting with start of app ...

2021-10-08 11:48:01,632 tdstreamer.py:81 INFO Returning token from store
client - state = CONNECTING
client - event = connection_made(<asyncio.sslproto._SSLProtocolTransport object at 0x7fbea5dbd880>)
client - event = data_received(<212 bytes>)
client - state = OPEN
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ADMIN", "requestid": "0", "command": "LOGIN", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"credential": "userid=<REDACTED>&token=<REDACTED>&company=AMER&segment=AMER&cddomain=<REDACTED>&usergroup=ACCT&accesslevel=ACCT&authorized=Y&timestamp=1633711682000&appid=<REDACTED>&acl=<REDACTED>", "token": "<REDACTED>", "version": "1.0"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<115 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ADMIN","requestid":"0","command":"LOGIN","timestamp":1633711682418,"content":{"code":0,"msg":"04-1"}}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ADMIN", "requestid": "1", "command": "QOS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"qoslevel": "0"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<55 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ADMIN","requestid":"1","command":"QOS","timestamp":1633711682446,"content":{"code":0,"msg":"QoS command succeeded. Set qoslevel=0"}}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ACCT_ACTIVITY", "requestid": "2", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "<REDACTED>", "fields": "0,1,2,3"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:48:02,647 sqs_client.py:217 INFO Got queue 'streamer-stream-submitter' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-stream-submitter
client - event = data_received(<34 bytes>)
client - event = data_received(<41 bytes>)
client - event = data_received(<139 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711682517"}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ACCT_ACTIVITY","requestid":"2","command":"SUBS","timestamp":1633711682517,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"ACCT_ACTIVITY", "timestamp":1633711682530,"command":"SUBS","content":[{"seq":0,"key":"<REDACTED>","1":"","2":"SUBSCRIBED","3":""}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:48:08,315 sqs_client.py:167 INFO Deleted message: 46434fcb-7f0b-41d2-a849-e1eebe6fd653
2021-10-08 11:48:08,364 sqs_client.py:217 INFO Got queue 'streamer-td-acct-activity' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-acct-activity
2021-10-08 11:48:08,416 sqs_client.py:72 INFO Message sent: f94774cf-23c1-4840-a0fb-abed3500495b: {"seq": 0, "key": "<REDACTED>", "ACCOUNT": "", "MESSAGE_TYPE": "SUBSCRIBED", "MESSAGE_DATA": ""}
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711693479"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : UNSUB from a service that has not been subscribe to
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_EQUITY", "requestid": "3", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "SPY", "fields": "0,1,2,3,4,5,6,7,8"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<39 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_EQUITY","requestid":"3","command":"UNSUBS","timestamp":1633711693505,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711703483"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xe2U\x97\xd3', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xe2U\x97\xd3', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: e25597d3
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711713487"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:48:38,625 sqs_client.py:167 INFO Deleted message: aa82c2d3-d2b3-4e0d-9c2d-234deafac916
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711723531"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : SUB THEN UNSUB from chart_equity
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_EQUITY", "requestid": "4", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "SPY", "fields": "0,1,2,3,4,5,6,7,8"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<10 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711723559"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<18 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_EQUITY","requestid":"4","command":"SUBS","timestamp":1633711723560,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<90 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"CHART_EQUITY", "timestamp":1633711723590,"command":"SUBS","content":[{"seq":3466,"key":"SPY","1":438.42,"2":438.4499,"3":438.34,"4":438.42,"5":73788.0,"6":347,"7":1633711620000,"8":18908}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:48:58,692 sqs_client.py:217 INFO Got queue 'streamer-td-chart-equity' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-chart-equity
2021-10-08 11:48:58,752 sqs_client.py:72 INFO Message sent: 38d062db-3089-44eb-82b0-16b105f5db6c: {"seq": 3466, "key": "SPY", "OPEN_PRICE": 438.42, "HIGH_PRICE": 438.4499, "LOW_PRICE": 438.34, "CLOSE_PRICE": 438.42, "VOLUME": 73788.0, "SEQUENCE": 347, "CHART_TIME": 1633711620000, "CHART_DAY": 18908}
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711735537"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xa3\xb1\x92\xef', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xa3\xb1\x92\xef', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: a3b192ef
client - event = data_received(<50 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"CHART_EQUITY", "timestamp":1633711744105,"command":"SUBS","content":[{"seq":3467,"key":"SPY","1":438.4201,"2":438.4201,"3":438.35,"4":438.3501,"5":19759.0,"6":348,"7":1633711680000,"8":18908}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:49:13,130 sqs_client.py:167 INFO Deleted message: dc57d16d-a3f1-4936-ae61-0c42087896d8
2021-10-08 11:49:13,179 sqs_client.py:217 INFO Got queue 'streamer-td-chart-equity' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-chart-equity
2021-10-08 11:49:13,299 sqs_client.py:72 INFO Message sent: 29510513-18e8-438c-9541-7fe853d463c7: {"seq": 3467, "key": "SPY", "OPEN_PRICE": 438.4201, "HIGH_PRICE": 438.4201, "LOW_PRICE": 438.35, "CLOSE_PRICE": 438.3501, "VOLUME": 19759.0, "SEQUENCE": 348, "CHART_TIME": 1633711680000, "CHART_DAY": 18908}
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711755568"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_EQUITY", "requestid": "5", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "SPY", "fields": "0,1,2,3,4,5,6,7,8"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<19 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_EQUITY","requestid":"5","command":"UNSUBS","timestamp":1633711755609,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711765572"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xec8\x0fc', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xec8\x0fc', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: ec380f63
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711775577"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:49:37,944 sqs_client.py:167 INFO Deleted message: 38770a5d-ede7-4e5f-a3c2-00f5da7ab77e
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711785582"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : UNSUB from chart_futures when chart_futures has not been subscribed
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_FUTURES", "requestid": "6", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES", "fields": "0,1,2,3,4,5,6"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<24 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_FUTURES","requestid":"6","command":"UNSUBS","timestamp":1633711785609,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711795586"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xbbs\xed\xcc', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:50:01,594 sqs_client.py:167 INFO Deleted message: 8f39bec0-dcc0-4013-9e82-3e10ab425f36
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xbbs\xed\xcc', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: bb73edcc
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711805596"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : SUB THEN UNSUB from chart_futures ES symbol
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_FUTURES", "requestid": "7", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES", "fields": "0,1,2,3,4,5,6"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<11 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711805624"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<16 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_FUTURES","requestid":"7","command":"SUBS","timestamp":1633711805624,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<69 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"CHART_FUTURES", "timestamp":1633711805636,"command":"SUBS","content":[{"seq":1504,"key":"/ES","1":1633711740000,"2":4387.75,"3":4388.5,"4":4387.25,"5":4388.25,"6":2065.0}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:50:20,753 sqs_client.py:217 INFO Got queue 'streamer-td-chart-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-chart-futures
2021-10-08 11:50:20,809 sqs_client.py:72 INFO Message sent: 99a0eac0-f5a5-4f45-b001-72f0d8ab32eb: {"seq": 1504, "key": "/ES", "CHART_TIME": 1633711740000, "OPEN_PRICE": 4387.75, "HIGH_PRICE": 4388.5, "LOW_PRICE": 4387.25, "CLOSE_PRICE": 4388.25, "VOLUME": 2065.0}
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711817602"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:50:24,868 sqs_client.py:167 INFO Deleted message: 6dbb390a-3d21-49ab-b0b8-d26c7191079a
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'Zn;]', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'Zn;]', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 5a6e3b5d
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711827606"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_FUTURES", "requestid": "8", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES", "fields": "0,1,2,3,4,5,6"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<19 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_FUTURES","requestid":"8","command":"UNSUBS","timestamp":1633711827694,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711837613"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:50:42,398 sqs_client.py:167 INFO Deleted message: 9f66d093-e9cc-4648-898a-f1824109691f
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xa3/\x00\xeb', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xa3/\x00\xeb', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: a32f00eb
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711847617"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : SUB THEN UNSUB from quote service symbol SPY
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "QUOTE", "requestid": "9", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "SPY", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<10 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711847644"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<23 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"QUOTE","requestid":"9","command":"SUBS","timestamp":1633711847644,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<344 bytes>)
client - event = data_received(<36 bytes>)
client - event = data_received(<22 bytes>)
client - event = data_received(<33 bytes>)
client - event = data_received(<29 bytes>)
client - event = data_received(<91 bytes>)
client - event = data_received(<29 bytes>)
client - event = data_received(<44 bytes>)
client - event = data_received(<75 bytes>)
client - event = data_received(<70 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711847684,"command":"SUBS","content":[{"key":"SPY","delayed":false,"assetMainType":"EQUITY","assetSubType":"ETF","cusip":"78462F103","1":438.39,"2":438.4,"3":438.3902,"4":6,"5":5,"6":"P","7":"Z","8":33999565,"9":16,"10":46247,"11":46247,"12":439.89,"13":437.78,"14":" ","15":438.66,"16":"p","17":true,"18":true,"22":18908,"23":18908,"24":0.0032,"25":"SPDR S&P 500","26":"D","27":2,"28":439.48,"29":-0.2698,"30":454.05,"31":322.6,"33":5.6618,"34":1.29,"39":"PACIFIC","40":"2021-09-17 00:00:00.000","41":true,"42":true,"43":438.3902,"44":16,"45":46247,"46":18908,"47":-0.2698,"48":"Normal","49":438.3902,"50":1633711847538,"51":1633711847545,"52":1633711847545}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711848264,"command":"SUBS","content":[{"key":"SPY","4":3,"5":6,"7":"T","11":46248,"50":1633711848141}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711848823,"command":"SUBS","content":[{"key":"SPY","4":6,"5":5,"50":1633711848492}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711849359,"command":"SUBS","content":[{"key":"SPY","4":7,"5":2,"7":"V","11":46249,"50":1633711849077}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711849916,"command":"SUBS","content":[{"key":"SPY","4":6,"5":3,"6":"N","7":"T","50":1633711849631}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711850454,"command":"SUBS","content":[{"key":"SPY","1":438.4,"2":438.41,"3":438.4,"4":4,"5":5,"6":"T","8":33999940,"9":1,"10":46250,"11":46250,"24":0.0032,"29":-0.26,"43":438.4,"44":1,"45":46250,"47":-0.26,"49":438.4,"50":1633711850364,"51":1633711850234,"52":1633711850234}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711850982,"command":"SUBS","content":[{"key":"SPY","4":5,"5":3,"6":"U","7":"U","50":1633711850648}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711851500,"command":"SUBS","content":[{"key":"SPY","1":438.41,"2":438.42,"4":1,"5":6,"6":"T","7":"N","11":46251,"49":438.41,"50":1633711851314}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711852035,"command":"SUBS","content":[{"key":"SPY","3":438.42,"4":2,"7":"K","8":34000290,"9":2,"10":46251,"29":-0.24,"43":438.42,"44":2,"45":46251,"47":-0.24,"49":438.42,"50":1633711851883,"51":1633711851587,"52":1633711851587}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711852585,"command":"SUBS","content":[{"key":"SPY","3":438.415,"4":3,"5":7,"7":"U","8":34000529,"10":46252,"11":46252,"24":0.0032,"29":-0.245,"43":438.415,"45":46252,"47":-0.245,"49":438.415,"50":1633711852344,"51":1633711852088,"52":1633711852088}]}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<73 bytes>)
client - event = data_received(<71 bytes>)
client - event = data_received(<67 bytes>)
client - event = data_received(<68 bytes>)
client - event = data_received(<77 bytes>)
client - event = data_received(<59 bytes>)
client - event = data_received(<23 bytes>)
client - event = data_received(<57 bytes>)
client - event = data_received(<43 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711853096,"command":"SUBS","content":[{"key":"SPY","1":438.44,"2":438.45,"3":438.45,"4":7,"5":3,"6":"Z","7":"T","8":34006027,"9":1,"24":0.0032,"29":-0.21,"43":438.45,"44":1,"47":-0.21,"49":438.45,"50":1633711852807,"51":1633711852847,"52":1633711852847}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711853640,"command":"SUBS","content":[{"key":"SPY","3":438.4402,"4":8,"5":2,"8":34006130,"10":46253,"11":46253,"24":0.0032,"29":-0.2198,"43":438.4402,"45":46253,"47":-0.2198,"49":438.4402,"50":1633711853390,"51":1633711853342,"52":1633711853342}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711854145,"command":"SUBS","content":[{"key":"SPY","3":438.4401,"4":7,"5":1,"6":"T","8":34011001,"9":9,"24":0.0032,"29":-0.2199,"43":438.4401,"44":9,"47":-0.2199,"49":438.4401,"50":1633711853889,"51":1633711853764,"52":1633711853764}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711854667,"command":"SUBS","content":[{"key":"SPY","1":438.45,"2":438.46,"3":438.45,"4":4,"5":7,"8":34012039,"9":2,"10":46254,"11":46254,"24":0.0032,"26":"U","29":-0.21,"43":438.45,"44":2,"45":46254,"47":-0.21,"49":438.45,"50":1633711854329,"51":1633711854350,"52":1633711854350}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711855193,"command":"SUBS","content":[{"key":"SPY","1":438.44,"2":438.45,"3":438.445,"4":11,"5":1,"7":"V","8":34013187,"10":46255,"11":46255,"24":0.0032,"26":"D","29":-0.215,"43":438.445,"45":46255,"47":-0.215,"49":438.445,"50":1633711855016,"51":1633711855134,"52":1633711855134}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711855734,"command":"SUBS","content":[{"key":"SPY","2":438.46,"3":438.4456,"4":10,"5":7,"8":34013300,"9":1,"24":0.0032,"29":-0.2144,"43":438.4456,"44":1,"47":-0.2144,"49":438.4456,"50":1633711855581,"51":1633711855634,"52":1633711855634}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711856263,"command":"SUBS","content":[{"key":"SPY","4":8,"11":46256,"50":1633711856141}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711856773,"command":"SUBS","content":[{"key":"SPY","3":438.45,"4":10,"5":6,"8":34013873,"10":46256,"24":0.0032,"26":"T","29":-0.21,"43":438.45,"45":46256,"47":-0.21,"49":438.45,"50":1633711856562,"51":1633711856536,"52":1633711856536}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711857297,"command":"SUBS","content":[{"key":"SPY","2":438.45,"4":6,"5":1,"6":"N","7":"T","8":34013983,"11":46257,"26":"X","50":1633711857150}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:01,638 sqs_client.py:167 INFO Deleted message: aeafe11a-037f-4ecf-9f48-0eba2358f62a
2021-10-08 11:51:01,695 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:01,752 sqs_client.py:72 INFO Message sent: 96f36a3b-3787-4cb1-a297-600140594a52: {"key": "SPY", "delayed": false, "assetMainType": "EQUITY", "assetSubType": "ETF", "cusip": "78462F103", "BID_PRICE": 438.39, "ASK_PRICE": 438.4, "LAST_PRICE": 438.3902, "BID_SIZE": 6, "ASK_SIZE": 5, "ASK_ID": "P", "BID_ID": "Z", "TOTAL_VOLUME": 33999565, "LAST_SIZE": 16, "TRADE_TIME": 46247, "QUOTE_TIME": 46247, "HIGH_PRICE": 439.89, "LOW_PRICE": 437.78, "BID_TICK": " ", "CLOSE_PRICE": 438.66, "EXCHANGE_ID": "p", "MARGINABLE": true, "SHORTABLE": true, "QUOTE_DAY": 18908, "TRADE_DAY": 18908, "VOLATILITY": 0.0032, "DESCRIPTION": "SPDR S&P 500", "LAST_ID": "D", "DIGITS": 2, "OPEN_PRICE": 439.48, "NET_CHANGE": -0.2698, "HIGH_52_WEEK": 454.05, "LOW_52_WEEK": 322.6, "DIVIDEND_AMOUNT": 5.6618, "DIVIDEND_YIELD": 1.29, "EXCHANGE_NAME": "PACIFIC", "DIVIDEND_DATE": "2021-09-17 00:00:00.000", "IS_REGULAR_MARKET_QUOTE": true, "IS_REGULAR_MARKET_TRADE": true, "REGULAR_MARKET_LAST_PRICE": 438.3902, "REGULAR_MARKET_LAST_SIZE": 16, "REGULAR_MARKET_TRADE_TIME": 46247, "REGULAR_MARKET_TRADE_DAY": 18908, "REGULAR_MARKET_NET_CHANGE": -0.2698, "SECURITY_STATUS": "Normal", "MARK": 438.3902, "QUOTE_TIME_IN_LONG": 1633711847538, "TRADE_TIME_IN_LONG": 1633711847545, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711847545}
2021-10-08 11:51:01,799 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:01,879 sqs_client.py:72 INFO Message sent: 54ef390c-897f-4bcd-b287-6c7048e166e3: {"key": "SPY", "BID_SIZE": 3, "ASK_SIZE": 6, "BID_ID": "T", "QUOTE_TIME": 46248, "QUOTE_TIME_IN_LONG": 1633711848141}
2021-10-08 11:51:01,926 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:01,979 sqs_client.py:72 INFO Message sent: 140848c5-aaa3-4401-92fa-262bfee07304: {"key": "SPY", "BID_SIZE": 6, "ASK_SIZE": 5, "QUOTE_TIME_IN_LONG": 1633711848492}
2021-10-08 11:51:02,026 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,076 sqs_client.py:72 INFO Message sent: 595eaa20-4758-4415-8028-8832baa450db: {"key": "SPY", "BID_SIZE": 7, "ASK_SIZE": 2, "BID_ID": "V", "QUOTE_TIME": 46249, "QUOTE_TIME_IN_LONG": 1633711849077}
2021-10-08 11:51:02,124 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,174 sqs_client.py:72 INFO Message sent: a7f2a475-ddd5-479f-8f6a-83433cc6a1fa: {"key": "SPY", "BID_SIZE": 6, "ASK_SIZE": 3, "ASK_ID": "N", "BID_ID": "T", "QUOTE_TIME_IN_LONG": 1633711849631}
2021-10-08 11:51:02,220 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,271 sqs_client.py:72 INFO Message sent: eece6d30-1801-4ac9-a305-d4156bb741d8: {"key": "SPY", "BID_PRICE": 438.4, "ASK_PRICE": 438.41, "LAST_PRICE": 438.4, "BID_SIZE": 4, "ASK_SIZE": 5, "ASK_ID": "T", "TOTAL_VOLUME": 33999940, "LAST_SIZE": 1, "TRADE_TIME": 46250, "QUOTE_TIME": 46250, "VOLATILITY": 0.0032, "NET_CHANGE": -0.26, "REGULAR_MARKET_LAST_PRICE": 438.4, "REGULAR_MARKET_LAST_SIZE": 1, "REGULAR_MARKET_TRADE_TIME": 46250, "REGULAR_MARKET_NET_CHANGE": -0.26, "MARK": 438.4, "QUOTE_TIME_IN_LONG": 1633711850364, "TRADE_TIME_IN_LONG": 1633711850234, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711850234}
2021-10-08 11:51:02,319 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,372 sqs_client.py:72 INFO Message sent: 9b44ced8-00f9-4db1-bfc9-9f3b7435a2ac: {"key": "SPY", "BID_SIZE": 5, "ASK_SIZE": 3, "ASK_ID": "U", "BID_ID": "U", "QUOTE_TIME_IN_LONG": 1633711850648}
2021-10-08 11:51:02,419 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,470 sqs_client.py:72 INFO Message sent: 1ae26873-cb2e-4f6a-90e7-925432c616a2: {"key": "SPY", "BID_PRICE": 438.41, "ASK_PRICE": 438.42, "BID_SIZE": 1, "ASK_SIZE": 6, "ASK_ID": "T", "BID_ID": "N", "QUOTE_TIME": 46251, "MARK": 438.41, "QUOTE_TIME_IN_LONG": 1633711851314}
2021-10-08 11:51:02,517 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,568 sqs_client.py:72 INFO Message sent: 0561063d-bb2c-4fd1-9850-8ab76dc0ce19: {"key": "SPY", "LAST_PRICE": 438.42, "BID_SIZE": 2, "BID_ID": "K", "TOTAL_VOLUME": 34000290, "LAST_SIZE": 2, "TRADE_TIME": 46251, "NET_CHANGE": -0.24, "REGULAR_MARKET_LAST_PRICE": 438.42, "REGULAR_MARKET_LAST_SIZE": 2, "REGULAR_MARKET_TRADE_TIME": 46251, "REGULAR_MARKET_NET_CHANGE": -0.24, "MARK": 438.42, "QUOTE_TIME_IN_LONG": 1633711851883, "TRADE_TIME_IN_LONG": 1633711851587, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711851587}
2021-10-08 11:51:02,616 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,667 sqs_client.py:72 INFO Message sent: 3fa9061c-b8c1-416a-8a28-d351b9857389: {"key": "SPY", "LAST_PRICE": 438.415, "BID_SIZE": 3, "ASK_SIZE": 7, "BID_ID": "U", "TOTAL_VOLUME": 34000529, "TRADE_TIME": 46252, "QUOTE_TIME": 46252, "VOLATILITY": 0.0032, "NET_CHANGE": -0.245, "REGULAR_MARKET_LAST_PRICE": 438.415, "REGULAR_MARKET_TRADE_TIME": 46252, "REGULAR_MARKET_NET_CHANGE": -0.245, "MARK": 438.415, "QUOTE_TIME_IN_LONG": 1633711852344, "TRADE_TIME_IN_LONG": 1633711852088, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711852088}
client - event = data_received(<55 bytes>)
client - event = data_received(<54 bytes>)
client - event = data_received(<46 bytes>)
client - event = data_received(<60 bytes>)
client - event = data_received(<72 bytes>)
client - event = data_received(<68 bytes>)
client - event = data_received(<31 bytes>)
client - event = data_received(<30 bytes>)
client - event = data_received(<69 bytes>)
client - event = data_received(<81 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711857823,"command":"SUBS","content":[{"key":"SPY","4":10,"6":"K","7":"Z","8":34014184,"10":46257,"24":0.0032,"26":"P","45":46257,"50":1633711857534,"51":1633711857532,"52":1633711857532}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711858327,"command":"SUBS","content":[{"key":"SPY","3":438.445,"6":"N","8":34022384,"10":46258,"11":46258,"24":0.0032,"26":"D","29":-0.215,"43":438.445,"45":46258,"47":-0.215,"49":438.445,"50":1633711858148,"51":1633711858135,"52":1633711858135}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711858872,"command":"SUBS","content":[{"key":"SPY","4":11,"6":"K","8":34022771,"9":3,"24":0.0032,"44":3,"50":1633711858538,"51":1633711858183,"52":1633711858183}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711859401,"command":"SUBS","content":[{"key":"SPY","1":438.45,"2":438.46,"3":438.455,"4":7,"5":4,"6":"V","7":"T","8":34024034,"9":1,"24":0.0032,"29":-0.205,"43":438.455,"44":1,"47":-0.205,"49":438.455,"50":1633711858962,"51":1633711858974,"52":1633711858974}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711859912,"command":"SUBS","content":[{"key":"SPY","3":438.46,"4":2,"5":8,"8":34026466,"10":46259,"11":46259,"24":0.0032,"26":"Z","29":-0.2,"43":438.46,"45":46259,"47":-0.2,"49":438.46,"50":1633711859649,"51":1633711859526,"52":1633711859526}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711860427,"command":"SUBS","content":[{"key":"SPY","1":438.44,"2":438.45,"3":438.45,"4":8,"5":6,"6":"T","7":"V","8":34026796,"9":2,"10":46260,"11":46260,"24":0.0032,"26":"T","29":-0.21,"43":438.45,"44":2,"45":46260,"47":-0.21,"49":438.45,"50":1633711860122,"51":1633711860028,"52":1633711860028}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711860939,"command":"SUBS","content":[{"key":"SPY","4":10,"5":3,"8":34026798,"26":"V","50":1633711860905}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711861441,"command":"SUBS","content":[{"key":"SPY","4":5,"5":4,"7":"Z","11":46261,"50":1633711861401}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711861964,"command":"SUBS","content":[{"key":"SPY","2":438.46,"3":438.46,"4":9,"5":7,"6":"P","7":"K","8":34030337,"9":12,"10":46261,"24":0.0032,"26":"D","29":-0.2,"43":438.46,"44":12,"45":46261,"47":-0.2,"49":438.46,"50":1633711861799,"51":1633711861687,"52":1633711861687}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711862516,"command":"SUBS","content":[{"key":"SPY","3":438.4599,"4":10,"5":8,"6":"T","7":"T","8":34032337,"9":20,"10":46262,"11":46262,"24":0.0032,"29":-0.2001,"43":438.4599,"44":20,"45":46262,"47":-0.2001,"49":438.4599,"50":1633711862387,"51":1633711862166,"52":1633711862166}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:02,717 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,767 sqs_client.py:72 INFO Message sent: 421a2c27-bf0f-49ae-a70a-28fa4ac6596a: {"key": "SPY", "BID_PRICE": 438.44, "ASK_PRICE": 438.45, "LAST_PRICE": 438.45, "BID_SIZE": 7, "ASK_SIZE": 3, "ASK_ID": "Z", "BID_ID": "T", "TOTAL_VOLUME": 34006027, "LAST_SIZE": 1, "VOLATILITY": 0.0032, "NET_CHANGE": -0.21, "REGULAR_MARKET_LAST_PRICE": 438.45, "REGULAR_MARKET_LAST_SIZE": 1, "REGULAR_MARKET_NET_CHANGE": -0.21, "MARK": 438.45, "QUOTE_TIME_IN_LONG": 1633711852807, "TRADE_TIME_IN_LONG": 1633711852847, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711852847}
2021-10-08 11:51:02,816 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:02,962 sqs_client.py:72 INFO Message sent: fe44c015-bc2c-4d0b-8dca-9ce28645b986: {"key": "SPY", "LAST_PRICE": 438.4402, "BID_SIZE": 8, "ASK_SIZE": 2, "TOTAL_VOLUME": 34006130, "TRADE_TIME": 46253, "QUOTE_TIME": 46253, "VOLATILITY": 0.0032, "NET_CHANGE": -0.2198, "REGULAR_MARKET_LAST_PRICE": 438.4402, "REGULAR_MARKET_TRADE_TIME": 46253, "REGULAR_MARKET_NET_CHANGE": -0.2198, "MARK": 438.4402, "QUOTE_TIME_IN_LONG": 1633711853390, "TRADE_TIME_IN_LONG": 1633711853342, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711853342}
2021-10-08 11:51:03,010 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,099 sqs_client.py:72 INFO Message sent: 35bc2ec2-6377-4448-8a0b-a28daa995f8e: {"key": "SPY", "LAST_PRICE": 438.4401, "BID_SIZE": 7, "ASK_SIZE": 1, "ASK_ID": "T", "TOTAL_VOLUME": 34011001, "LAST_SIZE": 9, "VOLATILITY": 0.0032, "NET_CHANGE": -0.2199, "REGULAR_MARKET_LAST_PRICE": 438.4401, "REGULAR_MARKET_LAST_SIZE": 9, "REGULAR_MARKET_NET_CHANGE": -0.2199, "MARK": 438.4401, "QUOTE_TIME_IN_LONG": 1633711853889, "TRADE_TIME_IN_LONG": 1633711853764, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711853764}
2021-10-08 11:51:03,147 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,197 sqs_client.py:72 INFO Message sent: 96d75fe1-7c28-4ae0-b708-7a707c686515: {"key": "SPY", "BID_PRICE": 438.45, "ASK_PRICE": 438.46, "LAST_PRICE": 438.45, "BID_SIZE": 4, "ASK_SIZE": 7, "TOTAL_VOLUME": 34012039, "LAST_SIZE": 2, "TRADE_TIME": 46254, "QUOTE_TIME": 46254, "VOLATILITY": 0.0032, "LAST_ID": "U", "NET_CHANGE": -0.21, "REGULAR_MARKET_LAST_PRICE": 438.45, "REGULAR_MARKET_LAST_SIZE": 2, "REGULAR_MARKET_TRADE_TIME": 46254, "REGULAR_MARKET_NET_CHANGE": -0.21, "MARK": 438.45, "QUOTE_TIME_IN_LONG": 1633711854329, "TRADE_TIME_IN_LONG": 1633711854350, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711854350}
2021-10-08 11:51:03,244 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,294 sqs_client.py:72 INFO Message sent: 761f8425-f0e6-427e-bda1-fb8d76b5a867: {"key": "SPY", "BID_PRICE": 438.44, "ASK_PRICE": 438.45, "LAST_PRICE": 438.445, "BID_SIZE": 11, "ASK_SIZE": 1, "BID_ID": "V", "TOTAL_VOLUME": 34013187, "TRADE_TIME": 46255, "QUOTE_TIME": 46255, "VOLATILITY": 0.0032, "LAST_ID": "D", "NET_CHANGE": -0.215, "REGULAR_MARKET_LAST_PRICE": 438.445, "REGULAR_MARKET_TRADE_TIME": 46255, "REGULAR_MARKET_NET_CHANGE": -0.215, "MARK": 438.445, "QUOTE_TIME_IN_LONG": 1633711855016, "TRADE_TIME_IN_LONG": 1633711855134, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711855134}
2021-10-08 11:51:03,343 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,659 sqs_client.py:72 INFO Message sent: 1e209887-60d7-4cc9-8e14-62dfa16156e1: {"key": "SPY", "ASK_PRICE": 438.46, "LAST_PRICE": 438.4456, "BID_SIZE": 10, "ASK_SIZE": 7, "TOTAL_VOLUME": 34013300, "LAST_SIZE": 1, "VOLATILITY": 0.0032, "NET_CHANGE": -0.2144, "REGULAR_MARKET_LAST_PRICE": 438.4456, "REGULAR_MARKET_LAST_SIZE": 1, "REGULAR_MARKET_NET_CHANGE": -0.2144, "MARK": 438.4456, "QUOTE_TIME_IN_LONG": 1633711855581, "TRADE_TIME_IN_LONG": 1633711855634, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711855634}
2021-10-08 11:51:03,707 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,755 sqs_client.py:72 INFO Message sent: bfeeae4c-172f-4b8e-97ba-3381ff6d5d72: {"key": "SPY", "BID_SIZE": 8, "QUOTE_TIME": 46256, "QUOTE_TIME_IN_LONG": 1633711856141}
2021-10-08 11:51:03,801 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,851 sqs_client.py:72 INFO Message sent: c5930587-d8a3-41bd-8af2-056944446cb1: {"key": "SPY", "LAST_PRICE": 438.45, "BID_SIZE": 10, "ASK_SIZE": 6, "TOTAL_VOLUME": 34013873, "TRADE_TIME": 46256, "VOLATILITY": 0.0032, "LAST_ID": "T", "NET_CHANGE": -0.21, "REGULAR_MARKET_LAST_PRICE": 438.45, "REGULAR_MARKET_TRADE_TIME": 46256, "REGULAR_MARKET_NET_CHANGE": -0.21, "MARK": 438.45, "QUOTE_TIME_IN_LONG": 1633711856562, "TRADE_TIME_IN_LONG": 1633711856536, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711856536}
2021-10-08 11:51:03,896 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:03,946 sqs_client.py:72 INFO Message sent: b5d3b7ef-c98e-48c0-a480-ad529f402cd5: {"key": "SPY", "ASK_PRICE": 438.45, "BID_SIZE": 6, "ASK_SIZE": 1, "ASK_ID": "N", "BID_ID": "T", "TOTAL_VOLUME": 34013983, "QUOTE_TIME": 46257, "LAST_ID": "X", "QUOTE_TIME_IN_LONG": 1633711857150}
client - event = data_received(<52 bytes>)
client - event = data_received(<27 bytes>)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "QUOTE", "requestid": "10", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "SPY", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52"}}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711863033,"command":"SUBS","content":[{"key":"SPY","3":438.46,"4":11,"5":7,"6":"P","8":34040614,"9":27,"24":0.0032,"29":-0.2,"43":438.46,"44":27,"47":-0.2,"49":438.46,"50":1633711862823,"51":1633711862611,"52":1633711862611}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"QUOTE", "timestamp":1633711863548,"command":"SUBS","content":[{"key":"SPY","2":438.45,"4":7,"5":6,"11":46263,"49":438.45,"50":1633711863370}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:03,993 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:04,043 sqs_client.py:72 INFO Message sent: 1ff259eb-2974-42dc-9be0-3a5eb3a5bc49: {"key": "SPY", "BID_SIZE": 10, "ASK_ID": "K", "BID_ID": "Z", "TOTAL_VOLUME": 34014184, "TRADE_TIME": 46257, "VOLATILITY": 0.0032, "LAST_ID": "P", "REGULAR_MARKET_TRADE_TIME": 46257, "QUOTE_TIME_IN_LONG": 1633711857534, "TRADE_TIME_IN_LONG": 1633711857532, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711857532}
client - event = data_received(<22 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"QUOTE","requestid":"10","command":"UNSUBS","timestamp":1633711864039,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:09,142 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,191 sqs_client.py:72 INFO Message sent: 608e4a52-845e-4dde-aafb-c062764b6ee4: {"key": "SPY", "LAST_PRICE": 438.445, "ASK_ID": "N", "TOTAL_VOLUME": 34022384, "TRADE_TIME": 46258, "QUOTE_TIME": 46258, "VOLATILITY": 0.0032, "LAST_ID": "D", "NET_CHANGE": -0.215, "REGULAR_MARKET_LAST_PRICE": 438.445, "REGULAR_MARKET_TRADE_TIME": 46258, "REGULAR_MARKET_NET_CHANGE": -0.215, "MARK": 438.445, "QUOTE_TIME_IN_LONG": 1633711858148, "TRADE_TIME_IN_LONG": 1633711858135, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711858135}
2021-10-08 11:51:09,236 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,344 sqs_client.py:72 INFO Message sent: e707aa32-644c-4f47-b384-9b8e43f33dba: {"key": "SPY", "BID_SIZE": 11, "ASK_ID": "K", "TOTAL_VOLUME": 34022771, "LAST_SIZE": 3, "VOLATILITY": 0.0032, "REGULAR_MARKET_LAST_SIZE": 3, "QUOTE_TIME_IN_LONG": 1633711858538, "TRADE_TIME_IN_LONG": 1633711858183, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711858183}
2021-10-08 11:51:09,391 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,440 sqs_client.py:72 INFO Message sent: a2f01850-49ef-43ae-be29-22115cfb3cb9: {"key": "SPY", "BID_PRICE": 438.45, "ASK_PRICE": 438.46, "LAST_PRICE": 438.455, "BID_SIZE": 7, "ASK_SIZE": 4, "ASK_ID": "V", "BID_ID": "T", "TOTAL_VOLUME": 34024034, "LAST_SIZE": 1, "VOLATILITY": 0.0032, "NET_CHANGE": -0.205, "REGULAR_MARKET_LAST_PRICE": 438.455, "REGULAR_MARKET_LAST_SIZE": 1, "REGULAR_MARKET_NET_CHANGE": -0.205, "MARK": 438.455, "QUOTE_TIME_IN_LONG": 1633711858962, "TRADE_TIME_IN_LONG": 1633711858974, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711858974}
2021-10-08 11:51:09,486 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,573 sqs_client.py:72 INFO Message sent: e8d1a61b-1f88-4526-b55b-2b380936b31f: {"key": "SPY", "LAST_PRICE": 438.46, "BID_SIZE": 2, "ASK_SIZE": 8, "TOTAL_VOLUME": 34026466, "TRADE_TIME": 46259, "QUOTE_TIME": 46259, "VOLATILITY": 0.0032, "LAST_ID": "Z", "NET_CHANGE": -0.2, "REGULAR_MARKET_LAST_PRICE": 438.46, "REGULAR_MARKET_TRADE_TIME": 46259, "REGULAR_MARKET_NET_CHANGE": -0.2, "MARK": 438.46, "QUOTE_TIME_IN_LONG": 1633711859649, "TRADE_TIME_IN_LONG": 1633711859526, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711859526}
2021-10-08 11:51:09,619 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,673 sqs_client.py:72 INFO Message sent: 4c85ec5a-5bf9-4ab8-9b4d-8544ecc57c14: {"key": "SPY", "BID_PRICE": 438.44, "ASK_PRICE": 438.45, "LAST_PRICE": 438.45, "BID_SIZE": 8, "ASK_SIZE": 6, "ASK_ID": "T", "BID_ID": "V", "TOTAL_VOLUME": 34026796, "LAST_SIZE": 2, "TRADE_TIME": 46260, "QUOTE_TIME": 46260, "VOLATILITY": 0.0032, "LAST_ID": "T", "NET_CHANGE": -0.21, "REGULAR_MARKET_LAST_PRICE": 438.45, "REGULAR_MARKET_LAST_SIZE": 2, "REGULAR_MARKET_TRADE_TIME": 46260, "REGULAR_MARKET_NET_CHANGE": -0.21, "MARK": 438.45, "QUOTE_TIME_IN_LONG": 1633711860122, "TRADE_TIME_IN_LONG": 1633711860028, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711860028}
2021-10-08 11:51:09,721 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,770 sqs_client.py:72 INFO Message sent: f951d37c-ee8e-41c5-8dfc-e3b8e309fd5e: {"key": "SPY", "BID_SIZE": 10, "ASK_SIZE": 3, "TOTAL_VOLUME": 34026798, "LAST_ID": "V", "QUOTE_TIME_IN_LONG": 1633711860905}
2021-10-08 11:51:09,918 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:09,967 sqs_client.py:72 INFO Message sent: c460d512-c07c-4cda-92f9-16dcc51d5c3d: {"key": "SPY", "BID_SIZE": 5, "ASK_SIZE": 4, "BID_ID": "Z", "QUOTE_TIME": 46261, "QUOTE_TIME_IN_LONG": 1633711861401}
2021-10-08 11:51:10,013 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:10,069 sqs_client.py:72 INFO Message sent: e2cb5559-f757-4a97-9875-0f598711a77d: {"key": "SPY", "ASK_PRICE": 438.46, "LAST_PRICE": 438.46, "BID_SIZE": 9, "ASK_SIZE": 7, "ASK_ID": "P", "BID_ID": "K", "TOTAL_VOLUME": 34030337, "LAST_SIZE": 12, "TRADE_TIME": 46261, "VOLATILITY": 0.0032, "LAST_ID": "D", "NET_CHANGE": -0.2, "REGULAR_MARKET_LAST_PRICE": 438.46, "REGULAR_MARKET_LAST_SIZE": 12, "REGULAR_MARKET_TRADE_TIME": 46261, "REGULAR_MARKET_NET_CHANGE": -0.2, "MARK": 438.46, "QUOTE_TIME_IN_LONG": 1633711861799, "TRADE_TIME_IN_LONG": 1633711861687, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711861687}
2021-10-08 11:51:10,115 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:10,212 sqs_client.py:72 INFO Message sent: d167b5cf-6884-4474-aeb5-f1f96a2fadfc: {"key": "SPY", "LAST_PRICE": 438.4599, "BID_SIZE": 10, "ASK_SIZE": 8, "ASK_ID": "T", "BID_ID": "T", "TOTAL_VOLUME": 34032337, "LAST_SIZE": 20, "TRADE_TIME": 46262, "QUOTE_TIME": 46262, "VOLATILITY": 0.0032, "NET_CHANGE": -0.2001, "REGULAR_MARKET_LAST_PRICE": 438.4599, "REGULAR_MARKET_LAST_SIZE": 20, "REGULAR_MARKET_TRADE_TIME": 46262, "REGULAR_MARKET_NET_CHANGE": -0.2001, "MARK": 438.4599, "QUOTE_TIME_IN_LONG": 1633711862387, "TRADE_TIME_IN_LONG": 1633711862166, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711862166}
2021-10-08 11:51:10,258 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:10,306 sqs_client.py:72 INFO Message sent: 1ad19a8b-dc28-4954-af6d-28650b71b03c: {"key": "SPY", "LAST_PRICE": 438.46, "BID_SIZE": 11, "ASK_SIZE": 7, "ASK_ID": "P", "TOTAL_VOLUME": 34040614, "LAST_SIZE": 27, "VOLATILITY": 0.0032, "NET_CHANGE": -0.2, "REGULAR_MARKET_LAST_PRICE": 438.46, "REGULAR_MARKET_LAST_SIZE": 27, "REGULAR_MARKET_NET_CHANGE": -0.2, "MARK": 438.46, "QUOTE_TIME_IN_LONG": 1633711862823, "TRADE_TIME_IN_LONG": 1633711862611, "REGULAR_MARKET_TRADE_TIME_IN_LONG": 1633711862611}
2021-10-08 11:51:10,352 sqs_client.py:217 INFO Got queue 'streamer-td-quote' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-quote
2021-10-08 11:51:10,402 sqs_client.py:72 INFO Message sent: 8aea0d2d-c868-4b3b-8fbf-564f2ecf0069: {"key": "SPY", "ASK_PRICE": 438.45, "BID_SIZE": 7, "ASK_SIZE": 6, "QUOTE_TIME": 46263, "MARK": 438.45, "QUOTE_TIME_IN_LONG": 1633711863370}
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'r9\x96\xd1', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client - event = data_received(<15 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'r9\x96\xd1', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 723996d1
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711873656"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711883660"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:35,406 sqs_client.py:167 INFO Deleted message: 5a1fdbfa-8e29-4e94-8729-1d0254b527d9
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711893665"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : SUB THEN UNSUB from option service underlying NET
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "OPTION", "requestid": "11", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "NET_102221C55", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711895500"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<26 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"OPTION","requestid":"11","command":"SUBS","timestamp":1633711895500,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<255 bytes>)
client - event = data_received(<57 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"OPTION", "timestamp":1633711895504,"command":"SUBS","content":[{"key":"NET_102221C55","delayed":false,"assetMainType":"OPTION","cusip":"0NET..JM10055000","1":"NET Oct 22 2021 55 Call (Weekly)","2":81.8,"3":84.5,"7":81.92,"10":256.1811,"11":46251,"12":68400,"13":83.1859,"14":18908,"16":2021,"17":100,"18":2,"20":15,"21":15,"24":55,"25":"C","26":"NET","27":10,"29":-0.0359,"30":22,"31":14,"32":0.979,"33":0.0007,"34":-0.1104,"35":0.0135,"36":0.0207,"37":"Normal","38":83.7067,"39":138.1859,"40":"S","41":83.15}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"OPTION", "timestamp":1633711899095,"command":"SUBS","content":[{"key":"NET_102221C55","10":256.6287,"13":83.25,"29":-0.1,"32":0.9807,"33":0.0007,"34":-0.1263,"35":0.0135,"36":0.0207,"38":84.0066,"39":138.25}]}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<52 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"OPTION", "timestamp":1633711904357,"command":"SUBS","content":[{"key":"NET_102221C55","10":256.5598,"13":83.245,"29":-0.095,"32":0.9804,"33":0.0007,"34":-0.1235,"35":0.0135,"36":0.0207,"38":83.9604,"39":138.245}]}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'c\x040Y', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:50,717 sqs_client.py:217 INFO Got queue 'streamer-td-option' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-option
2021-10-08 11:51:50,771 sqs_client.py:72 INFO Message sent: 943ac157-663a-47a0-8e2a-cf173e7270be: {"key": "NET_102221C55", "delayed": false, "assetMainType": "OPTION", "cusip": "0NET..JM10055000", "DESCRIPTION": "NET Oct 22 2021 55 Call (Weekly)", "BID_PRICE": 81.8, "ASK_PRICE": 84.5, "CLOSE_PRICE": 81.92, "VOLATILITY": 256.1811, "QUOTE_TIME": 46251, "TRADE_TIME": 68400, "MONEY_INTRINSIC_VALUE": 83.1859, "QUOTE_DAY": 18908, "EXPIRATION_YEAR": 2021, "MULTIPLIER": 100, "DIGITS": 2, "BID_SIZE": 15, "ASK_SIZE": 15, "STRIKE_PRICE": 55, "CONTRACT_TYPE": "C", "UNDERLYING": "NET", "EXPIRATION_MONTH": 10, "TIME_VALUE": -0.0359, "EXPIRATION_DAY": 22, "DAYS_TO_EXPIRATION": 14, "DELTA": 0.979, "GAMMA": 0.0007, "THETA": -0.1104, "VEGA": 0.0135, "RHO": 0.0207, "SECURITY_STATUS": "Normal", "THEORETICAL_OPTION_VALUE": 83.7067, "UNDERLYING_PRICE": 138.1859, "UV_EXPIRATION_TYPE": "S", "MARK": 83.15}
2021-10-08 11:51:50,818 sqs_client.py:217 INFO Got queue 'streamer-td-option' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-option
2021-10-08 11:51:50,872 sqs_client.py:72 INFO Message sent: 374eff7d-7acb-493d-b5cf-63e4b242be31: {"key": "NET_102221C55", "VOLATILITY": 256.6287, "MONEY_INTRINSIC_VALUE": 83.25, "TIME_VALUE": -0.1, "DELTA": 0.9807, "GAMMA": 0.0007, "THETA": -0.1263, "VEGA": 0.0135, "RHO": 0.0207, "THEORETICAL_OPTION_VALUE": 84.0066, "UNDERLYING_PRICE": 138.25}
client - event = data_received(<6 bytes>)
client - event = data_received(<22 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'c\x040Y', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 63043059
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"OPTION", "timestamp":1633711909516,"command":"SUBS","content":[{"key":"NET_102221C55","10":256.6287,"32":0.9807,"33":0.0007,"34":-0.1266,"35":0.0135,"36":0.0207,"38":84.0066}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:51:52,251 sqs_client.py:167 INFO Deleted message: 40b813ab-c498-4a1e-9d74-de52afba0173
2021-10-08 11:51:52,347 sqs_client.py:217 INFO Got queue 'streamer-td-option' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-option
2021-10-08 11:51:52,396 sqs_client.py:72 INFO Message sent: 472f09f8-4807-450a-9d7d-8b7fdd885839: {"key": "NET_102221C55", "VOLATILITY": 256.5598, "MONEY_INTRINSIC_VALUE": 83.245, "TIME_VALUE": -0.095, "DELTA": 0.9804, "GAMMA": 0.0007, "THETA": -0.1235, "VEGA": 0.0135, "RHO": 0.0207, "THEORETICAL_OPTION_VALUE": 83.9604, "UNDERLYING_PRICE": 138.245}
2021-10-08 11:51:52,441 sqs_client.py:217 INFO Got queue 'streamer-td-option' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-option
2021-10-08 11:51:52,491 sqs_client.py:72 INFO Message sent: 5e97db5f-b459-4197-b2a8-72ef5b052e2a: {"key": "NET_102221C55", "VOLATILITY": 256.6287, "DELTA": 0.9807, "GAMMA": 0.0007, "THETA": -0.1266, "VEGA": 0.0135, "RHO": 0.0207, "THEORETICAL_OPTION_VALUE": 84.0066}
client - event = data_received(<15 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711919698"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "OPTION", "requestid": "12", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "NET_102221C55", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<19 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"OPTION","requestid":"12","command":"UNSUBS","timestamp":1633711919725,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711929702"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:52:13,466 sqs_client.py:167 INFO Deleted message: 3b4b4c85-b543-499b-969e-64029e3b27fb
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'~>`L', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'~>`L', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 7e3e604c
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711939706"}]}', rsv1=False, rsv2=False, rsv3=False)
CASE : SUB THEN UNSUB from LEVELONE FUTURE symbol ES
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "LEVELONE_FUTURES", "requestid": "13", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<10 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711939733"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<28 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"LEVELONE_FUTURES","requestid":"13","command":"SUBS","timestamp":1633711939733,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<307 bytes>)
client - event = data_received(<32 bytes>)
client - event = data_received(<60 bytes>)
client - event = data_received(<40 bytes>)
client - event = data_received(<49 bytes>)
client - event = data_received(<53 bytes>)
client - event = data_received(<33 bytes>)
client - event = data_received(<46 bytes>)
client - event = data_received(<25 bytes>)
client - event = data_received(<48 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711939753,"command":"SUBS","content":[{"key":"/ES","delayed":false,"assetMainType":"FUTURE","1":4389.25,"2":4389.5,"3":4389.5,"4":102,"5":135,"6":"?","7":"?","8":939501,"9":1,"10":1633711939513,"11":1633711938480,"12":4407.75,"13":4382.25,"14":4390,"15":"E","16":"E-mini S&P 500 Index Futures,Dec-2021,ETH","17":"?","18":4390.5,"19":-0.5,"20":-0.0001,"21":"XCME","22":"Unknown","23":2363795,"24":4389.5,"25":0.25,"26":12.5,"27":"/ES","28":"D,D","29":"GLBX(de=1640;0=-17001600;1=r-17001600d-15551640;7=d-16401555)","30":true,"31":50,"32":true,"33":4390,"34":"/ESZ21","35":1639717200000}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711940296,"command":"SUBS","content":[{"key":"/ES","4":90,"5":136,"10":1633711940086}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711940836,"command":"SUBS","content":[{"key":"/ES","1":4389,"2":4389.25,"3":4389.25,"4":154,"5":62,"8":939591,"9":2,"10":1633711940759,"11":1633711940607,"19":-0.75,"20":-0.0002}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711941413,"command":"SUBS","content":[{"key":"/ES","5":74,"8":939595,"9":4,"10":1633711941166,"11":1633711941088,"24":4389.25}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711941944,"command":"SUBS","content":[{"key":"/ES","3":4389,"4":94,"5":76,"8":939608,"9":1,"10":1633711941723,"11":1633711941721,"19":-1,"20":-0.0002}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711942450,"command":"SUBS","content":[{"key":"/ES","3":4389.25,"4":84,"5":99,"8":939613,"9":5,"10":1633711942154,"11":1633711942092,"19":-0.75,"20":-0.0002,"24":4389}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711942981,"command":"SUBS","content":[{"key":"/ES","3":4389,"4":82,"8":939615,"9":2,"10":1633711942745,"11":1633711942745,"19":-1,"20":-0.0002}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711943484,"command":"SUBS","content":[{"key":"/ES","1":4388.75,"2":4389,"4":125,"5":72,"8":939716,"9":1,"10":1633711943276,"11":1633711943116,"24":4389.25}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711944027,"command":"SUBS","content":[{"key":"/ES","5":85,"10":1633711943763,"24":4389}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711944549,"command":"SUBS","content":[{"key":"/ES","1":4389.25,"2":4389.5,"3":4389.25,"4":115,"5":125,"8":939942,"9":2,"10":1633711944267,"11":1633711944092,"19":-0.75,"20":-0.0002}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:52:27,548 sqs_client.py:167 INFO Deleted message: a186a830-a92b-438f-9447-753e327973e1
client - event = data_received(<39 bytes>)
client - event = data_received(<37 bytes>)
client - event = data_received(<26 bytes>)
client - event = data_received(<26 bytes>)
client - event = data_received(<36 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711945054,"command":"SUBS","content":[{"key":"/ES","4":64,"5":161,"8":939963,"9":1,"10":1633711945031,"11":1633711944688}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711945556,"command":"SUBS","content":[{"key":"/ES","4":105,"5":133,"8":939970,"10":1633711945528,"11":1633711945041,"24":4389.25}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711946062,"command":"SUBS","content":[{"key":"/ES","4":109,"5":120,"10":1633711945844}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711946618,"command":"SUBS","content":[{"key":"/ES","4":102,"5":122,"10":1633711946458}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711947136,"command":"SUBS","content":[{"key":"/ES","4":96,"5":139,"8":939971,"10":1633711946820,"11":1633711946805}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:52:27,607 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:27,659 sqs_client.py:72 INFO Message sent: c44a41a6-3d48-47a7-b6e3-d161e4211383: {"key": "/ES", "delayed": false, "assetMainType": "FUTURE", "BID_PRICE": 4389.25, "ASK_PRICE": 4389.5, "LAST_PRICE": 4389.5, "BID_SIZE": 102, "ASK_SIZE": 135, "ASK_ID": "?", "BID_ID": "?", "TOTAL_VOLUME": 939501, "LAST_SIZE": 1, "QUOTE_TIME": 1633711939513, "TRADE_TIME": 1633711938480, "HIGH_PRICE": 4407.75, "LOW_PRICE": 4382.25, "CLOSE_PRICE": 4390, "EXCHANGE_ID": "E", "DESCRIPTION": "E-mini S&P 500 Index Futures,Dec-2021,ETH", "LAST_ID": "?", "OPEN_PRICE": 4390.5, "NET_CHANGE": -0.5, "FUTURE_PERCENT_CHANGE": -0.0001, "EXCHANGE_NAME": "XCME", "SECURITY_STATUS": "Unknown", "OPEN_INTEREST": 2363795, "MARK": 4389.5, "TICK": 0.25, "TICK_AMOUNT": 12.5, "PRODUCT": "/ES", "FUTURE_PRICE_FORMAT": "D,D", "FUTURE_TRADING_HOURS": "GLBX(de=1640;0=-17001600;1=r-17001600d-15551640;7=d-16401555)", "FUTURE_IS_TRADEABLE": true, "FUTURE_MULTIPLIER": 50, "FUTURE_IS_ACTIVE": true, "FUTURE_SETTLEMENT_PRICE": 4390, "FUTURE_ACTIVE_SYMBOL": "/ESZ21", "FUTURE_EXPIRATION_DATE": 1639717200000}
2021-10-08 11:52:27,705 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:27,758 sqs_client.py:72 INFO Message sent: 63157da6-d5da-4d43-b1cd-6f55b939916a: {"key": "/ES", "BID_SIZE": 90, "ASK_SIZE": 136, "QUOTE_TIME": 1633711940086}
2021-10-08 11:52:27,803 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:27,857 sqs_client.py:72 INFO Message sent: 76998ae1-52c4-4865-ab3c-357bc2c3287b: {"key": "/ES", "BID_PRICE": 4389, "ASK_PRICE": 4389.25, "LAST_PRICE": 4389.25, "BID_SIZE": 154, "ASK_SIZE": 62, "TOTAL_VOLUME": 939591, "LAST_SIZE": 2, "QUOTE_TIME": 1633711940759, "TRADE_TIME": 1633711940607, "NET_CHANGE": -0.75, "FUTURE_PERCENT_CHANGE": -0.0002}
2021-10-08 11:52:27,902 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:27,954 sqs_client.py:72 INFO Message sent: a492b3db-5ec7-4341-acdc-540604f7753c: {"key": "/ES", "ASK_SIZE": 74, "TOTAL_VOLUME": 939595, "LAST_SIZE": 4, "QUOTE_TIME": 1633711941166, "TRADE_TIME": 1633711941088, "MARK": 4389.25}
2021-10-08 11:52:28,000 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,049 sqs_client.py:72 INFO Message sent: 1656427b-3c3e-44d7-ac00-4f4d6fb3ab3b: {"key": "/ES", "LAST_PRICE": 4389, "BID_SIZE": 94, "ASK_SIZE": 76, "TOTAL_VOLUME": 939608, "LAST_SIZE": 1, "QUOTE_TIME": 1633711941723, "TRADE_TIME": 1633711941721, "NET_CHANGE": -1, "FUTURE_PERCENT_CHANGE": -0.0002}
2021-10-08 11:52:28,095 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,181 sqs_client.py:72 INFO Message sent: cdc6279a-b2f7-4a6e-b514-5948a384c0f3: {"key": "/ES", "LAST_PRICE": 4389.25, "BID_SIZE": 84, "ASK_SIZE": 99, "TOTAL_VOLUME": 939613, "LAST_SIZE": 5, "QUOTE_TIME": 1633711942154, "TRADE_TIME": 1633711942092, "NET_CHANGE": -0.75, "FUTURE_PERCENT_CHANGE": -0.0002, "MARK": 4389}
2021-10-08 11:52:28,227 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,310 sqs_client.py:72 INFO Message sent: ea7a1c6f-83de-45e0-ab91-d9252a810dcb: {"key": "/ES", "LAST_PRICE": 4389, "BID_SIZE": 82, "TOTAL_VOLUME": 939615, "LAST_SIZE": 2, "QUOTE_TIME": 1633711942745, "TRADE_TIME": 1633711942745, "NET_CHANGE": -1, "FUTURE_PERCENT_CHANGE": -0.0002}
2021-10-08 11:52:28,357 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,405 sqs_client.py:72 INFO Message sent: b0e9b209-4a6b-44c8-ab8d-a7ca8976b5a0: {"key": "/ES", "BID_PRICE": 4388.75, "ASK_PRICE": 4389, "BID_SIZE": 125, "ASK_SIZE": 72, "TOTAL_VOLUME": 939716, "LAST_SIZE": 1, "QUOTE_TIME": 1633711943276, "TRADE_TIME": 1633711943116, "MARK": 4389.25}
2021-10-08 11:52:28,450 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,498 sqs_client.py:72 INFO Message sent: 50f1345a-7dc1-432e-829d-f83af5f642aa: {"key": "/ES", "ASK_SIZE": 85, "QUOTE_TIME": 1633711943763, "MARK": 4389}
2021-10-08 11:52:28,545 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,594 sqs_client.py:72 INFO Message sent: 84d71d62-6f1e-44a8-96f7-499f47f3ca34: {"key": "/ES", "BID_PRICE": 4389.25, "ASK_PRICE": 4389.5, "LAST_PRICE": 4389.25, "BID_SIZE": 115, "ASK_SIZE": 125, "TOTAL_VOLUME": 939942, "LAST_SIZE": 2, "QUOTE_TIME": 1633711944267, "TRADE_TIME": 1633711944092, "NET_CHANGE": -0.75, "FUTURE_PERCENT_CHANGE": -0.0002}
client - event = data_received(<23 bytes>)
client - event = data_received(<47 bytes>)
client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "LEVELONE_FUTURES", "requestid": "14", "command": "UNSUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES", "fields": "0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35"}}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711947653,"command":"SUBS","content":[{"key":"/ES","4":88,"10":1633711947307}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711948155,"command":"SUBS","content":[{"key":"/ES","3":4389.5,"4":183,"5":89,"8":939993,"9":2,"10":1633711947932,"11":1633711947788,"19":-0.5,"20":-0.0001}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:52:28,640 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:28,690 sqs_client.py:72 INFO Message sent: e768f6d7-abd0-41c4-9505-a813e82c6e11: {"key": "/ES", "BID_SIZE": 64, "ASK_SIZE": 161, "TOTAL_VOLUME": 939963, "LAST_SIZE": 1, "QUOTE_TIME": 1633711945031, "TRADE_TIME": 1633711944688}
client - event = data_received(<28 bytes>)
client - event = data_received(<23 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"LEVELONE_FUTURES", "timestamp":1633711948661,"command":"SUBS","content":[{"key":"/ES","4":172,"5":117,"10":1633711948516}]}]}', rsv1=False, rsv2=False, rsv3=False)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"LEVELONE_FUTURES","requestid":"14","command":"UNSUBS","timestamp":1633711948687,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-08 11:52:34,008 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,058 sqs_client.py:72 INFO Message sent: d9281dc7-6e9b-4b07-afc9-b78b15f0ca82: {"key": "/ES", "BID_SIZE": 105, "ASK_SIZE": 133, "TOTAL_VOLUME": 939970, "QUOTE_TIME": 1633711945528, "TRADE_TIME": 1633711945041, "MARK": 4389.25}
2021-10-08 11:52:34,105 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,154 sqs_client.py:72 INFO Message sent: ff7cf255-691a-4038-91f5-a89564c638c8: {"key": "/ES", "BID_SIZE": 109, "ASK_SIZE": 120, "QUOTE_TIME": 1633711945844}
2021-10-08 11:52:34,200 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,249 sqs_client.py:72 INFO Message sent: bb8f7806-fc36-4689-b43d-cf71438edea9: {"key": "/ES", "BID_SIZE": 102, "ASK_SIZE": 122, "QUOTE_TIME": 1633711946458}
2021-10-08 11:52:34,296 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,346 sqs_client.py:72 INFO Message sent: 4dfc27aa-87ca-4737-bce6-6bab09de4e92: {"key": "/ES", "BID_SIZE": 96, "ASK_SIZE": 139, "TOTAL_VOLUME": 939971, "QUOTE_TIME": 1633711946820, "TRADE_TIME": 1633711946805}
2021-10-08 11:52:34,392 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,442 sqs_client.py:72 INFO Message sent: f4c0511d-d33f-479d-ae52-ec1d92c7ec14: {"key": "/ES", "BID_SIZE": 88, "QUOTE_TIME": 1633711947307}
2021-10-08 11:52:34,490 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,541 sqs_client.py:72 INFO Message sent: 4e45af8b-01c4-475b-bdfc-8bba0af2a12c: {"key": "/ES", "LAST_PRICE": 4389.5, "BID_SIZE": 183, "ASK_SIZE": 89, "TOTAL_VOLUME": 939993, "LAST_SIZE": 2, "QUOTE_TIME": 1633711947932, "TRADE_TIME": 1633711947788, "NET_CHANGE": -0.5, "FUTURE_PERCENT_CHANGE": -0.0001}
2021-10-08 11:52:34,588 sqs_client.py:217 INFO Got queue 'streamer-td-levelone-futures' with URL=https://us-east-2.queue.amazonaws.com/<REDACTED>/streamer-td-levelone-futures
2021-10-08 11:52:34,638 sqs_client.py:72 INFO Message sent: 3e18f841-91c7-4f3c-b913-b5ae23fbe019: {"key": "/ES", "BID_SIZE": 172, "ASK_SIZE": 117, "QUOTE_TIME": 1633711948516}
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'=\xcd\xa4\xa1', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'=\xcd\xa4\xa1', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 3dcda4a1
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711959713"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711969717"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711979734"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\x12R\x16\xe5', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client - event = data_received(<12 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\x12R\x16\xe5', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 125216e5
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711989738"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633711999742"}]}', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<14 bytes>)
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633712009796"}]}', rsv1=False, rsv2=False, rsv3=False)
client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'~\xab\xfd\xc3', rsv1=False, rsv2=False, rsv3=False)
client - event = data_received(<6 bytes>)
client - event = data_received(<13 bytes>)
client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'~\xab\xfd\xc3', rsv1=False, rsv2=False, rsv3=False)
client - received solicited pong: 7eabfdc3
client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633712019801"}]}', rsv1=False, rsv2=False, rsv3=False)
^Cstreamer/app/tdstreamer.py:325: DeprecationWarning: Task.all_tasks() is deprecated, use asyncio.all_tasks() instead
  for task in asyncio.Task.all_tasks():
Case: When no services are subscribed for 20 seconds - verify the last 2 messages from td
2021-10-09 11:29:54,229 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ACCT_ACTIVITY", "requestid": "2", "command": "SUBS", "account": "490723761", "source": "<REDACTED>", "parameters": {"keys": "<REDACTED>", "fields": "0,1,2,3"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:29:54,256 protocol.py:1344 DEBUG client - event = data_received(<9 bytes>)
2021-10-09 11:29:54,256 protocol.py:1344 DEBUG client - event = data_received(<41 bytes>)
2021-10-09 11:29:54,256 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633796994440"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:29:54,256 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ACCT_ACTIVITY","requestid":"2","command":"SUBS","timestamp":1633796994440,"content":{"code":0,"msg":"SUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:29:59,304 protocol.py:1344 DEBUG client - event = data_received(<138 bytes>)
2021-10-09 11:29:59,305 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"data":[{"service":"ACCT_ACTIVITY", "timestamp":1633796994451,"command":"SUBS","content":[{"seq":0,"key":"<REDACTED>","1":"","2":"SUBSCRIBED","3":""}]}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:04,395 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'\xde\xb2\xf9\x8d', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:09,785 protocol.py:1344 DEBUG client - event = data_received(<6 bytes>)
2021-10-09 11:30:09,785 protocol.py:1344 DEBUG client - event = data_received(<15 bytes>)
2021-10-09 11:30:09,785 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'\xde\xb2\xf9\x8d', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:09,786 protocol.py:924 DEBUG client - received solicited pong: deb2f98d
2021-10-09 11:30:09,786 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633797006343"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:16,241 protocol.py:1344 DEBUG client - event = data_received(<12 bytes>)
2021-10-09 11:30:16,241 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633797016345"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:16,242 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ACCT_ACTIVITY", "requestid": "3", "command": "UNSUBS", "account": "490723761", "source": "<REDACTED>", "parameters": {"keys": "<REDACTED>", "fields": "0,1,2,3"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:16,268 protocol.py:1344 DEBUG client - event = data_received(<26 bytes>)
2021-10-09 11:30:16,268 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ACCT_ACTIVITY","requestid":"3","command":"UNSUBS","timestamp":1633797016453,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:26,410 protocol.py:1344 DEBUG client - event = data_received(<14 bytes>)
2021-10-09 11:30:26,411 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633797026376"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:33,264 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'u]\x9c\xfc', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:33,297 protocol.py:1344 DEBUG client - event = data_received(<6 bytes>)
2021-10-09 11:30:33,297 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.PONG: 10>, data=b'u]\x9c\xfc', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:33,297 protocol.py:924 DEBUG client - received solicited pong: 755d9cfc
2021-10-09 11:30:36,210 protocol.py:1344 DEBUG client - event = data_received(<12 bytes>)
2021-10-09 11:30:36,210 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633797036378"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:36,210 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "ACCT_ACTIVITY", "requestid": "4", "command": "UNSUBS", "account": "490723761", "source": "<REDACTED>", "parameters": {"keys": "<REDACTED>", "fields": "0,1,2,3"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:36,237 protocol.py:1344 DEBUG client - event = data_received(<18 bytes>)
2021-10-09 11:30:36,238 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"ACCT_ACTIVITY","requestid":"4","command":"UNSUBS","timestamp":1633797036422,"content":{"code":0,"msg":"UNSUBS command succeeded"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:46,481 protocol.py:1344 DEBUG client - event = data_received(<13 bytes>)
2021-10-09 11:30:46,481 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"heartbeat":"1633797046380"}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:56,576 protocol.py:1344 DEBUG client - event = data_received(<62 bytes>)
2021-10-09 11:30:56,577 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"notify":[{"service":"ADMIN","timestamp":1633797056172,"content":{"code":30,"msg":"Stop streaming due to empty subscription"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:30:56,577 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.PING: 9>, data=b'q\xb1B\x13', rsv1=False, rsv2=False, rsv3=False)
2021-10-09 11:31:01,624 protocol.py:1286 DEBUG client - event = connection_lost(None)
2021-10-09 11:31:01,624 protocol.py:1288 DEBUG client - state = CLOSED
2021-10-09 11:31:01,624 protocol.py:1293 DEBUG client x code = 1006, reason = [no reason]
2021-10-09 11:31:01,625 protocol.py:1252 DEBUG client - aborted pending ping: 71b14213
2021-10-09 11:31:01,625 protocol.py:1189 DEBUG client ! failing CLOSED WebSocket connection with code 1006
2021-10-09 11:31:01,625 protocol.py:1133 DEBUG client x closing TCP connection
2021-10-09 11:31:06,729 tdstreamer.py:326 ERROR code = 1006 (connection closed abnormally [internal]), no reason
Traceback (most recent call last):

await self.client.handle_message()
await self.client.news_headline_unsubs(['GOOG', 'MSFT'])

self.assert_handler_called_once_with(handler, {"service": "NEWS_HEADLINE", "command": "SUBS", "timestamp": 1590186642440, 'content': {}})
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's go ahead and factor this timestamp out into a global constant.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These dicts are ugly, hard to read, and break line lengths. Please format, manually if necessary. Feel free to ignore conventions and such for now.

@@ -578,6 +608,15 @@ engineering and crowdsourced experience. Take them with a grain of salt.
If you have specific questions, please join our `Discord server
<https://discord.gg/nfrd9gh>`__ to discuss with the community.

You can enable the websocket client debug to watch the incoming/outgoing messages on the stream by setting these
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add this in a separate PR.

tda/streaming.py Outdated
@@ -882,6 +927,24 @@ async def level_one_equity_subs(self, symbols, *, fields=None):
symbols, 'QUOTE', 'SUBS', self.LevelOneEquityFields,
fields=fields)

async def level_one_equity_unsubs(self, symbols, *, fields=None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this fields parameter do? Let's verify that it's actually used.

@@ -13,6 +13,7 @@

ACCOUNT_ID = 1000
TOKEN_TIMESTAMP = '2020-05-22T02:12:48+0000'
UNIX_TIMESTAMP = 1590116673258
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexgolec I've extracted all unix timestamp and replaced all hardcoded values with this UNIX_TIMESTAMP cont var

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the factor-out, but the name UNIX_TIMESTAMP says nothing about how this variable is going to be used. How about something like REQUEST_TIMESTAMP?

await self.client.chart_equity_unsubs(['GOOG,MSFT'])

###########################################################################
# Private member _service_op
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alexgolec I've added some service_op tests.

I've refactored _service_op to remove the "fields" parameter for any UNSUBS cmds and any _service_op calls with field_type=None. Although we do not have any sub/add cmds that make requests with field_type=None, it tests the behavior that fields parameter, which is optional, won't get sent if field_type=None

@httran13
Copy link
Contributor Author

httran13 commented Oct 24, 2021

So it looks like subs commands may required the fields parameters. I tried sending a sub chart futures cmd without fields and it failed. Not that we are doing this anywhere in the code, but just wanted to see the behavior

@alexgolec

2021-10-24 17:25:40,515 protocol.py:990 DEBUG client > Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"requests": [{"service": "CHART_FUTURES", "requestid": "2", "command": "SUBS", "account": "<REDACTED>", "source": "<REDACTED>", "parameters": {"keys": "/ES"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-24 17:25:40,544 protocol.py:1344 DEBUG client - event = data_received(<55 bytes>)
2021-10-24 17:25:40,544 protocol.py:977 DEBUG client < Frame(fin=True, opcode=<Opcode.TEXT: 1>, data=b'{"response":[{"service":"CHART_FUTURES","requestid":"2","command":"SUBS","timestamp":1635114340610,"content":{"code":22,"msg":"SUBS command failed"}}]}', rsv1=False, rsv2=False, rsv3=False)
2021-10-24 17:25:40,545 tdstreamer.py:326 ERROR unexpected response code: 22, msg is 'SUBS command failed'
Traceback (most recent call last):
  File "stonks/app/tdstreamer.py", line 323, in main
    await asyncio.gather(consumer.stream(), consumer.read_message())
  File "stonks/app/tdstreamer.py", line 254, in read_message
    jsonmsg["symbols"],
  File "stonks/app/tdstreamer.py", line 235, in _request_to_stream
    await method_dict[cmd](symbols)
  File "/Users/huytran/.pyenv/versions/3.7.9/envs/stonks/lib/python3.7/site-packages/tda/streaming.py", line 677, in chart_futures_subs
    symbols, 'CHART_FUTURES', 'SUBS')
  File "/Users/huytran/.pyenv/versions/3.7.9/envs/stonks/lib/python3.7/site-packages/tda/streaming.py", line 332, in _service_op
    await self._await_response(request_id, service, command)
  File "/Users/huytran/.pyenv/versions/3.7.9/envs/stonks/lib/python3.7/site-packages/tda/streaming.py", line 306, in _await_response
    resp['response'][0]['content']['msg']))
tda.streaming.UnexpectedResponseCode: unexpected response code: 22, msg is 'SUBS command failed'

socket.recv.side_effect = [json.dumps(self.success_response(
1, 'CHART_EQUITY', 'UNSUBS'))]

await self.client.chart_equity_unsubs(['GOOG', 'MSFT'])
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's call _service_op directly in these tests? This way we can be 100% certain that there's nothing method-specific interfering with us.

Copy link
Contributor Author

@httran13 httran13 Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, i removed the first test that used a chart equity, once broken down to use _service_op, it had the same test effect as: test_service_op_no_fields_for_unsubs

# Private member _service_op
#
# Note: https://developer.tdameritrade.com/content/streaming-data#_Toc504640564
# parameters are optional and in the case of UNSUBS commands, fields should not be required
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

80 char lines

tda/streaming.py Outdated
*, fields=None):
if fields is None:
# td fields parameter is optional and does not apply in the context of un-subscribing.
if fields is None and field_type is not None and command != 'UNSUBS':
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the constant checking for UNSUBS here. This method is supposed to just do what it's told, and if it's told to do something bogus, then it's the problem of the calling method's implementation.

tda/streaming.py Outdated
fields = field_type.all_fields()
fields = sorted(self.convert_enum_iterable(fields, field_type))

if command != 'UNSUBS' and field_type is not None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a suggested refactor that's easier to read and (I believe) equivalent. Note I've omitted the UNSUBS check:

parameters = {
            'keys': ','.join(symbols)
}

if field_type is not None:
    if fields is None:
        fields = field_type.all_fields()
    else:
        fields = sorted(self.convert_enum_iterable(fields, field_type))

    parameters['fields'] = ','.join(str(f) for f in fields)

Copy link
Contributor Author

@httran13 httran13 Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Used a much simpler equivalent.

parameters = {
    'keys': ','.join(symbols)
}

if field_type is not None:
    if fields is None:
        fields = field_type.all_fields()

    fields = sorted(self.convert_enum_iterable(fields, field_type))
    parameters['fields'] = ','.join(str(f) for f in fields)

@@ -13,6 +13,7 @@

ACCOUNT_ID = 1000
TOKEN_TIMESTAMP = '2020-05-22T02:12:48+0000'
UNIX_TIMESTAMP = 1590116673258
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the factor-out, but the name UNIX_TIMESTAMP says nothing about how this variable is going to be used. How about something like REQUEST_TIMESTAMP?

@alexgolec
Copy link
Owner

Also note the failing docs generation test.

@@ -114,6 +114,21 @@ subscription methods again seems to clear the old subscription and create a new
one. Note this behavior is not officially documented, so this interpretation may
be incorrect.

----------------------
Copy link
Contributor

@pssolanki111 pssolanki111 Oct 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically just the below change to fix the documentation check fail. @httran13

-------------------------
Un-Subscribing to Streams
-------------------------

Copy link
Owner

@alexgolec alexgolec left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alright, you're good to go. Thanks for putting this together!

@alexgolec alexgolec merged commit 90398b4 into alexgolec:master Oct 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants