update refactor
This commit is contained in:
parent
01abc7e446
commit
55ad0607f3
39 changed files with 4304 additions and 584 deletions
21
src/handlers/orderHandler.ts
Normal file
21
src/handlers/orderHandler.ts
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Request, Response } from 'express';
|
||||
import { BybitService } from '../services/bybitService';
|
||||
|
||||
const bybitService = new BybitService(process.env.BYBIT_API_KEY!, process.env.BYBIT_API_SECRET!);
|
||||
|
||||
export const createOrder = async (req: Request, res: Response) => {
|
||||
// TODO: Lấy client từ credential
|
||||
const order = await bybitService.createOrder(req.body);
|
||||
res.json(order);
|
||||
};
|
||||
|
||||
export const listOrders = async (req: Request, res: Response) => {
|
||||
const orders = await bybitService.listOrders({ category: 'linear' });
|
||||
res.json(orders);
|
||||
};
|
||||
|
||||
export const cancelOrder = async (req: Request, res: Response) => {
|
||||
const { orderId } = req.params;
|
||||
const result = await bybitService.cancelOrder({ orderId, symbol: 'BTCUSDT', category: 'linear' });
|
||||
res.json(result);
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue