Skip to content

Commit

Permalink
hook callback back in to risk
Browse files Browse the repository at this point in the history
  • Loading branch information
timkpaine committed Jul 2, 2019
1 parent 8fa062f commit bb87a0c
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions aat/callback.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def onExit(self):

def onAnalyze(self, engine):
'''onAnalyze'''
if not engine:
return

import pandas
import numpy as np
import matplotlib
Expand Down
1 change: 1 addition & 0 deletions aat/exchanges/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,5 +88,6 @@ async def get_data_sub_pair(ws, sub=None):
self.callback(res.type, res)
else:
event = json.loads(val[0].data)
print(event)
if event.get('type', 'subscription_ack') in ('subscription_ack', 'heartbeat'):
continue
3 changes: 1 addition & 2 deletions aat/order_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ def sell(self, req: TradeRequest) -> TradeResponse:
return resp

def cancel(self, resp: TradeResponse):
params = tradereq_to_ccxt_order(resp)
self.oe_client().cancel_order(**params)
self.oe_client().cancel_order(resp.order_id)

def cancelAll(self, order_ids: List[str] = None):
if order_ids:
Expand Down
3 changes: 3 additions & 0 deletions aat/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def __init__(self,
self._trade_resps_by_instrument = {}

self._strats = []
self._risk = risk
self._execution = execution

def registerStrategy(self, strat: TradingStrategy):
self._strats.append(strat) # add to tickables
Expand Down Expand Up @@ -134,6 +136,7 @@ def onTrade(self, data: MarketData) -> None:
resp.remaining = data.remaining
for strat in self._strats:
strat.onFill(resp)
self._risk.update(resp)

if data.order_id in self._pending.keys() and data.remaining <= 0:
del self._pending[data.order_id]
Expand Down
4 changes: 2 additions & 2 deletions aat/risk.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ def requestSell(self, req: TradeRequest):
'''precheck for risk compliance'''
return self.request(req)

def update(self, data: TradeResponse):
def update(self, resp: TradeResponse):
'''update risk after execution'''
pass
log.critical('NOT IMPLEMENTED')

0 comments on commit bb87a0c

Please sign in to comment.