exchanges: Types and unmarshalling methods update (#1899)

* 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

* 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

* update slice data processing

* fix linter issues

* remove unnecessary Unmarshal methods and replace type delatration and added unit tests

* minor change

* minor changes to types

* update gateio string to timeInForce conversion and unit test

* removed unused timeInForceString func from kraken

* removed redundant parentheses in slice unmarshaling

* array to slice conversion and other updates

* reverted slice target to array

* Binanceus unit test NotNil check to Len check

* change NotNil to Len check

* rename unmarshal unit test funcs name

* wrap json strings with []byte
This commit is contained in:
Samuael A.
2025-06-02 06:54:49 +03:00
committed by GitHub
parent 8fa6179f65
commit 0e9adcd1e1
28 changed files with 483 additions and 1095 deletions

View File

@@ -5553,9 +5553,9 @@ func TestGetOptionsTickBands(t *testing.T) {
func TestExtractIndexCandlestick(t *testing.T) {
t.Parallel()
data := `[ [ "1597026383085", "3.721", "3.743", "3.677", "3.708", "1" ], [ "1597026383085", "3.731", "3.799", "3.494", "3.72", "1" ]]`
data := []byte(`[ [ "1597026383085", "3.721", "3.743", "3.677", "3.708", "1" ], [ "1597026383085", "3.731", "3.799", "3.494", "3.72", "1" ]]`)
var resp []CandlestickHistoryItem
err := json.Unmarshal([]byte(data), &resp)
err := json.Unmarshal(data, &resp)
require.NoError(t, err)
require.Len(t, resp, 2)
require.Equal(t, 3.743, resp[0].HighestPrice.Float64())

View File

@@ -690,8 +690,7 @@ type ExpiryOpenInterestAndVolume struct {
// UnmarshalJSON deserializes slice of data into ExpiryOpenInterestAndVolume structure
func (e *ExpiryOpenInterestAndVolume) UnmarshalJSON(data []byte) error {
var expiryTimeString string
target := [6]any{&e.Timestamp, &expiryTimeString, &e.CallOpenInterest, &e.PutOpenInterest, &e.CallVolume, &e.PutVolume}
err := json.Unmarshal(data, &target)
err := json.Unmarshal(data, &[6]any{&e.Timestamp, &expiryTimeString, &e.CallOpenInterest, &e.PutOpenInterest, &e.CallVolume, &e.PutVolume})
if err != nil {
return err
}