bybit.go.api/examples/Trade/place_trade.go

23 lines
610 B
Go
Raw Normal View History

2023-11-05 23:35:56 +02:00
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
2023-11-06 18:29:28 +02:00
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
2023-11-05 23:35:56 +02:00
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT", "side": "Buy", "positionIdx": 0, "orderType": "Limit", "qty": "0.001", "price": "10000", "timeInForce": "GTC"}
2023-11-06 00:18:48 +02:00
orderResult, err := client.NewTradeService(params).PlaceOrder(context.Background())
2023-11-05 23:35:56 +02:00
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}