From c243d82d5b6a2098992cec3f7dd7ca7d6f9b5863 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Sat, 11 Mar 2017 09:36:23 +0700 Subject: [PATCH] Tradesink: trade parsing fix --- tradesink.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tradesink.py b/tradesink.py index 5564875..f7ac029 100644 --- a/tradesink.py +++ b/tradesink.py @@ -17,9 +17,14 @@ def store_trade(j): quantity = -quantity elif j['operation'] != 'buy': raise Exception('Invalid operation: ' + j['operation']) + + try: + comment = j['order-comment'] + except KeyError: + comment = "" ts = parse_timestamp(j['execution-time']) trade = Trade(account=j['account'], security=j['security'], price=float(j['price']), quantity=quantity, volume=float(j['volume']), volumeCurrency=j['volume-currency'], strategyId=j['strategy'], - signalId=j['signal-id'], comment=j['order-comment'], timestamp=ts) + signalId=j['signal-id'], comment=comment, timestamp=ts) trade.save()