gitee.com/quant1x/engine@v1.8.4/trader/trader_test.go (about)

     1  package trader
     2  
     3  import (
     4  	"fmt"
     5  	"gitee.com/quant1x/engine/models"
     6  	"gitee.com/quant1x/engine/strategies"
     7  	"testing"
     8  )
     9  
    10  func TestQueryAccount(t *testing.T) {
    11  	info, err := QueryAccount()
    12  	fmt.Println(info, err)
    13  }
    14  
    15  func TestQueryHolding(t *testing.T) {
    16  	info, err := QueryHolding()
    17  	fmt.Println(info, err)
    18  }
    19  
    20  func TestQueryOrders(t *testing.T) {
    21  	info, err := QueryOrders()
    22  	fmt.Println(info, err)
    23  }
    24  
    25  func TestTradeCancelOrder(t *testing.T) {
    26  	orderId := 1086140321
    27  	err := CancelOrder(orderId)
    28  	fmt.Println(err)
    29  }
    30  
    31  func TestTradePlaceOrder(t *testing.T) {
    32  	direction := BUY
    33  	model := strategies.ModelNo1{}
    34  	securityCode := "sh600178"
    35  	price := 13.68
    36  	volume := 100
    37  
    38  	orderId, err := PlaceOrder(direction, model, securityCode, FIX_PRICE, price, volume)
    39  	fmt.Println(orderId, err)
    40  }
    41  
    42  func TestCalculateFundForStrategy(t *testing.T) {
    43  	var model models.Strategy
    44  	model = new(TestModel)
    45  	fund := CalculateFundForStrategy(model)
    46  	fmt.Println(fund)
    47  }