Skip to content

Commit

Permalink
refactor: stock_evaluate 요청 및 응답 형식 변경
Browse files Browse the repository at this point in the history
  • Loading branch information
yooooonshine committed Aug 30, 2024
1 parent 540cc13 commit 561aed8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions aiServer/stock/ai_model.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from array import array
from typing import List, Dict, Any
from typing import Any


class Output:
def __init__(self, product_number, name, percentage):
def __init__(self, product_number, name, quantity):
self.product_number = product_number
self.name = name
self.percentage = percentage
self.quantity = quantity

def to_dict(self):
return {
'productNumber': self.product_number,
'name': self.name,
"percentage": self.percentage,
"quantity": self.quantity,
}


# 요청된 주식 목록에 따라 각 주식의 구매 비율을 리턴하는 메서드
def get_stock_order_ratio(stocks) -> list[dict[str, Any]]:
print(stocks)

outputs = []
output = Output("삼성전자", "000000", 0.1)
output = Output("005930", "삼성전자", 1)
outputs.append(output.to_dict())

return outputs
3 changes: 2 additions & 1 deletion aiServer/stock/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def recommended_stock_list(request):
@api_view(['POST'])
def stock_evaluate(request) -> JsonResponse:
stocks = request.data['stocks']
amount = request.data['amount'] # 사용 가능 금액

response = get_stock_order_ratio(stocks)

return JsonResponse({"outputs": response}, safe=True)
return JsonResponse({"stocks": response}, safe=True)

0 comments on commit 561aed8

Please sign in to comment.