tedchou12 / webull

Unofficial APIs for Webull.
MIT License
597 stars 183 forks source link

[Question] Crypto orders / Streaming API #252

Closed meltdown03 closed 3 years ago

meltdown03 commented 3 years ago

Does the on_order_message for the StreamConn provide real-time order info? Like if I send an order, will the streamer show the details as soon as I send it, or only after it fills, or not at all (Not sure if that's its purpose)? Also, do crypto orders show up with with the streamer running? I tried but got nothing when I had conn.run_blocking_loop() running.

tedchou12 commented 3 years ago

Sorry for the delayed response.

This is quite a rudimentary question if I did interpret your question correctly.

Yes, I believe the on_order_message does provide you the correct details of the realtime market. However, you will need to think about the tens of thousands, if not millions of traders on the other side of the market.

Think of dropping a stone in a pond, and you will probably recall ripples that comes immediately after the stone comes in contact with the water. And now think about dropping a stone in a sea, can you see what ripple or wave is caused by the action attributed to you?

The on_order_message is only trying to get the most recent bid and ask orders that are closest to the mid-price; however, the ability of getting the information is not only limited to how fast you can access the information (which is often not very quickly) as well as how good your machines are (which is not the case if you are trading by yourself).

If you want to access the actual result of your orders, you shouldn't using streamconn, but use the get_history_orders or something else instead.

The on_order_message is somewhat a good idea of the price action of the current stock; but I wouldn't be basing my trading decision off of it.

As for the conn.run_blocking_loop(), sorry, I didn't write the conn part of the code, but I am assuming that the run_blocking_loop()'s general idea is to loop over the function to get the price action intermittently until the user intervenes.

meltdown03 commented 3 years ago

Ok thank you. I was looking for my specific orders and fills, but in real-time so I can process them with another library.

meltdown03 commented 3 years ago

Are you sure on_order_message isn't what I am looking for? https://github.com/tedchou12/webull/blob/e63c267803b07d2b118dd7cc25b2ae4631833e7c/webull/streamconn.py#L64-L65 It shows that the information recieved has the orderId, orderStatus and filled quantity etc. I still don't get any of this when I set the debug_flg=True and/or use a order_func that prints the info

tedchou12 commented 3 years ago

on_order_message Sorry, you are right. If it returns orderID and the order details, it might be what you are looking for.

Go ahead and try it!

(sorry, I didn't add the streamconn module and I only checked it for 1-2 times, I am not very familiar with this part of the code.)

meltdown03 commented 3 years ago

on_order_message Sorry, you are right. If it returns orderID and the order details, it might be what you are looking for.

Go ahead and try it!

(sorry, I didn't add the streamconn module and I only checked it for 1-2 times, I am not very familiar with this part of the code.)

Yeah, It doesn't work. I tried watching the websockets data on the Webull webapp (using Chrome developer tools) and nothing is received there either when an order is placed. It may be because the market is closed though. The streaming MQTT endpoints I see in the chrome developer tools are wspush.webullfintech.com/mqtt and platpush.webullfintech.com/mqtt also. The StreamConn is set to use *.webullbroker.com, changing them didn't help, it must just be an alternative.

meltdown03 commented 3 years ago

I found out that is working only when I use my live (Real money) account. I get the fills and cancelled orders on stocks and crypto. Even if I use the paper_webull class, the streamer shows activity from the live account only.