move and fix binance exchange api examples

This commit is contained in:
c9s 2022-08-24 12:58:06 +08:00
parent 90f077b78b
commit 68064bfe44
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54
3 changed files with 8 additions and 7 deletions

View File

@ -14,6 +14,7 @@ import (
"github.com/c9s/bbgo/pkg/cmd/cmdutil"
"github.com/c9s/bbgo/pkg/exchange/binance"
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
)
@ -70,7 +71,7 @@ var rootCmd = &cobra.Command{
return fmt.Errorf("market %s is not defined", symbol)
}
marginAccount, err := exchange.QueryMarginAccount(ctx)
marginAccount, err := exchange.QueryCrossMarginAccount(ctx)
if err != nil {
return err
}
@ -98,8 +99,8 @@ var rootCmd = &cobra.Command{
Market: market,
Side: types.SideTypeBuy,
Type: types.OrderTypeLimit,
Price: price,
Quantity: quantity,
Price: fixedpoint.NewFromFloat(price),
Quantity: fixedpoint.NewFromFloat(quantity),
MarginSideEffect: types.SideEffectTypeMarginBuy,
TimeInForce: "GTC",
})

View File

@ -374,7 +374,7 @@ func (e *Exchange) transferCrossMarginAccountAsset(ctx context.Context, asset st
return err
}
func (e *Exchange) queryCrossMarginAccount(ctx context.Context) (*types.Account, error) {
func (e *Exchange) QueryCrossMarginAccount(ctx context.Context) (*types.Account, error) {
marginAccount, err := e.client.NewGetMarginAccountService().Do(ctx)
if err != nil {
return nil, err
@ -406,7 +406,7 @@ func (e *Exchange) queryCrossMarginAccount(ctx context.Context) (*types.Account,
return a, nil
}
func (e *Exchange) queryIsolatedMarginAccount(ctx context.Context) (*types.Account, error) {
func (e *Exchange) QueryIsolatedMarginAccount(ctx context.Context) (*types.Account, error) {
req := e.client.NewGetIsolatedMarginAccountService()
req.Symbols(e.IsolatedMarginSymbol)
@ -677,9 +677,9 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
if e.IsFutures {
account, err = e.QueryFuturesAccount(ctx)
} else if e.IsIsolatedMargin {
account, err = e.queryIsolatedMarginAccount(ctx)
account, err = e.QueryIsolatedMarginAccount(ctx)
} else if e.IsMargin {
account, err = e.queryCrossMarginAccount(ctx)
account, err = e.QueryCrossMarginAccount(ctx)
} else {
account, err = e.QuerySpotAccount(ctx)
}