Package: pyflx
PyFLXProvides Python market data API access to FlexTrade SYM. PyFLX has two market data Python classes -Symlistener(client) for consuming market data from FlexTrade market data server andSymproxy(publisher or feeder) for publising custom tick data to FlexTrade market data server.InstallationInstall fromPyPIusingpip:pip install pyflxExampleimportpyflximporttimedefonData(symbol,data={}):print("[onData] symbol:{}, data:{}".format(symbol,data))sl=pyflx.Symlistener()sl.onData(onData)whileTrue:try:ifsl.connect('192.168.1.123',7600):sl.subscribe('XAU/USD')sl.loop()time.sleep(5)exceptKeyboardInterrupt:exit(0)exceptExceptionase:print(e)Seesymlistener.pyandsymproxy.pyfor example codes.APISymlistener Classpyflx.Symlistener()Create an instance of Symlistener client.>> sl = pyflx.Symlistener()Symlistener.connect(ip_address,port)ip_address: strport: int➥return: boolConnect to a SYM server on a specified port number. Returntrueif successful orfalseif not able to connect to the server.>> sl.connect('192.168.1.123', 7600)Symlistener.subscribe(symbol)symbol: strSubscribe to market data of the symbol.>> sl.subscribe('XAU/USD')Symlistener.subscribeAll()Subscribe to market data of all symbols.>> sl.subscribeAll()Symlistener.unsubscribe(symbol)symbol: strUnsubscribe to market data of the symbol.>> sl.unsubscribe('XAU/USD')Symlistener.subscribeAll()Unsubscribe to market data of all symbols.>> sl.unsubscribeAll()Symlistener.loop()Enter an event loop and listens for callbacks .>> sl.loop()Symlistener.onData(symbol,data)symbol: strdata: dictA callbackonData, if assigned, is called upon receiving messages from SYM server.>> def onData(symbol, data):
>>     print("[onData] symbol:{}, data:{}".format(symbol, data))
>>
>> sl = pyflx.Symlistener()
>> sl.onData(onData)Symproxy Classpyflx.Symproxy()Create an instance of Symproxy server.>> sp = pyflx.Symproxy()Symproxy.initialize(port)port: intListens to an incoming connection request on a port.>> sp.initialize(7600)Symproxy.getFd()➥return: intReturns either client or a binding socket.>> sp.getFd()Symproxy.select()➥return: intLooks for events on a socket.>> sp.select()Symproxy.checkSocket()Process checks requests and callbacks will be triggered.>> sp.checkSocket()Symproxy.publish(symbol,data)symbol: strdata: dictPublishes market data tick update to a SYM server. SeeData Format.>> sp.publish('XAU/USD', {0:1420, 1:1421.5, 512:1000, 513:2000, 1032:'USD', 1541:'U'})Symproxy.onLogon(username,password)username: strpassword: strA callbackonLogon, if assigned, is called upon receiving a logon message from a client.>> def onLogon(username, password):
>>     print("[onLogon] username:{}, password:{}".format(username, password))
>>
>> sp = pyflx.Symproxy()
>> sp.initialize(7600)
>> sp.onLogon(onLogon)
>> sp.onSubscribe(onSubscribe)
>> sp.onUnsubscribe(onUnsubscribe)Symproxy.onSubscribe(symbol)symbol: strA callbackonSubscribe, if assigned, is called upon receiving a symbol subscription message from a client.Symproxy.onUnsubscribe(symbol)symbol: strA callbackonUnsubscribe, if assigned, is called upon receiving a symbol unsubscription message from a client.Data FormatTagTypeDescription0floatBid1floatAsk2floatVWAP3floatLast traded price8floatToday's high9floatToday's low10floatToday's open11floatPrevious day's close17floatToday's close18floatVolume512intBid size513intAsk size514intTrade size518intUpdate time519intLast trade time1024strSymbol1032strTraded currency1541strBid tick directionU- upD- down1545strAsk tick directionU- upD- downSupportReport an issue inissue trackerChangelog1.3.06 April 2020New: Closes clien connection and rebinds to binding port withSymproxy.closeClient()1.2.07 August 2019Support for Python 2.7Symlistener classSymproxy class