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.2 KiB
131 lines
4.2 KiB
package service
|
|
|
|
import (
|
|
"context"
|
|
"matchmaking-system/internal/pkg/flags"
|
|
"matchmaking-system/internal/service/option"
|
|
"matchmaking-system/internal/service/order"
|
|
|
|
v1 "matchmaking-system/api/matchmaking/v1/option"
|
|
)
|
|
|
|
// GetBotStockOptionInrTrade
|
|
//
|
|
// @Description: 期权印度股订单列表
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.GetBotStockOptionInrTradeReply
|
|
// @return error
|
|
func (s *ConduitService) GetBotStockOptionInrTrade(ctx context.Context, req *v1.GetBotStockOptionInrTradeRequest) (*v1.GetBotStockOptionInrTradeReply, error) {
|
|
if !option.VerificationBotStockOptionInrTrade(req) {
|
|
return option.BotStockOptionInrTradeReply(false, flags.ErrIsParameter.Error(), req, nil, 0), nil
|
|
}
|
|
|
|
stockTradeList, totalCount, err := s.oi.BotStockOptionInrTradeList(ctx, req.PageSize, req.PageCount, req.Status)
|
|
if err != nil {
|
|
return option.BotStockOptionInrTradeReply(false, err.Error(), req, nil, 0), nil
|
|
}
|
|
|
|
return option.BotStockOptionInrTradeReply(true, flags.SetNull, req, stockTradeList, totalCount), nil
|
|
}
|
|
|
|
// OptionInrPlaceOrder
|
|
//
|
|
// @Description: 期权印度股下单
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.OptionInrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) OptionInrPlaceOrder(ctx context.Context, req *v1.OptionInrOrderRequest) (*v1.OptionInrOrderReply, error) {
|
|
if !option.VerificationOptionInrOrderQuery(req) {
|
|
return option.OptionInrPlaceOrderReply(false, flags.ErrIsParameter.Error(), flags.SetNull), nil
|
|
}
|
|
|
|
orderId, err := s.oi.OptionInrPlaceOrder(ctx, option.OptionInrOrderQuery(req))
|
|
if err != nil {
|
|
return option.OptionInrPlaceOrderReply(false, order.CheckShareError(err), flags.SetNull), nil
|
|
}
|
|
|
|
return option.OptionInrPlaceOrderReply(true, flags.SetNull, orderId), nil
|
|
}
|
|
|
|
// OptionInrUpdateOrder
|
|
//
|
|
// @Description: 期权印度股止盈止损
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.OptionInrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) OptionInrUpdateOrder(ctx context.Context, req *v1.UpdateOptionInrOrderRequest) (*v1.OptionInrOrderReply, error) {
|
|
if !option.VerificationOptionInrStopOrderQuery(req) {
|
|
return option.OptionInrUpdateOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.oi.OptionInrUpdateOrder(ctx, option.StopOptionInrOrderQuery(req))
|
|
if err != nil {
|
|
return option.OptionInrUpdateOrderReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return option.OptionInrUpdateOrderReply(true, flags.SetNull, req), nil
|
|
}
|
|
|
|
// OptionInrCancel
|
|
//
|
|
// @Description: 期权印度股撤单
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.OptionInrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) OptionInrCancel(ctx context.Context, req *v1.CancelOptionInrOrderRequest) (*v1.OptionInrOrderReply, error) {
|
|
if !option.VerificationOptionInrCancel(req) {
|
|
return option.OptionInrCancelReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.oi.OptionInrCancel(ctx, req.OrderId)
|
|
if err != nil {
|
|
return option.OptionInrCancelReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return option.OptionInrCancelReply(true, flags.SetNull, req), nil
|
|
}
|
|
|
|
// OptionInrPosition
|
|
//
|
|
// @Description: 期权印度股平仓
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.InrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) OptionInrPosition(ctx context.Context, req *v1.CancelOptionInrOrderRequest) (*v1.OptionInrOrderReply, error) {
|
|
if !option.VerificationOptionInrPosition(req) {
|
|
return option.OptionInrPositionOrderReply(false, flags.ErrIsParameter.Error(), req), nil
|
|
}
|
|
|
|
_, err := s.oi.OptionInrPosition(ctx, req.OrderId)
|
|
if err != nil {
|
|
return option.OptionInrPositionOrderReply(false, order.CheckShareError(err), req), nil
|
|
}
|
|
|
|
return option.OptionInrPositionOrderReply(true, flags.SetNull, req), nil
|
|
}
|
|
|
|
// OptionInrAllPosition
|
|
//
|
|
// @Description: 期权印度股一键平仓
|
|
// @receiver s
|
|
// @param ctx
|
|
// @param req
|
|
// @return *v1.AllOptionInrOrderReply
|
|
// @return error
|
|
func (s *ConduitService) OptionInrAllPosition(ctx context.Context, req *v1.AllOptionInrOrderRequest) (*v1.AllOptionInrOrderReply, error) {
|
|
if err := s.oi.OptionInrAllPosition(ctx); err != nil {
|
|
return option.OptionInrAllPositionRequest(false, order.CheckShareError(err)), nil
|
|
}
|
|
|
|
return option.OptionInrAllPositionRequest(true, flags.SetNull), nil
|
|
}
|
|
|