mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-13 02:23:51 +00:00
move MarginSettings struct to a file
This commit is contained in:
parent
1c77de031a
commit
5cab37488b
|
@ -30,22 +30,6 @@ func init() {
|
|||
}
|
||||
}
|
||||
|
||||
type MarginSettings struct {
|
||||
useMargin bool
|
||||
useMarginIsolated bool
|
||||
useMarginIsolatedSymbol string
|
||||
}
|
||||
|
||||
func (e *MarginSettings) UseMargin() {
|
||||
e.useMargin = true
|
||||
}
|
||||
|
||||
func (e *MarginSettings) UseIsolatedMargin(symbol string) {
|
||||
e.useMargin = true
|
||||
e.useMarginIsolated = true
|
||||
e.useMarginIsolatedSymbol = symbol
|
||||
}
|
||||
|
||||
type Exchange struct {
|
||||
MarginSettings
|
||||
|
||||
|
@ -388,11 +372,14 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
|
|||
return err2
|
||||
}
|
||||
|
||||
func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) {
|
||||
for _, order := range orders {
|
||||
func (e *Exchange) submitMarginOrder(ctx context.Context, order types.SubmitOrder) (*types.Order, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (e *Exchange) submitSpotOrder(ctx context.Context, order types.SubmitOrder) (*types.Order, error) {
|
||||
orderType, err := toLocalOrderType(order.Type)
|
||||
if err != nil {
|
||||
return createdOrders, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
clientOrderID := uuid.New().String()
|
||||
|
@ -415,7 +402,7 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
|
|||
switch order.Type {
|
||||
case types.OrderTypeStopLimit, types.OrderTypeStopMarket:
|
||||
if len(order.StopPriceString) == 0 {
|
||||
return createdOrders, fmt.Errorf("stop price string can not be empty")
|
||||
return nil, fmt.Errorf("stop price string can not be empty")
|
||||
}
|
||||
|
||||
req.StopPrice(order.StopPriceString)
|
||||
|
@ -428,12 +415,12 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
|
|||
|
||||
response, err := req.Do(ctx)
|
||||
if err != nil {
|
||||
return createdOrders, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
log.Infof("order creation response: %+v", response)
|
||||
|
||||
retOrder := binance.Order{
|
||||
createdOrder, err := ToGlobalOrder(&binance.Order{
|
||||
Symbol: response.Symbol,
|
||||
OrderID: response.OrderID,
|
||||
ClientOrderID: response.ClientOrderID,
|
||||
|
@ -445,16 +432,21 @@ func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder
|
|||
TimeInForce: response.TimeInForce,
|
||||
Type: response.Type,
|
||||
Side: response.Side,
|
||||
UpdateTime: response.TransactTime,
|
||||
Time: response.TransactTime,
|
||||
// IsIsolated: response.IsIsolated,
|
||||
// StopPrice:
|
||||
// IcebergQuantity:
|
||||
Time: response.TransactTime,
|
||||
// UpdateTime:
|
||||
// IsWorking: ,
|
||||
})
|
||||
|
||||
return createdOrder, err
|
||||
}
|
||||
|
||||
createdOrder, err := ToGlobalOrder(&retOrder)
|
||||
func (e *Exchange) SubmitOrders(ctx context.Context, orders ...types.SubmitOrder) (createdOrders types.OrderSlice, err error) {
|
||||
for _, order := range orders {
|
||||
createdOrder, err := e.submitSpotOrder(ctx, order)
|
||||
if err != nil {
|
||||
return createdOrders, err
|
||||
}
|
||||
|
|
17
pkg/exchange/binance/margin.go
Normal file
17
pkg/exchange/binance/margin.go
Normal file
|
@ -0,0 +1,17 @@
|
|||
package binance
|
||||
|
||||
type MarginSettings struct {
|
||||
useMargin bool
|
||||
useMarginIsolated bool
|
||||
useMarginIsolatedSymbol string
|
||||
}
|
||||
|
||||
func (e *MarginSettings) UseMargin() {
|
||||
e.useMargin = true
|
||||
}
|
||||
|
||||
func (e *MarginSettings) UseIsolatedMargin(symbol string) {
|
||||
e.useMargin = true
|
||||
e.useMarginIsolated = true
|
||||
e.useMarginIsolatedSymbol = symbol
|
||||
}
|
Loading…
Reference in New Issue
Block a user