Accessing multiple brokers in a single session
Created at 25 Jan 2023, 22:02
GR
Accessing multiple brokers in a single session
25 Jan 2023, 22:02
I would like to know if it is possible to access multiple brokers in a single python session using the twisted libraries provided by cTrader. The idea is to get 'tick volumes' from different brokers and aggregate them to build a reasonable volume profile.
If I set up two clients only the latest one receives messages - I suspect it is because both are configured to listen to the same port. I think should be able to work as two different servers communicate via the same port. Any guidance will be appreciated.
with open("ICMarketsDemoPriceConfig.json") as configFile: config = json.load(configFile) client1 = Client(config["Host"], config["Port"], ssl = config["SSL"]) # Setting client callbacks client1.setConnectedCallback(connected1) client1.setDisconnectedCallback(disconnected1) client1.setMessageReceivedCallback(onMessageReceived1) # Starting the client service client1.startService() #twp.writePriceDataDump() # you can use two separate config files for QUOTE and TRADE with open("skillingDemoPriceConfig.json") as configFile: config = json.load(configFile) client = Client(config["Host"], config["Port"], ssl = config["SSL"]) # Setting client callbacks client.setConnectedCallback(connected) client.setDisconnectedCallback(disconnected) client.setMessageReceivedCallback(onMessageReceived) # Starting the client service client.startService()
ctid1980098
30 Jan 2023, 10:56 ( Updated at: 21 Dec 2023, 09:23 )
RE:
Hi,
I was also looking for a solution to this for a client and struggled to achieve this solution with the twisted libraries. Eventually I gave up and decided to write the application from scratch using a synchronous setup finally was able to aggregate brokers tick volume using my own custom methods instead of twisted. Something like below is what i delivered to a client. Also curious to see how this could be done with twisted though. Personally i found working with the twisted libraries difficult and caused many issues that I was unable to solve. Maybe because i'm still a novice coder. :)
@ctid1980098