service: drop unused methods

Signed-off-by: c9s <yoanlin93@gmail.com>
This commit is contained in:
c9s 2022-06-24 19:11:21 +08:00
parent bd991a7080
commit f4bb7bd231
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
2 changed files with 0 additions and 62 deletions

View File

@ -2,7 +2,6 @@ package service
import (
"context"
"fmt"
"strconv"
"strings"
"time"
@ -335,49 +334,6 @@ func (s *TradeService) Load(ctx context.Context, id int64) (*types.Trade, error)
return nil, errors.Wrapf(ErrTradeNotFound, "trade id:%d not found", id)
}
func (s *TradeService) Mark(ctx context.Context, id int64, strategyID string) error {
result, err := s.DB.NamedExecContext(ctx, "UPDATE `trades` SET `strategy` = :strategy WHERE `id` = :id", map[string]interface{}{
"id": id,
"strategy": strategyID,
})
if err != nil {
return err
}
cnt, err := result.RowsAffected()
if err != nil {
return err
}
if cnt == 0 {
return fmt.Errorf("trade id:%d not found", id)
}
return nil
}
func (s *TradeService) UpdatePnL(ctx context.Context, id int64, pnl float64) error {
result, err := s.DB.NamedExecContext(ctx, "UPDATE `trades` SET `pnl` = :pnl WHERE `id` = :id", map[string]interface{}{
"id": id,
"pnl": pnl,
})
if err != nil {
return err
}
cnt, err := result.RowsAffected()
if err != nil {
return err
}
if cnt == 0 {
return fmt.Errorf("trade id:%d not found", id)
}
return nil
}
func queryTradesSQL(options QueryTradesOptions) string {
ordering := "ASC"
switch v := strings.ToUpper(options.Ordering); v {

View File

@ -38,24 +38,6 @@ func Test_tradeService(t *testing.T) {
Time: types.Time(time.Now()),
})
assert.NoError(t, err)
err = service.Mark(ctx, 1, "grid")
assert.NoError(t, err)
tradeRecord, err := service.Load(ctx, 1)
assert.NoError(t, err)
assert.NotNil(t, tradeRecord)
assert.True(t, tradeRecord.StrategyID.Valid)
assert.Equal(t, "grid", tradeRecord.StrategyID.String)
err = service.UpdatePnL(ctx, 1, 10.0)
assert.NoError(t, err)
tradeRecord, err = service.Load(ctx, 1)
assert.NoError(t, err)
assert.NotNil(t, tradeRecord)
assert.True(t, tradeRecord.PnL.Valid)
assert.Equal(t, 10.0, tradeRecord.PnL.Float64)
}
func Test_queryTradingVolumeSQL(t *testing.T) {