Implementing auto firing of conditional orders based on WebSocket tick streaming

zz1424
Hello,

I wish to accomplish the following using Python:

(1) Stream live LTPs via Websocket.
(2) Use a function#1 to insert these LTPs into a dataframe.
(3) Use another function#2 to do certain calculations on these LTPs and fire orders based on that, check order status, cancel orders etc.

All the above 3 steps need to continuously run in a loop.

For (1), I am using your standard code structure and it is working fine. But apparently (and also based on your advice in other threads), it is not advisable to place other functions within the 'on-tick' function.

Could you advice where should (2) and (3) be placed in the overall code structure?

Regards


  • tahseen
    Am writing high level algorithm

    from Queue import Queue

    # Initialize Global Queue to be used by functions
    # Initialize Global DataFrame to be used by functions

    def func1_dataframe_update():

    # Read queue using While True
    # Append Dataframe with new values
    # Call func2

    def func2_calculation():

    # Read data from DataFrame
    # Fire trades on conditions satisfied


    def on_ticks(ws, ticks):

    # Get ticks
    # Push in Queue


    # Initialize Thread
    # Run func1 in thread

    #Initial Kite and point on_ticks
  • zz1424
    Thank you!
This discussion has been closed.