gitee.com/quant1x/engine@v1.8.4/services/task_sell_test.go (about)

     1  package services
     2  
     3  import (
     4  	"fmt"
     5  	"gitee.com/quant1x/engine/config"
     6  	"gitee.com/quant1x/engine/models"
     7  	"reflect"
     8  	"slices"
     9  	"testing"
    10  )
    11  
    12  func TestTaskSell_LastSession(t *testing.T) {
    13  	sellStrategyCode := models.ModelOneSizeFitsAllSells
    14  	// 1. 获取117号策略(卖出)
    15  	sellRule := config.GetStrategyParameterByCode(sellStrategyCode)
    16  	if sellRule == nil {
    17  		return
    18  	}
    19  	timestamp := "14:55:00"
    20  	v := sellRule.Session.IsTodayLastSession(timestamp)
    21  	fmt.Println(v)
    22  }
    23  
    24  type MyStruct struct {
    25  	Field1 string
    26  	Field2 int
    27  }
    28  
    29  func TestStructPtr(t *testing.T) {
    30  	// 创建一个结构体切片
    31  	structSlice := []MyStruct{
    32  		{"first", 1},
    33  		{"second", 2},
    34  		{"third", 3},
    35  	}
    36  
    37  	// 获取切片的反射值对象
    38  	sliceValue := reflect.ValueOf(structSlice)
    39  	// 遍历切片
    40  	for i := 0; i < sliceValue.Len(); i++ {
    41  		// 获取切片元素
    42  		elem := sliceValue.Index(i)
    43  		// 获取元素的地址
    44  		elemAddr := elem.Addr().Interface()
    45  		// 打印元素的地址
    46  		fmt.Printf("Element %d address: %v\n", i, elemAddr)
    47  	}
    48  }
    49  
    50  func Test_cookieCutterSell(t *testing.T) {
    51  	cookieCutterSell()
    52  }
    53  
    54  func TestFinal(t *testing.T) {
    55  	var list []string = nil
    56  	v := slices.Contains(list, "1")
    57  	fmt.Println(v)
    58  
    59  }