FutunnOpen / py-futu-api

富途 OpenAPI Python SDK
Apache License 2.0
1.03k stars 220 forks source link

reusing context objects #182

Open zihaolam opened 1 week ago

zihaolam commented 1 week ago

Hi all,

I am planning to run futuapi in a server that long-living, isit recommended to reuse context objects such as OpenSecTradeContext? or should we create a new object everytime we want to use the apis such as place_order()?

It seems that there are some setup overhead when instantiating the class and it seems that the OpenSecTradeContext will also hog up a port as mentioned in the docs.

byblehua commented 3 days ago

You can reuse context objects. As long as you don't call the trd_context.close() function, you can continue to use it. We also recommend doing this.