Beispiel #1
0
def seed(dbpath=DBPATH):
    ORM.dbpath = dbpath

    mike_bloom = Account(username='******', balance=10000.00)
    mike_bloom.set_password('password')
    mike_bloom.api_key = '00000'
    mike_bloom.save()

    buy_trade = Trade(accounts_pk=mike_bloom.pk,
                      ticker='tsla',
                      volume=10,
                      price=100.0)
    sell_trade = Trade(accounts_pk=mike_bloom.pk,
                       ticker='tsla',
                       volume=-5,
                       price=200.0)
    buy_trade.save()
    sell_trade.save()

    tsla_position = Position(ticker='tsla',
                             shares=5,
                             accounts_pk=mike_bloom.pk)
    appl_position = Position(ticker='aapl',
                             shares=5,
                             accounts_pk=mike_bloom.pk)

    tsla_position.save()
    appl_position.save()
Beispiel #2
0
def create_account():
    data = request.get_json()
    if data:
        # email, password, balance = views.create_account()
        new_account = Account(None, data['email'], data['password'],
                              data['first_name'], data['last_name'])
        new_account.api_key = generate_key()
        new_account.save()
        return jsonify({'status': 'success', 'api_key': new_account.api_key})
    return jsonify({"error": "invalid data"})