exchanges: Order types update (#1850)

* Added TimeInForce type and updated related files

* Linter issue fix and minor coinbasepro type update

* Bitrex consts update

* added unit test and minor changes in bittrex

* Unit tests update

* Fix minor linter issues

* Update TestStringToTimeInForce unit test

* fix conflict with gateio timeInForce

* Update order tests

* Complete updating the order unit tests

* update kucoin and deribit wrapper to match the time in force change

* fix time-in-force related test errors

* linter issue fix

* time in force constants, functions and unit tests update

* shift tif policies to TimeInForce

* Update time-in-force, related functions, and unit tests

* fix linter issue and time-in-force processing

* added a good till crossing tif value

* order type fix and fix related tim-in-force entries

* update time-in-force unmarshaling and unit test

* update order type to support time-in-force and hybrid order type representation

* added tests for type and time-in-force check from order type

* fix time-in-force error in gateio

* fix minor unit test issues

* linter issue fix

* update based on review comments

* add unit test and fix missing issues

* minor fix and added benchmark unit test

* change GTT to GTC for limit

* fix linter issue

* linter issues fix

* update order types declaration and handling by endpoints

* added time-in-force value to place order param

* fix minor issues based on review comment and move tif code to separate files

* update on exchanges linked to time-in-force

* resolve missing review comments

* minor linter issues fix

* added time-in-force handler and update timeInForce parametered endpoint

* minor fixes based on review

* nits fix

* update based on review

* linter fix

* rm getTimeInForce func and minor change to time-in-force

* minor change

* update based on review comments

* wrappers and time-in-force calling approach

* minor change

* update gateio string to timeInForce conversion and unit test

* fix types to string conversion

* fix build errors

* update on order types handling and unit tests

* fix linter issue

* order type unit tests update

* order types string as constant replacement and unit tests update

* update order type-string functions unit test
This commit is contained in:
Samuael A.
2025-06-12 08:39:17 +03:00
committed by GitHub
parent d5ba674fc4
commit a8a3bc4ee2
9 changed files with 265 additions and 148 deletions

View File

@@ -667,44 +667,42 @@ func (d *Detail) DeriveCancel() (*Cancel, error) {
// String implements the stringer interface
func (t Type) String() string {
switch t {
case AnyType:
return "ANY"
case Limit:
return "LIMIT"
case Market:
return "MARKET"
case Stop:
return "STOP"
case ConditionalStop:
return "CONDITIONAL"
case MarketMakerProtection:
return "MMP"
case MarketMakerProtectionAndPostOnly:
return "MMP_AND_POST_ONLY"
case TWAP:
return "TWAP"
case Chase:
return "CHASE"
case StopLimit:
return "STOP LIMIT"
case StopMarket:
return "STOP MARKET"
return orderStopMarket
case StopLimit:
return orderStopLimit
case Limit:
return orderLimit
case Market:
return orderMarket
case Stop:
return orderStop
case ConditionalStop:
return orderConditionalStop
case TWAP:
return orderTWAP
case Chase:
return orderChase
case TakeProfit:
return "TAKE PROFIT"
return orderTakeProfit
case TakeProfitMarket:
return "TAKE PROFIT MARKET"
return orderTakeProfitMarket
case TrailingStop:
return "TRAILING_STOP"
return orderTrailingStop
case IOS:
return "IOS"
return orderIOS
case Liquidation:
return "LIQUIDATION"
return orderLiquidation
case Trigger:
return "TRIGGER"
case OptimalLimitIOC:
return "OPTIMAL_LIMIT_IOC"
return orderTrigger
case OCO:
return "OCO"
return orderOCO
case OptimalLimit:
return orderOptimalLimit
case MarketMakerProtection:
return orderMarketMakerProtection
case AnyType:
return orderAnyType
default:
return "UNKNOWN"
}
@@ -1102,43 +1100,41 @@ func (s Side) MarshalJSON() ([]byte, error) {
func StringToOrderType(oType string) (Type, error) {
oType = strings.ToUpper(oType)
switch oType {
case Limit.String(), "EXCHANGE LIMIT":
case orderLimit, "EXCHANGE LIMIT":
return Limit, nil
case Market.String(), "EXCHANGE MARKET":
case orderMarket, "EXCHANGE MARKET":
return Market, nil
case Stop.String(), "STOP LOSS", "STOP_LOSS", "EXCHANGE STOP":
case orderStop, "STOP LOSS", "STOP_LOSS", "EXCHANGE STOP":
return Stop, nil
case StopLimit.String(), "EXCHANGE STOP LIMIT", "STOP_LIMIT":
case orderStopLimit, "EXCHANGE STOP LIMIT", "STOP_LIMIT":
return StopLimit, nil
case StopMarket.String(), "STOP_MARKET":
case orderStopMarket, "STOP_MARKET":
return StopMarket, nil
case TrailingStop.String(), "TRAILING STOP", "EXCHANGE TRAILING STOP", "MOVE_ORDER_STOP":
case orderTrailingStop, "TRAILING STOP", "EXCHANGE TRAILING STOP", "MOVE_ORDER_STOP":
return TrailingStop, nil
case IOS.String():
case orderIOS:
return IOS, nil
case AnyType.String():
case orderAnyType:
return AnyType, nil
case Trigger.String():
case orderTrigger:
return Trigger, nil
case OptimalLimitIOC.String():
return OptimalLimitIOC, nil
case OCO.String():
case orderOptimalLimit:
return OptimalLimit, nil
case orderOCO:
return OCO, nil
case ConditionalStop.String():
case orderConditionalStop:
return ConditionalStop, nil
case MarketMakerProtection.String():
case orderMarketMakerProtection:
return MarketMakerProtection, nil
case MarketMakerProtectionAndPostOnly.String():
return MarketMakerProtectionAndPostOnly, nil
case TWAP.String():
case orderTWAP:
return TWAP, nil
case Chase.String():
case orderChase:
return Chase, nil
case TakeProfitMarket.String(), "TAKE_PROFIT_MARKET":
case orderTakeProfitMarket, "TAKE_PROFIT_MARKET":
return TakeProfitMarket, nil
case TakeProfit.String(), "TAKE_PROFIT":
case orderTakeProfit, "TAKE_PROFIT":
return TakeProfit, nil
case Liquidation.String():
case orderLiquidation:
return Liquidation, nil
default:
return UnknownType, fmt.Errorf("'%v' %w", oType, errUnrecognisedOrderType)