Skip to content
This repository was archived by the owner on Oct 5, 2021. It is now read-only.

Commit fe367be

Browse files
committed
starting ui work instead of manual
1 parent 944c66d commit fe367be

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

algocoin/__main__.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import sys
2+
import tornado
3+
import threading
24
from .custom_strategies import CustomStrategy
35
from .lib.strategies.sma_crosses_strategy import SMACrossesStrategy
46
from .trading import TradingEngine
57
# from .lib.parser import parse_command_line_config, parse_config
68
from .lib.parser import parse_command_line_config
9+
from .lib.logging import LOG as log
10+
from .ui.server import ServerApplication
711

812

913
def main(argv: list) -> None:
1014
config = parse_command_line_config(argv)
15+
16+
port = 8889
1117
# config = parse_config(argv)
1218

1319
# Instantiate trading engine
@@ -16,6 +22,7 @@ def main(argv: list) -> None:
1622
# including the strategies, the bank/risk engine, and the
1723
# exchange/backtest engine.
1824
te = TradingEngine(config)
25+
application = ServerApplication(te)
1926

2027
# A sample strategy that impelements the correct interface
2128
ts = CustomStrategy(50)
@@ -32,8 +39,14 @@ def main(argv: list) -> None:
3239
# log.critical("registering %d - %d", i, j)
3340
# te.registerStrategy(ts)
3441

42+
log.critical('Server listening on port: %s', port)
43+
application.listen(port)
44+
t = threading.Thread(target=tornado.ioloop.IOLoop.current().start)
45+
t.daemon = True # So it terminates on exit
46+
3547
# Run the live trading engine
3648
te.run()
3749

50+
3851
if __name__ == '__main__':
3952
main(sys.argv)

algocoin/ui/__init__.py

Whitespace-only changes.

algocoin/ui/server.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import tornado.ioloop
2+
import tornado.web
3+
4+
5+
class ServerHandler(tornado.web.RequestHandler):
6+
'''Server Handler
7+
Extends:
8+
tornado.web.RequestHandler
9+
'''
10+
def get(self):
11+
self.write("Server")
12+
13+
14+
class ServerApplication(tornado.web.Application):
15+
def __init__(self, trading_engine, *args, **kwargs):
16+
super(ServerApplication, self).__init__([
17+
(r"/", ServerHandler),
18+
])

0 commit comments

Comments
 (0)