Example #1
0
def position_op(type_):
    try:
        user = current_user._id
        operated_at = datetime.strptime(request.form.get('operated_at'),
                                        '%Y%m%d')
        exchange = request.form.get('exchange')
        symbol = request.form.get('symbol')
        price = float(request.form.get('price'))
        quantity = int(request.form.get('quantity'))
        t = Transaction({
            'user': user,
            'type_': type_,
            'operated_at': operated_at,
            'exchange': exchange,
            'symbol': symbol,
            'price': price,
            'quantity': quantity,
        })
        t.save()
        if not Position.do_op(t):
            t.remove()
        return jsonify(status=200)
    except Exception as e:
        log.exception('')
        return jsonify(status=500, reason=str(e))
Example #2
0
File: trader.py Project: sopnic/ybk
 def add_transaction(type_, exchange, symbol, price, quantity):
     t = Transaction({
         'user': user._id,
         'type_': type_,
         'operated_at': operated_at,
         'exchange': exchange,
         'symbol': symbol,
         'price': price,
         'quantity': quantity,
     })
     t.save()
     if not Position.do_op(t):
         t.remove()
Example #3
0
 def add_transaction(type_, exchange, symbol, price, quantity):
     t = Transaction({
         'user': user._id,
         'type_': type_,
         'operated_at': operated_at,
         'exchange': exchange,
         'symbol': symbol,
         'price': price,
         'quantity': quantity,
     })
     t.save()
     if not Position.do_op(t):
         t.remove()