update
This commit is contained in:
parent
ac32800ba7
commit
7cc42ee6a1
7 changed files with 82 additions and 82 deletions
|
|
@ -21,14 +21,14 @@ def get_user_api(user_id: str):
|
|||
|
||||
@router.get("/orders", tags=["Order"])
|
||||
def get_orders(
|
||||
userId: str = Query(..., description="ID của user để lấy API key/secret"),
|
||||
symbol: str = Query(..., description="Mã giao dịch, ví dụ: BTCUSDT"),
|
||||
category: str = Query("linear", description="Loại lệnh: linear (future) hoặc spot")
|
||||
userId: str = Query(..., description="User ID to get API key/secret"),
|
||||
symbol: str = Query(..., description="Trading symbol, e.g. BTCUSDT"),
|
||||
category: str = Query("linear", description="Order type: linear (future) or spot")
|
||||
):
|
||||
api_key, api_secret = get_user_api(userId)
|
||||
client = get_bybit_client(api_key, api_secret)
|
||||
res = client.get_open_orders(
|
||||
category=category, # "linear" cho future, "spot" cho spot
|
||||
category=category, # "linear" for future, "spot" for spot
|
||||
symbol=symbol
|
||||
)
|
||||
return res
|
||||
|
|
@ -36,13 +36,13 @@ def get_orders(
|
|||
# Submit order
|
||||
@router.post("/orders", tags=["Order"])
|
||||
def submit_order(
|
||||
userId: str = Body(..., embed=True, description="ID của user để lấy API key/secret"),
|
||||
symbol: str = Body(..., embed=True, description="Mã giao dịch, ví dụ: BTCUSDT"),
|
||||
side: str = Body(..., embed=True, description="side: Buy hoặc Sell"),
|
||||
orderType: str = Body(..., embed=True, description="Loại lệnh: Market hoặc Limit"),
|
||||
qty: float = Body(..., embed=True, description="Số lượng"),
|
||||
category: str = Body("linear", embed=True, description="Loại lệnh: linear (future) hoặc spot"),
|
||||
price: Optional[float] = Body(None, embed=True, description="Giá (bắt buộc với Limit)")
|
||||
userId: str = Body(..., embed=True, description="User ID to get API key/secret"),
|
||||
symbol: str = Body(..., embed=True, description="Trading symbol, e.g. BTCUSDT"),
|
||||
side: str = Body(..., embed=True, description="Order side: Buy or Sell"),
|
||||
orderType: str = Body(..., embed=True, description="Order type: Market or Limit"),
|
||||
qty: float = Body(..., embed=True, description="Order quantity"),
|
||||
category: str = Body("linear", embed=True, description="Order type: linear (future) or spot"),
|
||||
price: Optional[float] = Body(None, embed=True, description="Order price (required for Limit)")
|
||||
):
|
||||
api_key, api_secret = get_user_api(userId)
|
||||
client = get_bybit_client(api_key, api_secret)
|
||||
|
|
@ -55,7 +55,7 @@ def submit_order(
|
|||
}
|
||||
if orderType.lower() == "limit":
|
||||
if price is None:
|
||||
raise HTTPException(status_code=400, detail="Thiếu giá cho lệnh Limit")
|
||||
raise HTTPException(status_code=400, detail="Missing price for Limit order")
|
||||
params["price"] = price
|
||||
res = client.place_order(**params)
|
||||
return res
|
||||
|
|
@ -64,9 +64,9 @@ def submit_order(
|
|||
@router.delete("/orders/{order_id}", tags=["Order"])
|
||||
def cancel_order(
|
||||
order_id: str,
|
||||
userId: str = Query(..., description="ID của user để lấy API key/secret"),
|
||||
symbol: str = Query(..., description="Mã giao dịch, ví dụ: BTCUSDT"),
|
||||
category: str = Query("linear", description="Loại lệnh: linear (future) hoặc spot")
|
||||
userId: str = Query(..., description="User ID to get API key/secret"),
|
||||
symbol: str = Query(..., description="Trading symbol, e.g. BTCUSDT"),
|
||||
category: str = Query("linear", description="Order type: linear (future) or spot")
|
||||
):
|
||||
api_key, api_secret = get_user_api(userId)
|
||||
client = get_bybit_client(api_key, api_secret)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue