mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-06 23:16:53 +00:00
protocol/order: adds additional fields for trading requirements (#1552)
* Add in initial handling for quote/base currency deployment requirements * include client order ID checking * glorious: suggestions * spell and fix * linter/context/test * rework tests and order side specific requirements * linter * mend panic at the disco * mending more panics at the disco * anudda fix brudda * glorious: NITTTTTT BOOOOOMB * leftover things and stuff * whoops * tie in gateio * glorious: nit fixes life and everything. * thrasher: nits --------- Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
This commit is contained in:
@@ -55,6 +55,10 @@ func (g *Gateio) SetDefaults() {
|
||||
}
|
||||
|
||||
g.Features = exchange.Features{
|
||||
TradingRequirements: protocol.TradingRequirements{
|
||||
SpotMarketOrderAmountPurchaseQuotationOnly: true,
|
||||
SpotMarketOrderAmountSellBaseOnly: true,
|
||||
},
|
||||
Supports: exchange.FeaturesSupported{
|
||||
REST: true,
|
||||
Websocket: true,
|
||||
@@ -984,7 +988,7 @@ func (g *Gateio) GetHistoricTrades(_ context.Context, _ currency.Pair, _ asset.I
|
||||
// SubmitOrder submits a new order
|
||||
// TODO: support multiple order types (IOC)
|
||||
func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.SubmitResponse, error) {
|
||||
err := s.Validate()
|
||||
err := s.Validate(g.GetTradingRequirements())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1008,11 +1012,20 @@ func (g *Gateio) SubmitOrder(ctx context.Context, s *order.Submit) (*order.Submi
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// When doing spot market orders when purchasing base currency, the
|
||||
// quote currency amount is used. When selling the base currency the
|
||||
// base currency amount is used.
|
||||
tradingAmount := s.Amount
|
||||
if tradingAmount == 0 && s.Type == order.Market {
|
||||
tradingAmount = s.QuoteAmount
|
||||
}
|
||||
|
||||
sOrder, err := g.PlaceSpotOrder(ctx, &CreateOrderRequestData{
|
||||
Side: s.Side.Lower(),
|
||||
Type: s.Type.Lower(),
|
||||
Account: g.assetTypeToString(s.AssetType),
|
||||
Amount: types.Number(s.Amount),
|
||||
Amount: types.Number(tradingAmount),
|
||||
Price: types.Number(s.Price),
|
||||
CurrencyPair: s.Pair,
|
||||
Text: s.ClientOrderID,
|
||||
|
||||
Reference in New Issue
Block a user