You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
131 lines
4.0 KiB
131 lines
4.0 KiB
package service
|
|
|
|
import (
|
|
"context"
|
|
"matchmaking-system/internal/pkg/flags"
|
|
"matchmaking-system/internal/service/order"
|
|
"matchmaking-system/internal/service/share"
|
|
|
|
v1 "matchmaking-system/api/matchmaking/v1/share"
|
|
)
|
|
|
|
// GetBotStockInrTrade
|
|
//
|
|
// @Description: 英股订单列表
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.GetInrBotStockInrTradeReply
|
|
// @return error
|
|
func (s *ConduitService) GetBotStockGbxTrade(ctx context.Context, req *v1.GetBotStockGbxTradeRequest) (*v1.GetBotStockGbxTradeReply, error) {
|
|
if !share.VerificationGbxBotStockTrade(req) {
|
|
return share.BotStockGbxTradeReply(false, flags.ErrIsParameter.Error(), req, nil, 0), nil
|
|
}
|
|
|
|
stockTradeList, totalCount, err := s.gb.BotStockGbxTradeList(ctx, req.PageSize, req.PageCount, req.Status)
|
|
if err != nil {
|
|
return share.BotStockGbxTradeReply(false, err.Error(), req, nil, 0), nil
|
|
}
|
|
|
|
return share.BotStockGbxTradeReply(true, flags.SetNull, req, stockTradeList, totalCount), nil
|
|
}
|
|
|
|
// ShareInrPlaceOrder
|
|
//
|
|
// @Description: 英股下单
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.InrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) ShareGbxPlaceOrder(ctx context.Context, req *v1.OrderGbxRequest) (*v1.OrderGbxReply, error) {
|
|
if !share.VerificationGbxShareOrderQuery(req) {
|
|
return share.ShareGbxPlaceOrderReply(false, flags.ErrIsParameter.Error(), flags.SetNull), nil
|
|
}
|
|
|
|
orderId, err := s.gb.ShareGbxPlaceOrder(ctx, share.ShareGbxOrderQuery(req))
|
|
if err != nil {
|
|
return share.ShareGbxPlaceOrderReply(false, order.CheckShareError(err), flags.SetNull), nil
|
|
}
|
|
|
|
return share.ShareGbxPlaceOrderReply(true, flags.SetNull, orderId), nil
|
|
}
|
|
|
|
// ShareInrUpdateOrder
|
|
//
|
|
// @Description: 英股止盈止损
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.InrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) ShareGbxUpdateOrder(ctx context.Context, req *v1.UpdateGbxOrderRequest) (*v1.OrderGbxReply, error) {
|
|
if !share.VerificationGbxStopOrderQuery(req) {
|
|
return share.ShareGbxUpdateOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.gb.ShareGbxUpdateOrder(ctx, share.StopGbxOrderQuery(req))
|
|
if err != nil {
|
|
return share.ShareGbxUpdateOrderReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return share.ShareGbxUpdateOrderReply(true, flags.SetNull, req), nil
|
|
}
|
|
|
|
// ShareInrPosition
|
|
//
|
|
// @Description: 英股平仓
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.InrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) ShareGbxPosition(ctx context.Context, req *v1.CancelGbxOrderRequest) (*v1.OrderGbxReply, error) {
|
|
if !share.VerificationGbxSharePosition(req) {
|
|
return share.ShareGbxPositionOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.gb.ShareGbxPosition(ctx, req.OrderId)
|
|
if err != nil {
|
|
return share.ShareGbxPositionOrderReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return share.ShareGbxPositionOrderReply(true, flags.SetNull, req), nil
|
|
}
|
|
|
|
// ShareInrAllPosition
|
|
//
|
|
// @Description: 英股一键平仓
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.AllInrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) ShareGbxAllPosition(ctx context.Context, req *v1.AllGbxOrderRequest) (*v1.AllGbxOrderReply, error) {
|
|
if err := s.gb.ShareGbxAllPosition(ctx); err != nil {
|
|
return share.ShareAllGbxPositionRequest(false, order.CheckShareError(err)), nil
|
|
}
|
|
|
|
return share.ShareAllGbxPositionRequest(true, flags.SetNull), nil
|
|
}
|
|
|
|
// ShareInrCancel
|
|
//
|
|
// @Description: 英股撤单
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.InrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) ShareGbxCancel(ctx context.Context, req *v1.CancelGbxOrderRequest) (*v1.OrderGbxReply, error) {
|
|
if !share.VerificationGbxShareCancel(req) {
|
|
return share.ShareGbxCancelReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.gb.ShareGbxCancel(ctx, req.OrderId)
|
|
if err != nil {
|
|
return share.ShareGbxCancelReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return share.ShareGbxCancelReply(true, flags.SetNull, req), nil
|
|
}
|
|
|