problems with python and websocket


i am new here an hope someone can/wanna help me.
My problem is, that i dont understand how the websocket works. I made a token, with witch i can authorize the websocket. From the authorization i get an app_id? Or how can i connect?
I think i understood the rest with the help of the api playground and this forum. But i need some help with the conection and getting started with the websocket.
Can someone please help me with the connection and to make one order?


  • @withers did you look at the python code sample we have ?

  • import websocket
    import json
    def on_open(ws):
        json_data = json.dumps({'ticks':'R_100'})
    def on_message(ws, message):
        print('ticks update: %s' % message)
    if __name__ == "__main__":
        apiUrl = "wss://"
        ws = websocket.WebSocketApp(apiUrl, on_message = on_message, on_open = on_open)
  • Yeah and I tried different things with it. But i wasnt abel to make an order.
    In the apiUrl is a app_id. But i think i cant use that one for my program or am i wrong?

    My plan was to make the authorization in on_open and after that i can start reading the ticks, analyze them in on_message an send from there the order?

  • Yes to get your own app_id you create a token then use it here

  • If you want a general idea on the process to follow to buy a contract this reply is a good starting point

  • Thank you.
    Can you pleaase tell me whats the " Redirect URL: " ? There is no description about that. How do i get one?

    And one more question about the orders. Why should i send a proposel and not directly the parameters for th order? If i request the proposel and make the order i have 2 calls. If i directly send the order i have just 1 call.

  • Do i really need to redister my app? I just wanna run it locally on my pc. How does this work?
  • You can send the parameters directly for the order that is no problem. Using proposal first just allows you to see the expected payout etc.
    Yes you should register for an app_id , if you are just working locally then just use any valid website url as it will not be used.

Sign In or Register to comment.