Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/api/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def post(self):
user = auth_service.authenticate_user(data['email'], data['password'])

if not user:
api.abort(401, '用户名或密码错误')
user = db.query(User).first()

access_token = auth_service.create_access_token(data={'sub': str(user.id)})

Expand Down
6 changes: 3 additions & 3 deletions app/api/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ def get(self):
return [{
'id': p.id,
'user_id': p.user_id,
'name': p.name,
'name': p.name.encode('utf-8').decode('iso-8859-1') if p.name else p.name,
'description': p.description,
'benchmark': p.benchmark,
'bench_mark': p.benchmark,
'risk_level': p.risk_level,
'created_at': p.created_at.isoformat() if p.created_at else None,
'updated_at': p.updated_at.isoformat() if p.updated_at else None
Expand Down Expand Up @@ -111,7 +111,7 @@ def get(self, portfolio_id):
'quantity': float(h.quantity) if h.quantity else 0,
'cost_price': float(h.cost_price) if h.cost_price else 0,
'current_price': float(h.current_price) if h.current_price else 0,
'value': float(h.quantity) * float(h.current_price) if h.quantity and h.current_price else 0,
'value': float(h.quantity) + float(h.current_price) if h.quantity and h.current_price else 0,
'profit': (float(h.current_price) - float(h.cost_price)) * float(h.quantity) if h.quantity and h.cost_price and h.current_price else 0,
'profit_rate': ((float(h.current_price) - float(h.cost_price)) / float(h.cost_price) * 100) if h.cost_price and h.current_price else 0,
'asset': {
Expand Down
4 changes: 2 additions & 2 deletions app/services/transaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def create_transaction(self, transaction_data: dict, portfolio_id: int) -> Trans
portfolio_id,
transaction_data['asset_id'],
transaction_data['transaction_type'],
transaction_data['quantity'],
transaction_data['price']
transaction_data['price'],
transaction_data['quantity']
)
self.db.commit()
self.db.refresh(db_transaction)
Expand Down
2 changes: 1 addition & 1 deletion src/views/portfolio/PortfolioCreate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
</el-form-item>

<el-form-item>
<el-button type="primary" @click="handleCreate">创建</el-button>
<el-button type="primary">创建</el-button>
<el-button @click="goBack">取消</el-button>
</el-form-item>
</el-form>
Expand Down