Skip to content

Commit

Permalink
Merge pull request #183 from AsyncAlgoTrading/tkp/typefix
Browse files Browse the repository at this point in the history
upgrade deps in GitHub workflow
  • Loading branch information
timkpaine committed Jun 28, 2022
2 parents efe593a + 0ed7b96 commit 74106cd
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:

- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools wheel twine numpy pyarrow>=1. cpplint pyEX tqdm
python -m pip install -U cpplint numpy pip pyarrow pyEX setuptools tqdm twine wheel
python -m pip install -e .[dev]
cd js; yarn
Expand Down
46 changes: 23 additions & 23 deletions aat/engine/engine.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,36 +62,36 @@
class TradingEngine(Application):
"""A configureable trading application"""

name = "AAT"
description = "async algorithmic trading engine"
name = "AAT" # type: ignore
description = "async algorithmic trading engine" # type: ignore

# Configureable parameters
verbose = Bool(default_value=True)
api = Bool(default_value=False)
port = Unicode(default_value="8080", help="Port to run on").tag(config=True)
event_loop = Instance(klass=asyncio.events.AbstractEventLoop)
executor = Instance(klass=ThreadPoolExecutor, args=(4,), kwargs={})
verbose = Bool(default_value=True) # type: ignore
api = Bool(default_value=False) # type: ignore
port = Unicode(default_value="8080", help="Port to run on").tag(config=True) # type: ignore
event_loop = Instance(klass=asyncio.events.AbstractEventLoop) # type: ignore
executor = Instance(klass=ThreadPoolExecutor, args=(4,), kwargs={}) # type: ignore

# Core components
trading_type = Instance(klass=TradingType, default_value=TradingType.SIMULATION)
order_manager = Instance(OrderManager, args=(), kwargs={})
risk_manager = Instance(RiskManager, args=(), kwargs={})
portfolio_manager = Instance(PortfolioManager, args=(), kwargs={})
exchanges = List(trait=Instance(klass=Exchange))
event_handlers = List(trait=Instance(EventHandler), default_value=[])
strategies = List(trait=Instance(Strategy), default_value=[])
trading_type = Instance(klass=TradingType, default_value=TradingType.SIMULATION) # type: ignore
order_manager = Instance(OrderManager, args=(), kwargs={}) # type: ignore
risk_manager = Instance(RiskManager, args=(), kwargs={}) # type: ignore
portfolio_manager = Instance(PortfolioManager, args=(), kwargs={}) # type: ignore
exchanges = List(trait=Instance(klass=Exchange)) # type: ignore
event_handlers = List(trait=Instance(EventHandler), default_value=[]) # type: ignore
strategies = List(trait=Instance(Strategy), default_value=[]) # type: ignore

# API application
api_application = Instance(klass=TornadoApplication)
api_handlers = List(default_value=[])
api_application = Instance(klass=TornadoApplication) # type: ignore
api_handlers = List(default_value=[]) # type: ignore

table_manager = Instance(
table_manager = Instance( # type: ignore
klass=PerspectiveManager or object, args=(), kwargs={}
) # failover to object

aliases = {"port": "AAT.port", "trading_type": "AAT.trading_type"}

@validate("trading_type")
@validate("trading_type") # type: ignore
def _validate_trading_type(self, proposal: dict) -> TradingType:
if proposal["value"] not in (
TradingType.LIVE,
Expand All @@ -102,7 +102,7 @@ def _validate_trading_type(self, proposal: dict) -> TradingType:
raise TraitError(f'Invalid trading type: {proposal["value"]}')
return proposal["value"]

@validate("exchanges")
@validate("exchanges") # type: ignore
def _validate_exchanges(self, proposal: dict) -> ListType[Exchange]:
for exch in proposal["value"]:
if not isinstance(exch, Exchange):
Expand Down Expand Up @@ -148,7 +148,7 @@ def __init__(self, **config: dict) -> None:

# setup subscriptions
self._handler_subscriptions: Dict[EventType, List] = {
m: [] for m in EventType.__members__.values()
m: [] for m in EventType.__members__.values() # type: ignore
}

# setup `now` handler for backtest
Expand Down Expand Up @@ -311,10 +311,10 @@ def registerCallback(
Returns:
value (bool): True if registered (new), else False
"""
if (callback, handler) not in self._handler_subscriptions[event_type]:
if (callback, handler) not in self._handler_subscriptions[event_type]: # type: ignore
if not asyncio.iscoroutinefunction(callback):
callback = self._make_async(callback)
self._handler_subscriptions[event_type].append((callback, handler))
self._handler_subscriptions[event_type].append((callback, handler)) # type: ignore
return True
return False

Expand Down Expand Up @@ -449,7 +449,7 @@ async def processEvent(self, event: Event, strategy: Strategy = None) -> None:
# ignore heartbeat
return

for callback, handler in self._handler_subscriptions[event.type]:
for callback, handler in self._handler_subscriptions[event.type]: # type: ignore
# TODO make cleaner? move to somewhere not in critical path?
if strategy is not None and (handler not in (strategy, self.manager)):
continue
Expand Down
4 changes: 2 additions & 2 deletions aat/exchange/synthetic/server.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import asyncio
import os
import websockets # type: ignore
import ujson # type: ignore
import uvloop # type: ignore
from websockets import serve # type: ignore
from aat.exchange.synthetic import SyntheticExchange
from aat.core import Order
from aat.config import TradingType
Expand Down Expand Up @@ -31,7 +31,7 @@ async def handle(websocket, *args, **kwargs): # type: ignore
except asyncio.TimeoutError:
pass

start_server = websockets.serve(handle, "0.0.0.0", port)
start_server = serve(handle, "0.0.0.0", port)
print("listening on %d" % port)
return start_server

Expand Down

0 comments on commit 74106cd

Please sign in to comment.