This commit is contained in:
daichao
2025-02-10 17:55:34 +08:00
parent 365bde5848
commit ea7a51dd76
4 changed files with 131 additions and 7 deletions

View File

@ -108,11 +108,11 @@ func TestFutOrderPalce(t *testing.T) {
func TestCancelOpenOrderByOrderSn(t *testing.T) {
api := SpotRestApi{}
dsn := "root:root@tcp(192.168.1.12:3306)/gp-bian?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
dsn := "root:root@tcp(192.168.1.12:3306)/go_exchange_single?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
var apiUserInfo models.LineApiUser
db.Model(&models.LineApiUser{}).Where("id = ?", 10).Find(&apiUserInfo)
err := api.CancelOpenOrderByOrderSn(apiUserInfo, "DOGEUSDT", "367836524202426368")
db.Model(&models.LineApiUser{}).Where("id = ?", 50).Find(&apiUserInfo)
err := api.CancelOpenOrderByOrderSn(apiUserInfo, "TRUMPUSDT", "1698362708")
if err != nil {
t.Log("err:", err)
} else {
@ -194,3 +194,24 @@ func TestClosePosition(t *testing.T) {
fmt.Println("err:", err)
}
func TestFutOrderPlace(t *testing.T) {
futureApi := FutRestApi{}
dsn := "root:root@tcp(192.168.1.12:3306)/go_exchange_single?charset=utf8mb4&parseTime=True&loc=Local&timeout=1000ms"
db, _ := gorm.Open(mysql.Open(dsn), &gorm.Config{})
err := futureApi.OrderPlace(db, FutOrderPlace{
ApiId: 50,
Symbol: "ADAUSDT",
Side: "SELL",
Quantity: decimal.NewFromFloat(8),
Price: decimal.NewFromFloat(0.697),
SideType: "LIMIT",
OpenOrder: 0,
Profit: decimal.NewFromFloat(0.698),
StopPrice: decimal.NewFromFloat(0.698),
OrderType: "STOP",
NewClientOrderId: "5465465784222554477",
})
fmt.Println("err:", err)
}