21 lines
No EOL
780 B
TypeScript
21 lines
No EOL
780 B
TypeScript
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);
|
|
};
|