Remove dir: examples/

This commit is contained in:
isther 2024-01-04 16:42:45 +08:00
parent 9fbb411eb6
commit a5e773a1c3
22 changed files with 0 additions and 522 deletions

View File

@ -1,51 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceBatchTrade()
}
func PlaceBatchTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "option",
"request": []map[string]interface{}{
{
"category": "option",
"symbol": "BTC-10FEB23-24000-C",
"orderType": "Limit",
"side": "Buy",
"qty": "0.1",
"price": "5",
"orderIv": "0.1",
"timeInForce": "GTC",
"orderLinkId": "9b381bb1-401",
"mmp": false,
"reduceOnly": false,
},
{
"category": "option",
"symbol": "BTC-10FEB23-24000-C",
"orderType": "Limit",
"side": "Buy",
"qty": "0.1",
"price": "5",
"orderIv": "0.1",
"timeInForce": "GTC",
"orderLinkId": "82ee86dd-001",
"mmp": false,
"reduceOnly": false,
},
},
}
orderResult, err := client.NewTradeService(params).PlaceBatchOrder(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,21 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceOrder()
}
func PlaceOrder() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
orderResult, err := client.NewPlaceOrderService("linear", "XRPUSDT", "Buy", "Market", "10").Do(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

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

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"accountType": "UNIFIED", "category": "linear"}
accountResult, err := client.NewAccountService(params).GetTransactionLog(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(accountResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
AssetInfo()
}
func AssetInfo() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"accountType": "spot"}
assetResult, err := client.NewAssetService(params).GetAssetInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(assetResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
GetCoinInfo()
}
func GetCoinInfo() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"coin": "USDT"}
assetResult, err := client.NewAssetService(params).GetCoinInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(assetResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{}
orderResult, err := client.NewBrokerService(params).GetBrokerEarning(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"coin": "USDT"}
orderResult, err := client.NewLendingService(params).GetC2cLendingCoinInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,25 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
InstrumentInfo()
}
func InstrumentInfo() {
client := bybit.NewBybitHttpClient("", "")
// NewServerTimeService
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT", "status": "Trading"}
marketKline, err := client.NewMarketInfoService(params).GetInstrumentInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(marketKline))
}

View File

@ -1,25 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
IndexKline()
}
func IndexKline() {
client := bybit.NewBybitHttpClient("", "")
// NewServerTimeService
params := map[string]interface{}{"category": "linear", "symbol": "BTCUSDT", "interval": "1", "Limit": 2}
marketKline, err := client.NewMarketKLinesService("index-price-kline", params).GetMarketKline(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(marketKline))
}

View File

@ -1,24 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
MarketKline()
}
func MarketKline() {
client := bybit.NewBybitHttpClient("", "")
// NewServerTimeService
marketKline, err := client.NewMarketKlineService("premium-index-price-kline", "linear", "BTCUSDT", "1").Limit(10).Do(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(marketKline))
}

View File

@ -1,24 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
ServerTime()
}
func ServerTime() {
client := bybit.NewBybitHttpClient("", "")
// NewServerTimeService
serverTime, err := client.NewMarketInfoServiceNoParams().GetServerTime(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(serverTime))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "settleCoin": "USDT", "limit": 10}
orderResult, err := client.NewPositionService(params).GetPositionList(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
SwitchPositionMode()
}
func SwitchPositionMode() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "coin": "USDT", "mode": 3}
orderResult, err := client.NewPositionService(params).SwitchPositionMode(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"category": "linear", "settleCoin": "USDT", "limit": 10}
orderResult, err := client.NewPreUpgradeService(params).GetPreUpgradeOrderHistory(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(orderResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
PlaceTrade()
}
func PlaceTrade() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"ltCoin": "BTC3L"}
leverageTokenResult, err := client.NewSpotLeverageService(params).GetLeverageTokenInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(leverageTokenResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
SpotMarginData()
}
func SpotMarginData() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"ltCoin": "BTC3L"}
leverageTokenResult, err := client.NewSpotMarginDataService(params, true).GetSpotMarginData(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(leverageTokenResult))
}

View File

@ -1,28 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
CreateSubApiKey()
}
func CreateSubApiKey() {
client := bybit.NewBybitHttpClient("8wYkmpLsMg10eNQyPm", "Ouxc34myDnXvei54XsBZgoQzfGxO4bkr2Zsj", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"subuid": "100366706", "readOnly": 0,
"permissions": []map[string]interface{}{
{
"Wallet": []string{"AccountTransfer", "SubMemberTransferList"},
},
},
}
userResult, err := client.NewUserService(params).CreateSubApiKey(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(userResult))
}

View File

@ -1,22 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
CreateNewSubUser()
}
func CreateNewSubUser() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
params := map[string]interface{}{"username": "06112023Victor", "memberType": 1}
userResult, err := client.NewUserService(params).CreateSubMember(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(userResult))
}

View File

@ -1,21 +0,0 @@
package main
import (
"context"
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
GetApiKeyInfo()
}
func GetApiKeyInfo() {
client := bybit.NewBybitHttpClient("YOUR_API_KEY", "YOUR_API_SECRET", bybit.WithBaseURL(bybit.TESTNET))
userResult, err := client.NewUserServiceNoParams().GetAPIKeyInfo(context.Background())
if err != nil {
fmt.Println(err)
return
}
fmt.Println(bybit.PrettyPrint(userResult))
}

View File

@ -1,15 +0,0 @@
package main
import (
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
ws := bybit.NewBybitPrivateWebSocket("wss://stream-testnet.bybit.com/v5/private", "YOUR_API_KEY", "YOUR_API_SECRET", func(message string) error {
fmt.Println("Received:", message)
return nil
})
_ = ws.Connect([]string{"order"})
select {}
}

View File

@ -1,15 +0,0 @@
package main
import (
"fmt"
bybit "github.com/wuhewuhe/bybit.go.api"
)
func main() {
ws := bybit.NewBybitPublicWebSocket("wss://stream.bybit.com/v5/public/spot", func(message string) error {
fmt.Println("Received:", message)
return nil
})
_ = ws.Connect([]string{"orderbook.1.BTCUSDT"})
select {}
}