Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Jun 2, 2019
1 parent f54ecd0 commit 7b5e898
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,5 @@ logo.ai
logo.png
coverage
experiments
aat_test
aat_test
docs/api
7 changes: 4 additions & 3 deletions aat/query.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import operator
from concurrent.futures import ThreadPoolExecutor
from functools import reduce
from typing import List
from typing import List, Dict
from .enums import TickType, Side, ExchangeType, CurrencyType, PairType # noqa: F401
from .exceptions import QueryException
from .structs import Instrument, MarketData, TradeRequest, TradeResponse
Expand Down Expand Up @@ -35,8 +35,9 @@ def query_instruments(self, exchange=None) -> List[PairType]:
else:
return reduce(operator.concat, self._instruments.values())

def query_exchanges(self) -> List[ExchangeType]:
return self._exchanges
def query_exchanges(self) -> List[Dict]:
return [{'exchange': name, 'instruments': self.query_instruments(name)}
for name, ex in self._exchanges.items()]

def _paginate(self, instrument: Instrument, lst: list, lst_sub: list, page: int = 1) -> list:
if page is not None:
Expand Down
4 changes: 3 additions & 1 deletion aat/ui/handlers/exchanges.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ def initialize(self, trading_engine, **psp_kwargs):

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

Expand Down

0 comments on commit 7b5e898

Please sign in to comment.