Skip to main content

Data Streaming


Callback Content Examples

Callback content examples can be found at Websocket Notification Examples; The reference to content objects is available at SDK Reference

Subscribe Order Callback

# A callback to receive order data
def on_order(code, content):
print("==Order==")
print(code)
print(content)
# print(content.seq_no) # Print the order serial number

sdk.set_on_order(on_order)
info

For content object detail, please refer to OrderResult Object

Subscribe Amend / Cancel Callback


def on_order_changed(code, content):
print("=Modified==")
print(code)
print(content)
# print(content.seq_no) # Print the order serial number
print("========")


sdk.set_on_order_changed(on_order_changed)
info

For content object detail, please refer to OrderResult Object

Subscribe Filled Callback

def on_filled(code, content):
print("==Filled==")
print(code)
print(content)
# print(content.filled_no) # Print the filled serial number
print("========")

sdk.set_on_filled(on_filled)
info

For content object detail, please refer to FilledData Object

Subscribe Events Callback

def on_event(code, content):
print("===event=====")
print(code)
print(content)
print("========")

sdk.set_on_event(on_event)

Events Include Returns in the Following:

CodeMeaning
100Connect
200Log in
201Login Warning ( Password change alert)
300Disconnect
301Pong Missing
302Manual disconnect
500Error

Example

Users can subscribe to different callbacks to receive order and filled notifications

# A callback to receive order data
def on_order(code, content):
print("==Order==")
print(code)
print(content)
print("========")


sdk.set_on_order(on_order)

# A callback to receive Modified data
def on_order_changed(code, content):
print("=Modified==")
print(code)
print(content)
print("========")


sdk.set_on_order_changed(on_order_changed)

def on_filled(code, content):
print("==Filled==")
print(code)
print(content)
print("========")

sdk.set_on_filled(on_filled)

# A callback to receive Event data
def on_event(code, content):
print("===event=====")
print(code)
print(content)
print("========")

sdk.set_on_event(on_event)