mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 06:53:52 +00:00
move and fix binance exchange api examples
This commit is contained in:
parent
90f077b78b
commit
68064bfe44
|
@ -14,6 +14,7 @@ import (
|
||||||
|
|
||||||
"github.com/c9s/bbgo/pkg/cmd/cmdutil"
|
"github.com/c9s/bbgo/pkg/cmd/cmdutil"
|
||||||
"github.com/c9s/bbgo/pkg/exchange/binance"
|
"github.com/c9s/bbgo/pkg/exchange/binance"
|
||||||
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -70,7 +71,7 @@ var rootCmd = &cobra.Command{
|
||||||
return fmt.Errorf("market %s is not defined", symbol)
|
return fmt.Errorf("market %s is not defined", symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
marginAccount, err := exchange.QueryMarginAccount(ctx)
|
marginAccount, err := exchange.QueryCrossMarginAccount(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -98,8 +99,8 @@ var rootCmd = &cobra.Command{
|
||||||
Market: market,
|
Market: market,
|
||||||
Side: types.SideTypeBuy,
|
Side: types.SideTypeBuy,
|
||||||
Type: types.OrderTypeLimit,
|
Type: types.OrderTypeLimit,
|
||||||
Price: price,
|
Price: fixedpoint.NewFromFloat(price),
|
||||||
Quantity: quantity,
|
Quantity: fixedpoint.NewFromFloat(quantity),
|
||||||
MarginSideEffect: types.SideEffectTypeMarginBuy,
|
MarginSideEffect: types.SideEffectTypeMarginBuy,
|
||||||
TimeInForce: "GTC",
|
TimeInForce: "GTC",
|
||||||
})
|
})
|
|
@ -374,7 +374,7 @@ func (e *Exchange) transferCrossMarginAccountAsset(ctx context.Context, asset st
|
||||||
return err
|
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)
|
marginAccount, err := e.client.NewGetMarginAccountService().Do(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -406,7 +406,7 @@ func (e *Exchange) queryCrossMarginAccount(ctx context.Context) (*types.Account,
|
||||||
return a, nil
|
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 := e.client.NewGetIsolatedMarginAccountService()
|
||||||
req.Symbols(e.IsolatedMarginSymbol)
|
req.Symbols(e.IsolatedMarginSymbol)
|
||||||
|
|
||||||
|
@ -677,9 +677,9 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
|
||||||
if e.IsFutures {
|
if e.IsFutures {
|
||||||
account, err = e.QueryFuturesAccount(ctx)
|
account, err = e.QueryFuturesAccount(ctx)
|
||||||
} else if e.IsIsolatedMargin {
|
} else if e.IsIsolatedMargin {
|
||||||
account, err = e.queryIsolatedMarginAccount(ctx)
|
account, err = e.QueryIsolatedMarginAccount(ctx)
|
||||||
} else if e.IsMargin {
|
} else if e.IsMargin {
|
||||||
account, err = e.queryCrossMarginAccount(ctx)
|
account, err = e.QueryCrossMarginAccount(ctx)
|
||||||
} else {
|
} else {
|
||||||
account, err = e.QuerySpotAccount(ctx)
|
account, err = e.QuerySpotAccount(ctx)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user