cmd/exchange_template, exchanges: Update templates and propogate to exchanges (#1777)

* 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

* Exchange test template change

* A different approach

* fix conflict with gateio timeInForce

* minor exchange template update

* Minor fix to test_files template

* Update order tests

* Complete updating the order unit tests

* Updating exchange wrapper and test template files

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

* minor comment update

* fix time-in-force related test errors

* linter issue fix

* ADD_NEW_EXCHANGE documentation update

* 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

* consistency guideline added

* fix time-in-force error in gateio

* 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

* 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

* update exchange template

* update wrapper template file

* policy comments, and template files update

* rename all exchange types name to Exchange

* update on template files and template generation

* templates and generation code and other updates

* linter issue fix

* added subscriptions and websocket templates

* update ADD_NEW_EXCHANGE.md with recent binance functions and implementations

* rename template files and update unit tests

* minor template and unit test fix

* rename templates and fix on unit tests

* update on template files and documentation

* removed unnecessary tag fix and update templates

* fix Add_NEW_EXCHANGE.md doc file

* formatting, comments, and error checks update on template files

* rename exchange receivers to e and ex for consistency

* rename unit test exchange receiver and minor updates

* linter issues fix

* fix deribit issue and minor style update

* fix test issues caused by receiver change

* raname local variables exchange declaration variables

* update templates comments

* update templates and related comments

* renamed ex to e

* update template comments

* toggle WS to false to improve coverage

* template comments update

* added test coverage to Ws enabled and minor changes

---------

Co-authored-by: Samuel Reid <43227667+cranktakular@users.noreply.github.com>
This commit is contained in:
Samuael A.
2025-07-17 03:46:36 +03:00
committed by GitHub
parent 485397a0c7
commit 3f534a15f1
163 changed files with 20453 additions and 20313 deletions

View File

@@ -464,8 +464,8 @@ func TestSetupExchanges(t *testing.T) {
}
e.ExchangeManager = NewExchangeManager()
exchLoader(new(bitstamp.Bitstamp))
exchLoader(new(bitfinex.Bitfinex))
exchLoader(new(bitstamp.Exchange))
exchLoader(new(bitfinex.Exchange))
assert.ElementsMatch(t, []string{"Bitstamp", "Bitfinex"}, e.Config.GetEnabledExchanges())
t.Run("Load specific exchange", func(t *testing.T) {

View File

@@ -13,7 +13,7 @@ import (
)
type broken struct {
bitfinex.Bitfinex
bitfinex.Exchange
}
func (b *broken) Shutdown() error { return errExpectedTestError }
@@ -39,7 +39,7 @@ func TestExchangeManagerAdd(t *testing.T) {
err = m.Add(nil)
require.ErrorIs(t, err, errExchangeIsNil)
b := new(bitfinex.Bitfinex)
b := new(bitfinex.Exchange)
b.SetDefaults()
err = m.Add(b)
require.NoError(t, err)
@@ -70,7 +70,7 @@ func TestExchangeManagerGetExchanges(t *testing.T) {
if len(exchanges) != 0 {
t.Error("unexpected value")
}
b := new(bitfinex.Bitfinex)
b := new(bitfinex.Exchange)
b.SetDefaults()
err = m.Add(b)
require.NoError(t, err)
@@ -98,7 +98,7 @@ func TestExchangeManagerRemoveExchange(t *testing.T) {
err = m.RemoveExchange("Bitfinex")
require.ErrorIs(t, err, ErrExchangeNotFound)
b := new(bitfinex.Bitfinex)
b := new(bitfinex.Exchange)
b.SetDefaults()
err = m.Add(b)
require.NoError(t, err)
@@ -148,7 +148,7 @@ func TestNewExchangeByName(t *testing.T) {
}
}
load := &bitfinex.Bitfinex{}
load := &bitfinex.Exchange{}
load.SetDefaults()
err = m.Add(load)

View File

@@ -967,53 +967,53 @@ func genCert(targetDir string) error {
func NewSupportedExchangeByName(name string) (exchange.IBotExchange, error) {
switch strings.ToLower(name) {
case "binanceus":
return new(binanceus.Binanceus), nil
return new(binanceus.Exchange), nil
case "binance":
return new(binance.Binance), nil
return new(binance.Exchange), nil
case "bitfinex":
return new(bitfinex.Bitfinex), nil
return new(bitfinex.Exchange), nil
case "bitflyer":
return new(bitflyer.Bitflyer), nil
return new(bitflyer.Exchange), nil
case "bithumb":
return new(bithumb.Bithumb), nil
return new(bithumb.Exchange), nil
case "bitmex":
return new(bitmex.Bitmex), nil
return new(bitmex.Exchange), nil
case "bitstamp":
return new(bitstamp.Bitstamp), nil
return new(bitstamp.Exchange), nil
case "btc markets":
return new(btcmarkets.BTCMarkets), nil
return new(btcmarkets.Exchange), nil
case "btse":
return new(btse.BTSE), nil
return new(btse.Exchange), nil
case "bybit":
return new(bybit.Bybit), nil
return new(bybit.Exchange), nil
case "coinut":
return new(coinut.COINUT), nil
return new(coinut.Exchange), nil
case "deribit":
return new(deribit.Deribit), nil
return new(deribit.Exchange), nil
case "exmo":
return new(exmo.EXMO), nil
return new(exmo.Exchange), nil
case "coinbasepro":
return new(coinbasepro.CoinbasePro), nil
return new(coinbasepro.Exchange), nil
case "gateio":
return new(gateio.Gateio), nil
return new(gateio.Exchange), nil
case "gemini":
return new(gemini.Gemini), nil
return new(gemini.Exchange), nil
case "hitbtc":
return new(hitbtc.HitBTC), nil
return new(hitbtc.Exchange), nil
case "huobi":
return new(huobi.HUOBI), nil
return new(huobi.Exchange), nil
case "kraken":
return new(kraken.Kraken), nil
return new(kraken.Exchange), nil
case "kucoin":
return new(kucoin.Kucoin), nil
return new(kucoin.Exchange), nil
case "lbank":
return new(lbank.Lbank), nil
return new(lbank.Exchange), nil
case "okx":
return new(okx.Okx), nil
return new(okx.Exchange), nil
case "poloniex":
return new(poloniex.Poloniex), nil
return new(poloniex.Exchange), nil
case "yobit":
return new(yobit.Yobit), nil
return new(yobit.Exchange), nil
default:
return nil, fmt.Errorf("%q, %w", name, ErrExchangeNotFound)
}

View File

@@ -1471,7 +1471,7 @@ func TestCheckVars(t *testing.T) {
err := checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
assert.ErrorIs(t, err, errExchangeNotLoaded, "checkParams should error correctly")
e = &binance.Binance{}
e = &binance.Exchange{}
err = checkParams("Binance", e, asset.Spot, currency.NewBTCUSDT())
assert.ErrorIs(t, err, errExchangeNotEnabled, "checkParams should error correctly")

View File

@@ -23,7 +23,7 @@ const (
func withdrawManagerTestHelper(t *testing.T) (*ExchangeManager, *portfolioManager) {
t.Helper()
em := NewExchangeManager()
b := new(okx.Okx)
b := new(okx.Exchange)
cfg, err := exchange.GetDefaultConfig(t.Context(), b)
if err != nil {
t.Fatal(err)