期权新增买卖方向和盈亏算法展示

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-07-26 13:49:54 +08:00
parent c8ed098bfc
commit 8076cbbd51
4 changed files with 108 additions and 8 deletions
+4
View File
@@ -8,6 +8,7 @@ from app.models import OptionTrade, Contract, Product
router = APIRouter(prefix="/options", tags=["options"])
OPTION_TYPES = [("C", "C 看涨"), ("P", "P 看跌")]
OPTION_DIRECTIONS = [("buy", ""), ("sell", "")]
def get_product_contracts(db: Session) -> dict:
@@ -43,6 +44,7 @@ def option_page(request: Request, db: Session = Depends(get_db)):
active_nav="options",
product_contracts=get_product_contracts(db),
option_types=OPTION_TYPES,
option_directions=OPTION_DIRECTIONS,
open_trades=open_trades,
closed_trades=closed_trades,
today=today_str(),
@@ -55,6 +57,7 @@ def open_trade(
request: Request,
contract_code: str = Form(...),
option_type: str = Form(...),
direction: str = Form(...),
strike_price: float = Form(...),
open_date: str = Form(...),
open_price: float = Form(...),
@@ -69,6 +72,7 @@ def open_trade(
product_code=product_code,
contract_code=code,
option_type=option_type,
direction=direction,
strike_price=strike_price,
open_date=date.fromisoformat(open_date),
open_price=open_price,