Skip to content

Commit

Permalink
starting psp websocket code
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Jun 19, 2019
1 parent fcd6d89 commit d2790e1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions aat/order_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def oe_client(self):
'secret': secret,
'password': passphrase,
'enableRateLimit': True,
'rateLimit': 250
})

@lru_cache(None)
Expand Down
13 changes: 9 additions & 4 deletions aat/ui/handlers/exchanges.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import tornado.gen
from .base import HTTPHandler
from tornado.concurrent import run_on_executor
from perspective import PerspectiveHTTPMixin
from .base import HTTPHandler
from aat.enums import ExchangeType_to_string


class ExchangesHandler(PerspectiveHTTPMixin, HTTPHandler):
Expand All @@ -15,9 +16,13 @@ def initialize(self, trading_engine, **psp_kwargs):

@run_on_executor
def get_data(self, **psp_kwargs):
msgs = [{'name': x['exchange'].value,
'instruments': ','.join(y.to_dict(True, True)['underlying'] for y in x['instruments'])}
for x in self.te.query().query_exchanges()]
exchanges = self.te.query().query_exchanges()
msgs = [{'id': j + i*len(exchanges),
'name': ExchangeType_to_string(x['exchange']),
'instrument': y.to_dict(True, True)['underlying']}
for i, x in enumerate(exchanges)
for j, y in enumerate(x['instruments'])
]
super(ExchangesHandler, self).loadData(data=msgs, **psp_kwargs)
return super(ExchangesHandler, self).getData()

Expand Down
2 changes: 1 addition & 1 deletion aat/ui/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self,

super(ServerApplication, self).__init__(
extra_handlers + [
(r"/api/v1/json/accounts", AccountsHandler, {'trading_engine': trading_engine}),
(r"/api/v1/json/accounts", AccountsHandler, {'trading_engine': trading_engine, 'psp_kwargs': {'transfer_as_arrow': True}}),
(r"/api/v1/json/exchanges", ExchangesHandler, {'trading_engine': trading_engine}),
(r"/api/v1/json/instruments", InstrumentsHandler, {'trading_engine': trading_engine}),
(r"/api/v1/json/strategies", StrategiesHandler, {'trading_engine': trading_engine,
Expand Down

0 comments on commit d2790e1

Please sign in to comment.