-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsymproxy.py
More file actions
32 lines (27 loc) · 837 Bytes
/
symproxy.py
File metadata and controls
32 lines (27 loc) · 837 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python
import pyflx
import random
import time
def onLogon(username, password):
print("[onLogon] username:{}, password:{}".format(username, password))
def onSubscribe(symbol):
print("[onSubscribe] symbol:{}".format(symbol))
def onUnsubscribe(symbol):
print("[onUnsubscribe] symbol:{}".format(symbol))
sp = pyflx.Symproxy()
sp.initialize(7600)
sp.onLogon(onLogon)
sp.onSubscribe(onSubscribe)
sp.onUnsubscribe(onUnsubscribe)
while True:
try:
nFd = sp.getFd()
if nFd < 0: break
nReturn = sp.select()
if nReturn < 0: break
sp.checkSocket()
time.sleep(1)
price = round(round(1023 + random.random(),2),2)
sp.publish('XAU/USD', {0:price, 1:price+0.05, 256:1000.123, 257:2000.456, 1032:'USD', 1541:'U'})
except KeyboardInterrupt:
exit(0)