mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-05-13 15:09:42 +00:00
CI, sonic: Replace backend-arm64 docker build with native GHA runner, disable sonic for arm64 (#1794)
* CI: Replace docker amd64 with native runner, switch Docker test arch to amd64 * tests: Remove spaces and new lines from test JSON timestamp fields * builds: Disable sonic for arm64 due to OKX unmarshal issue * nits: Improve Dockerfile comment and fix build tag
This commit is contained in:
@@ -1,4 +1,7 @@
|
||||
FROM arm64v8/golang:1.23
|
||||
FROM golang:1.23-alpine
|
||||
|
||||
# Install GCC and musl-dev (needed for SQLite library)
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
|
||||
WORKDIR /app
|
||||
|
||||
@@ -7,6 +10,4 @@ RUN go mod download && go mod verify
|
||||
|
||||
COPY . /app
|
||||
|
||||
RUN go build
|
||||
|
||||
CMD ["go", "test", "./..."]
|
||||
46
.github/workflows/tests.yml
vendored
46
.github/workflows/tests.yml
vendored
@@ -3,8 +3,8 @@ name: CI
|
||||
env:
|
||||
GO_VERSION: 1.23.x
|
||||
jobs:
|
||||
backend-psql:
|
||||
name: GoCryptoTrader back-end
|
||||
backend:
|
||||
name: GoCryptoTrader backend (${{ matrix.os }}, ${{ matrix.goarch }}, psql=${{ matrix.psql }}, skip_wrapper_tests=${{ matrix.skip_wrapper_tests}}, sonic=${{ matrix.sonic && matrix.goarch != '386' }})
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
@@ -18,17 +18,17 @@ jobs:
|
||||
goarch: 386
|
||||
psql: true
|
||||
skip_wrapper_tests: true
|
||||
sonic: true # sonic is disabled for 386 this ensures fall back to legacy code
|
||||
sonic: true # Sonic is not supported on 386 systems, this ensures our build tag condition defaults to and tests the standard encoding/json implementation
|
||||
- os: ubuntu-24.04-arm
|
||||
goarch: arm64
|
||||
psql: false # Not supported
|
||||
skip_wrapper_tests: true
|
||||
sonic: false # Disabled temporarily until OKX's unmarshalling is changed for sonic arm64 compatibility
|
||||
- os: macos-latest
|
||||
goarch: amd64
|
||||
goarch: arm64
|
||||
psql: true
|
||||
skip_wrapper_tests: true
|
||||
sonic: true
|
||||
- os: macos-13 # beta
|
||||
goarch: amd64
|
||||
psql: true
|
||||
skip_wrapper_tests: true
|
||||
sonic: true
|
||||
sonic: false # Same reason as the arm64 ubuntu-latest runner
|
||||
- os: windows-latest
|
||||
goarch: amd64
|
||||
psql: true
|
||||
@@ -38,7 +38,7 @@ jobs:
|
||||
goarch: amd64
|
||||
psql: true
|
||||
skip_wrapper_tests: false
|
||||
sonic: false
|
||||
sonic: false # Disabled intentionally to test GCT's standard encoding/json implementation
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
|
||||
@@ -117,9 +117,9 @@ jobs:
|
||||
uses: codecov/codecov-action@v5
|
||||
env:
|
||||
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
|
||||
|
||||
backend-arm64:
|
||||
name: GoCryptoTrader back-end (ubuntu-latest, arm64, false, true)
|
||||
|
||||
backend-docker:
|
||||
name: GoCryptoTrader backend docker (ubuntu-latest, amd64, psql=false, skip_wrapper_tests=true, sonic=true)
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
@@ -130,11 +130,6 @@ jobs:
|
||||
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v3
|
||||
with:
|
||||
platforms: linux/arm64
|
||||
|
||||
- name: Set up Docker buildx
|
||||
uses: docker/setup-buildx-action@v3
|
||||
@@ -143,28 +138,27 @@ jobs:
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: /tmp/.docker-buildx-cache
|
||||
key: ${{ runner.os }}-docker-buildx-${{ hashFiles('./.github/workflows/arm64.Dockerfile') }}-${{ github.sha }}
|
||||
key: ${{ runner.os }}-docker-buildx-${{ hashFiles('./.github/workflows/amd64.Dockerfile') }}-${{ github.sha }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-docker-buildx-${{ hashFiles('./.github/workflows/arm64.Dockerfile') }}-
|
||||
${{ runner.os }}-docker-buildx-${{ hashFiles('./.github/workflows/amd64.Dockerfile') }}-
|
||||
${{ runner.os }}-docker-buildx-
|
||||
|
||||
- name: Build Docker image
|
||||
run: |
|
||||
docker buildx build \
|
||||
--load \
|
||||
--platform linux/arm64 \
|
||||
--cache-to=type=local,dest=/tmp/.docker-buildx-cache,mode=max \
|
||||
--cache-from=type=local,src=/tmp/.docker-buildx-cache \
|
||||
--tag gct-backend-arm64 \
|
||||
-f ./.github/workflows/arm64.Dockerfile \
|
||||
--tag gct-backend-amd64 \
|
||||
-f ./.github/workflows/amd64.Dockerfile \
|
||||
.
|
||||
|
||||
- name: Run Docker image
|
||||
run: |
|
||||
docker run --platform linux/arm64 --env SKIP_WRAPPER_CI_TESTS=true --env CI=true --env GCT_DOCKER_CI=true --rm gct-backend-arm64
|
||||
docker run --env SKIP_WRAPPER_CI_TESTS=true --env CI=true --env GCT_DOCKER_CI=true --rm gct-backend-amd64
|
||||
|
||||
frontend:
|
||||
name: GoCryptoTrader front-end
|
||||
name: GoCryptoTrader frontend
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Cancel previous workflow runs
|
||||
|
||||
@@ -124,7 +124,7 @@ mkdir %AppData%\GoCryptoTrader
|
||||
copy config_example.json %APPDATA%\GoCryptoTrader\config.json
|
||||
```
|
||||
|
||||
By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:
|
||||
By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for 32-bit or arm64 architectures. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:
|
||||
|
||||
```bash
|
||||
go build -tags=sonic_off
|
||||
@@ -152,7 +152,7 @@ Binaries will be published once the codebase reaches a stable condition.
|
||||
|User|Contribution Amount|
|
||||
|--|--|
|
||||
| [thrasher-](https://github.com/thrasher-) | 704 |
|
||||
| [shazbert](https://github.com/shazbert) | 359 |
|
||||
| [shazbert](https://github.com/shazbert) | 361 |
|
||||
| [dependabot[bot]](https://github.com/apps/dependabot) | 351 |
|
||||
| [gloriousCode](https://github.com/gloriousCode) | 236 |
|
||||
| [gbjk](https://github.com/gbjk) | 115 |
|
||||
|
||||
@@ -125,7 +125,7 @@ mkdir %AppData%\GoCryptoTrader
|
||||
copy config_example.json %APPDATA%\GoCryptoTrader\config.json
|
||||
```
|
||||
|
||||
By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for a 32-bit architecture (GOARCH=386). To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:
|
||||
By default, GoCryptoTrader uses the [Sonic JSON](https://github.com/bytedance/sonic) library for improved performance unless compiling for 32-bit or arm64 architectures. To disable Sonic and revert to Go's encoding/json, build with the sonic_off tag:
|
||||
|
||||
```bash
|
||||
go build -tags=sonic_off
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// json is an abstraction middleware package to allow switching between json encoder/decoder implementations
|
||||
// The default implementation is sonic.
|
||||
// Build with `sonic_off` or `386` tags to switch to golang.org/encoding/json.
|
||||
// Build with `sonic_off`, '386' or 'arm64' tags to switch to golang.org/encoding/json.
|
||||
package json
|
||||
|
||||
import "encoding/json" //nolint:depguard // Acceptable use in gct json wrapper
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build sonic_off || 386
|
||||
//go:build sonic_off || 386 || arm64
|
||||
|
||||
package json
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
//go:build !sonic_off && !386
|
||||
//go:build !sonic_off && !386 && !arm64
|
||||
|
||||
package json
|
||||
|
||||
|
||||
@@ -2205,8 +2205,7 @@ func TestWsBalanceUpdate(t *testing.T) {
|
||||
"E": 1573200697110,
|
||||
"a": "BTC",
|
||||
"d": "100.00000000",
|
||||
"T": 1573200697068
|
||||
}}`)
|
||||
"T": 1573200697068}}`)
|
||||
err := b.wsHandleData(pressXToJSON)
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
|
||||
@@ -1604,9 +1604,7 @@ var balanceUpdateInputJSON = `
|
||||
"E": 1573200697110,
|
||||
"a": "BTC",
|
||||
"d": "100.00000000",
|
||||
"T": 1573200697068
|
||||
}
|
||||
}`
|
||||
"T": 1573200697068}}`
|
||||
|
||||
func TestWebsocketBalanceUpdate(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -3164,9 +3164,9 @@ var pushDataMap = map[string]string{
|
||||
"Orderbook Snapshot": `{"topic":"orderbook.50.BTCUSDT","ts":1731035685326,"type":"snapshot","data":{"s":"BTCUSDT","b":[["75848.74","0.067669"],["75848.63","0.004772"],["75848.61","0.00659"],["75848.05","0.000329"],["75847.68","0.00159"],["75846.88","0.00159"],["75845.97","0.026366"],["75845.87","0.013185"],["75845.41","0.077259"],["75845.4","0.132228"],["75844.61","0.00159"],["75844.44","0.026367"],["75844.2","0.013185"],["75844","0.00039"],["75843.13","0.00159"],["75843.07","0.013185"],["75842.33","0.00159"],["75841.99","0.006"],["75841.75","0.019538"],["75841.74","0.04"],["75841.71","0.031817"],["75841.36","0.017336"],["75841.33","0.000072"],["75841.16","0.001872"],["75841.11","0.172641"],["75841.04","0.029772"],["75841","0.000065"],["75840.93","0.015244"],["75840.86","0.00159"],["75840.79","0.000072"],["75840.38","0.043333"],["75840.32","0.092539"],["75840.3","0.132228"],["75840.2","0.054966"],["75840.06","0.00159"],["75840","0.20726"],["75839.64","0.003744"],["75839.29","0.006592"],["75838.58","0.00159"],["75838.52","0.049778"],["75838.14","0.003955"],["75838","0.000065"],["75837.78","0.00159"],["75837.75","0.000587"],["75837.53","0.322245"],["75837.52","0.593323"],["75837.37","0.00384"],["75837.29","0.044335"],["75837.24","0.119228"],["75837.13","0.152844"]],"a":[["75848.75","0.747137"],["75848.89","0.060306"],["75848.9","0.1"],["75851.43","0.00159"],["75851.44","0.080754"],["75852.23","0.00159"],["75852.54","0.131067"],["75852.65","0.003955"],["75853.71","0.00159"],["75853.86","0.003955"],["75854.43","0.015684"],["75854.5","0.130389"],["75854.51","0.00159"],["75855.21","0.031168"],["75855.23","0.271494"],["75855.73","0.042698"],["75855.98","0.00159"],["75856.04","0.01346"],["75856.33","0.001872"],["75856.78","0.00159"],["75857.15","0.000072"],["75857.17","0.015127"],["75857.8","0.043322"],["75857.81","0.045305"],["75857.85","0.003792"],["75858.09","0.026344"],["75858.26","0.00159"],["75859.06","0.031618"],["75859.07","0.025"],["75859.1","0.006592"],["75859.98","0.013183"],["75860.12","0.00384"],["75860.54","0.00159"],["75860.74","0.051204"],["75860.75","0.065861"],["75861.18","0.031222"],["75861.33","0.00159"],["75861.64","0.003888"],["75861.96","0.042213"],["75862.28","0.000777"],["75862.79","0.013184"],["75862.81","0.00159"],["75862.84","0.027959"],["75863.16","0.003888"],["75863.51","0.043628"],["75863.52","0.002525"],["75863.61","0.00159"],["75864.2","0.003955"],["75864.76","0.000072"],["75864.81","0.002018"]],"u":2876700,"seq":47474967795},"cts":1731035685323}`,
|
||||
"Orderbook Update": `{"topic":"orderbook.50.BTCUSDT","ts":1731035685345,"type":"delta","data":{"s":"BTCUSDT","b":[["75848.62","0.014895"],["75837.13","0"]],"a":[["75848.89","0.088149"],["75851.44","0.078379"],["75852.65","0"],["75855.23","0.260219"],["75857.74","0.049778"]],"u":2876701,"seq":47474967823},"cts":1731035685342}`,
|
||||
"Public Trade": `{"topic":"publicTrade.BTCUSDT","ts":1690720953113,"type":"snapshot","data":[{"i":"2200000000067341890","T":1690720953111,"p":"3.6279","v":"1.3637","S":"Sell","s":"BTCUSDT","BT":false}]}`,
|
||||
"Public Kline": `{ "topic": "kline.5.BTCUSDT", "data": [ { "start": 1672324800000, "end": 1672325099999, "interval": "5", "open": "16649.5", "close": "16677", "high": "16677", "low": "16608", "volume": "2.081", "turnover": "34666.4005", "confirm": false, "timestamp": 1672324988882 } ], "ts": 1672324988882,"type": "snapshot"}`,
|
||||
"Public Liquidiation": `{ "data": { "price": "0.03803", "side": "Buy", "size": "1637", "symbol": "GALAUSDT", "updatedTime": 1673251091822 }, "topic": "liquidation.GALAUSDT", "ts": 1673251091822, "type": "snapshot" }`,
|
||||
"Public LT Kline": `{ "type": "snapshot", "topic": "kline_lt.5.BTCUSDT", "data": [ { "start": 1672325100000, "end": 1672325399999, "interval": "5", "open": "0.416039541212402799", "close": "0.41477848043290448", "high": "0.416039541212402799", "low": "0.409734237314911206", "confirm": false, "timestamp": 1672325322393 } ], "ts": 1672325322393 }`,
|
||||
"Public Kline": `{ "topic": "kline.5.BTCUSDT", "data": [ { "start": 1672324800000, "end": 1672325099999, "interval": "5", "open": "16649.5", "close": "16677", "high": "16677", "low": "16608", "volume": "2.081", "turnover": "34666.4005", "confirm": false, "timestamp": 1672324988882} ], "ts": 1672324988882,"type": "snapshot"}`,
|
||||
"Public Liquidiation": `{ "data": { "price": "0.03803", "side": "Buy", "size": "1637", "symbol": "GALAUSDT", "updatedTime": 1673251091822}, "topic": "liquidation.GALAUSDT", "ts": 1673251091822, "type": "snapshot" }`,
|
||||
"Public LT Kline": `{ "type": "snapshot", "topic": "kline_lt.5.BTCUSDT", "data": [ { "start": 1672325100000, "end": 1672325399999, "interval": "5", "open": "0.416039541212402799", "close": "0.41477848043290448", "high": "0.416039541212402799", "low": "0.409734237314911206", "confirm": false, "timestamp": 1672325322393} ], "ts": 1672325322393}`,
|
||||
"Public LT Ticker": `{ "topic": "tickers_lt.BTCUSDT", "ts": 1672325446847, "type": "snapshot", "data": { "symbol": "BTCUSDT", "lastPrice": "0.41477848043290448", "highPrice24h": "0.435285472510871305", "lowPrice24h": "0.394601507960931382", "prevPrice24h": "0.431502290172376349", "price24hPcnt": "-0.0388" } }`,
|
||||
"Public LT Navigation": `{ "topic": "lt.EOS3LUSDT", "ts": 1672325564669, "type": "snapshot", "data": { "symbol": "BTCUSDT", "time": 1672325564554, "nav": "0.413517419653406162", "basketPosition": "1.261060779498318641", "leverage": "2.656197506416192150", "basketLoan": "-0.684866519289629374", "circulation": "72767.309468460367138199", "basket": "91764.000000292013277472" } }`,
|
||||
"Private Position": `{"id": "59232430b58efe-5fc5-4470-9337-4ce293b68edd", "topic": "position", "creationTime": 1672364174455, "data": [ { "positionIdx": 0, "tradeMode": 0, "riskId": 41, "riskLimitValue": "200000", "symbol": "XRPUSDT", "side": "Buy", "size": "75", "entryPrice": "0.3615", "leverage": "10", "positionValue": "27.1125", "positionBalance": "0", "markPrice": "0.3374", "positionIM": "2.72589075", "positionMM": "0.28576575", "takeProfit": "0", "stopLoss": "0", "trailingStop": "0", "unrealisedPnl": "-1.8075", "cumRealisedPnl": "0.64782276", "createdTime": "1672121182216", "updatedTime": "1672364174449", "tpslMode": "Full", "liqPrice": "", "bustPrice": "", "category": "linear","positionStatus":"Normal","adlRankIndicator":2}]}`,
|
||||
|
||||
@@ -941,7 +941,7 @@ func TestWSCancelTransferByID(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
|
||||
const getTransferResponseJSON = `{"count": 2, "data":[{"amount": 0.2, "created_timestamp": 1550579457727, "currency": "BTC", "direction": "payment", "id": 2, "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy", "state": "prepared", "type": "user", "updated_timestamp": 1550579457727 }, { "amount": 0.3, "created_timestamp": 1550579255800, "currency": "BTC", "direction": "payment", "id": 1, "other_side": "new_user_1_1", "state": "confirmed", "type": "subaccount", "updated_timestamp": 1550579255800 } ] }`
|
||||
const getTransferResponseJSON = `{"count": 2, "data":[{"amount": 0.2, "created_timestamp": 1550579457727, "currency": "BTC", "direction": "payment", "id": 2, "other_side": "2MzyQc5Tkik61kJbEpJV5D5H9VfWHZK9Sgy", "state": "prepared", "type": "user", "updated_timestamp": 1550579457727}, { "amount": 0.3, "created_timestamp": 1550579255800, "currency": "BTC", "direction": "payment", "id": 1, "other_side": "new_user_1_1", "state": "confirmed", "type": "subaccount", "updated_timestamp": 1550579255800} ] }`
|
||||
|
||||
func TestGetTransfers(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -968,7 +968,7 @@ func TestWSRetrieveTransfers(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
|
||||
const cancelWithdrawlPushDataJSON = `{"address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.5, "confirmed_timestamp": null, "created_timestamp": 1550571443070, "currency": "BTC", "fee": 0.0001, "id": 1, "priority": 0.15, "state": "cancelled", "transaction_id": null, "updated_timestamp": 1550571443070 }`
|
||||
const cancelWithdrawlPushDataJSON = `{"address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.5, "confirmed_timestamp": null, "created_timestamp": 1550571443070, "currency": "BTC", "fee": 0.0001, "id": 1, "priority": 0.15, "state": "cancelled", "transaction_id": null, "updated_timestamp": 1550571443070}`
|
||||
|
||||
func TestCancelWithdrawal(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -1043,7 +1043,7 @@ func TestWSRetrieveCurrentDepositAddress(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
|
||||
const getDepositPushDataJSON = `{"count": 1, "data": [ { "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", "amount": 5, "currency": "BTC", "received_timestamp": 1549295017670, "state": "completed", "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", "updated_timestamp": 1549295130159 } ] }`
|
||||
const getDepositPushDataJSON = `{"count": 1, "data": [ { "address": "2N35qDKDY22zmJq9eSyiAerMD4enJ1xx6ax", "amount": 5, "currency": "BTC", "received_timestamp": 1549295017670, "state": "completed", "transaction_id": "230669110fdaf0a0dbcdc079b6b8b43d5af29cc73683835b9bc6b3406c065fda", "updated_timestamp": 1549295130159} ] }`
|
||||
|
||||
func TestGetDeposits(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -1070,7 +1070,7 @@ func TestWSRetrieveDeposits(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
|
||||
const getWithdrawalResponseJSON = `{"count": 1, "data": [ { "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.5, "confirmed_timestamp": null, "created_timestamp": 1550571443070, "currency": "BTC", "fee": 0.0001, "id": 1, "priority": 0.15, "state": "unconfirmed", "transaction_id": null, "updated_timestamp": 1550571443070 } ] }`
|
||||
const getWithdrawalResponseJSON = `{"count": 1, "data": [ { "address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.5, "confirmed_timestamp": null, "created_timestamp": 1550571443070, "currency": "BTC", "fee": 0.0001, "id": 1, "priority": 0.15, "state": "unconfirmed", "transaction_id": null, "updated_timestamp": 1550571443070} ] }`
|
||||
|
||||
func TestGetWithdrawals(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -1187,7 +1187,7 @@ func TestWSSubmitTransferToUser(t *testing.T) {
|
||||
assert.NotNil(t, result)
|
||||
}
|
||||
|
||||
const submitWithdrawalResponseJSON = `{"address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.4, "confirmed_timestamp": null, "created_timestamp": 1550574558607, "currency": "BTC", "fee": 0.0001, "id": 4, "priority": 1, "state": "unconfirmed", "transaction_id": null, "updated_timestamp": 1550574558607 }`
|
||||
const submitWithdrawalResponseJSON = `{"address": "2NBqqD5GRJ8wHy1PYyCXTe9ke5226FhavBz", "amount": 0.4, "confirmed_timestamp": null, "created_timestamp": 1550574558607, "currency": "BTC", "fee": 0.0001, "id": 4, "priority": 1, "state": "unconfirmed", "transaction_id": null, "updated_timestamp": 1550574558607}`
|
||||
|
||||
func TestSubmitWithdraw(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2658,7 +2658,7 @@ func TestOptionsUnderlyingTradesPushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsUnderlyingPricePushDataJSON = `{ "time": 1630576356, "channel": "options.ul_price", "event": "update", "result": { "underlying": "BTC_USDT", "price": 49653.24,"time": 1639143988,"time_ms": 1639143988931 }}`
|
||||
const optionsUnderlyingPricePushDataJSON = `{ "time": 1630576356, "channel": "options.ul_price", "event": "update", "result": { "underlying": "BTC_USDT", "price": 49653.24,"time": 1639143988,"time_ms": 1639143988931}}`
|
||||
|
||||
func TestOptionsUnderlyingPricePushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -2667,7 +2667,7 @@ func TestOptionsUnderlyingPricePushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsMarkPricePushDataJSON = `{ "time": 1630576356, "channel": "options.mark_price", "event": "update", "result": { "contract": "BTC_USDT-20211231-59800-P", "price": 11021.27, "time": 1639143401, "time_ms": 1639143401676 }}`
|
||||
const optionsMarkPricePushDataJSON = `{ "time": 1630576356, "channel": "options.mark_price", "event": "update", "result": { "contract": "BTC_USDT-20211231-59800-P", "price": 11021.27, "time": 1639143401, "time_ms": 1639143401676}}`
|
||||
|
||||
func TestOptionsMarkPricePushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -2676,7 +2676,7 @@ func TestOptionsMarkPricePushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsSettlementsPushDataJSON = `{ "time": 1630576356, "channel": "options.settlements", "event": "update", "result": { "contract": "BTC_USDT-20211130-55000-P", "orderbook_id": 2, "position_size": 1, "profit": 0.5, "settle_price": 70000, "strike_price": 65000, "tag": "WEEK", "trade_id": 1, "trade_size": 1, "underlying": "BTC_USDT", "time": 1639051907, "time_ms": 1639051907000 }}`
|
||||
const optionsSettlementsPushDataJSON = `{ "time": 1630576356, "channel": "options.settlements", "event": "update", "result": { "contract": "BTC_USDT-20211130-55000-P", "orderbook_id": 2, "position_size": 1, "profit": 0.5, "settle_price": 70000, "strike_price": 65000, "tag": "WEEK", "trade_id": 1, "trade_size": 1, "underlying": "BTC_USDT", "time": 1639051907, "time_ms": 1639051907000}}`
|
||||
|
||||
func TestSettlementsPushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -2685,7 +2685,7 @@ func TestSettlementsPushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsContractPushDataJSON = `{"time": 1630576356, "channel": "options.contracts", "event": "update", "result": { "contract": "BTC_USDT-20211130-50000-P", "create_time": 1637917026, "expiration_time": 1638230400, "init_margin_high": 0.15, "init_margin_low": 0.1, "is_call": false, "maint_margin_base": 0.075, "maker_fee_rate": 0.0004, "mark_price_round": 0.1, "min_balance_short": 0.5, "min_order_margin": 0.1, "multiplier": 0.0001, "order_price_deviate": 0, "order_price_round": 0.1, "order_size_max": 1, "order_size_min": 10, "orders_limit": 100000, "ref_discount_rate": 0.1, "ref_rebate_rate": 0, "strike_price": 50000, "tag": "WEEK", "taker_fee_rate": 0.0004, "underlying": "BTC_USDT", "time": 1639051907, "time_ms": 1639051907000 }}`
|
||||
const optionsContractPushDataJSON = `{"time": 1630576356, "channel": "options.contracts", "event": "update", "result": { "contract": "BTC_USDT-20211130-50000-P", "create_time": 1637917026, "expiration_time": 1638230400, "init_margin_high": 0.15, "init_margin_low": 0.1, "is_call": false, "maint_margin_base": 0.075, "maker_fee_rate": 0.0004, "mark_price_round": 0.1, "min_balance_short": 0.5, "min_order_margin": 0.1, "multiplier": 0.0001, "order_price_deviate": 0, "order_price_round": 0.1, "order_size_max": 1, "order_size_min": 10, "orders_limit": 100000, "ref_discount_rate": 0.1, "ref_rebate_rate": 0, "strike_price": 50000, "tag": "WEEK", "taker_fee_rate": 0.0004, "underlying": "BTC_USDT", "time": 1639051907, "time_ms": 1639051907000}}`
|
||||
|
||||
func TestOptionsContractPushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -2745,7 +2745,7 @@ func TestOptionUserTradesPushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsLiquidatesPushDataJSON = `{ "channel": "options.liquidates", "event": "update", "time": 1630654851, "result": [ { "user": "1xxxx", "init_margin": 1190, "maint_margin": 1042.5, "order_margin": 0, "time": 1639051907, "time_ms": 1639051907000 } ]}`
|
||||
const optionsLiquidatesPushDataJSON = `{ "channel": "options.liquidates", "event": "update", "time": 1630654851, "result": [ { "user": "1xxxx", "init_margin": 1190, "maint_margin": 1042.5, "order_margin": 0, "time": 1639051907, "time_ms": 1639051907000} ]}`
|
||||
|
||||
func TestOptionsLiquidatesPushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
@@ -2781,7 +2781,7 @@ func TestOptionsBalancePushData(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
const optionsPositionPushDataJSON = `{"time": 1630654851, "channel": "options.positions", "event": "update", "error": null, "result": [ { "entry_price": 0, "realised_pnl": -13.028, "size": 0, "contract": "BTC_USDT-20211130-65000-C", "user": "9010", "time": 1639051907, "time_ms": 1639051907000 } ]}`
|
||||
const optionsPositionPushDataJSON = `{"time": 1630654851, "channel": "options.positions", "event": "update", "error": null, "result": [ { "entry_price": 0, "realised_pnl": -13.028, "size": 0, "contract": "BTC_USDT-20211130-65000-C", "user": "9010", "time": 1639051907, "time_ms": 1639051907000} ]}`
|
||||
|
||||
func TestOptionsPositionPushData(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2690,8 +2690,8 @@ func TestCancelAllOrders(t *testing.T) {
|
||||
|
||||
const (
|
||||
subUserResponseJSON = `{"userId":"635002438793b80001dcc8b3", "uid":62356, "subName":"margin01", "status":2, "type":4, "access":"Margin", "createdAt":1666187844000, "remarks":null }`
|
||||
transferFuturesFundsResponseJSON = `{"applyId": "620a0bbefeaa6a000110e833", "bizNo": "620a0bbefeaa6a000110e832", "payAccountType": "CONTRACT", "payTag": "DEFAULT", "remark": "", "recAccountType": "MAIN", "recTag": "DEFAULT", "recRemark": "", "recSystem": "KUCOIN", "status": "PROCESSING", "currency": "USDT", "amount": "0.001", "fee": "0", "sn": 889048787670001, "reason": "", "createdAt": 1644825534000, "updatedAt": 1644825534000 }`
|
||||
modifySubAccountSpotAPIs = `{"subName": "AAAAAAAAAA0007", "remark": "remark", "apiKey": "630325e0e750870001829864", "apiSecret": "110f31fc-61c5-4baf-a29f-3f19a62bbf5d", "passphrase": "passphrase", "permission": "General", "ipWhitelist": "", "createdAt": 1661150688000 }`
|
||||
transferFuturesFundsResponseJSON = `{"applyId": "620a0bbefeaa6a000110e833", "bizNo": "620a0bbefeaa6a000110e832", "payAccountType": "CONTRACT", "payTag": "DEFAULT", "remark": "", "recAccountType": "MAIN", "recTag": "DEFAULT", "recRemark": "", "recSystem": "KUCOIN", "status": "PROCESSING", "currency": "USDT", "amount": "0.001", "fee": "0", "sn": 889048787670001, "reason": "", "createdAt": 1644825534000, "updatedAt": 1644825534000}`
|
||||
modifySubAccountSpotAPIs = `{"subName": "AAAAAAAAAA0007", "remark": "remark", "apiKey": "630325e0e750870001829864", "apiSecret": "110f31fc-61c5-4baf-a29f-3f19a62bbf5d", "passphrase": "passphrase", "permission": "General", "ipWhitelist": "", "createdAt": 1661150688000}`
|
||||
)
|
||||
|
||||
func TestCreateSubUser(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user