c9s / bbgo

The modern cryptocurrency trading bot framework written in Go.
https://bbgo.finance
GNU Affero General Public License v3.0
1.18k stars 283 forks source link

FIX: [bitget] use new size instead of size #1542

Closed bailantaotao closed 6 months ago

bailantaotao commented 6 months ago

Bitget API changelog

https://www.bitget.com/api-doc/common/changelog The spot order channel push now includes a new parameter newSize, which will gradually replace the existing parameter size in subsequent updates.

newSize represents the order quantity, following the specified rules:

when orderType=limit, newSize represents the quantity of base coin, when orderType=market and side=buy, newSize represents the quantity of quote coin, when orderType=market and side=sell, newSize represents the quantity of base coin

Unexpected Size field

The size filed is unexpected on limit buy order. it represents the *size volume**. This is different from what was previously tested.

The order placed a limit buy at price 1.6 and size 5.6756, but the websocket returned size 9.0809.

[{"instId":"APEUSDT","orderId":"1144801703390253056","clientOid":"8d9160a6-69a6-46e6-b6bf-41f77a869c7e","price":"1.6000","size":"9.0809","newSize":"5.6756","notional":"9.080960","orderType":"limit","force":"gtc","side":"buy","accBaseVolume":"0.0000","priceAvg":"0.0000","status":"live","cTime":"1708667916152","uTime":"1708667916152","feeDetail":[],"enterPointSource":"WEB"}]

The raw data above is displayed in the web console.

image

Other data filed in size and newSize is expected.

when orderType=limit, and side = sell, newSize and size represents the quantity of base coin,

[{"instId":"APEUSDT","orderId":"1144800668517044224","clientOid":"b540604a-21a3-40d6-9655-ee42e2db41f7","price":"1.6800","size":"3.3000","newSize":"3.3000","orderType":"limit","force":"gtc","side":"sell","accBaseVolume":"0.0000","priceAvg":"0.0000","status":"cancelled","cTime":"1708667669419","uTime":"1708667676652","feeDetail":[],"enterPointSource":"WEB"}]

when orderType=market and side=buy, newSize and size represents the quantity of quote coin,

[{"instId":"APEUSDT","orderId":"1144800468134170630","clientOid":"d0f595a1-482f-46f6-8bac-02b88052b5f1","size":"5.5000","newSize":"5.5000","notional":"5.500000","orderType":"market","force":"gtc","side":"buy","accBaseVolume":"0.0000","priceAvg":"0.0000","status":"live","cTime":"1708667621644","uTime":"1708667621644","feeDetail":[],"enterPointSource":"WEB"}]

when orderType=market and side=sell, newSize and size represents the quantity of base coin

[{"instId":"APEUSDT","orderId":"1144800723705696258","clientOid":"5bbf35af-c8e6-491b-ac38-55f2ee9e1e70","size":"3.3114","newSize":"3.3114","orderType":"market","force":"gtc","side":"sell","accBaseVolume":"0.0000","priceAvg":"0.0000","status":"live","cTime":"1708667682577","uTime":"1708667682577","feeDetail":[],"enterPointSource":"WEB"}]
bbgokarma-bot commented 6 months ago

Welcome back! @bailantaotao, This pull request may get 218 BBG.

codecov[bot] commented 6 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 21.77%. Comparing base (06c533f) to head (5c75095).

Additional details and impacted files [![Impacted file tree graph](https://app.codecov.io/gh/c9s/bbgo/pull/1542/graphs/tree.svg?width=650&height=150&src=pr&token=ZT7I56OV8K&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin)](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin) ```diff @@ Coverage Diff @@ ## main #1542 +/- ## ======================================= Coverage 21.77% 21.77% ======================================= Files 606 606 Lines 43940 43940 ======================================= Hits 9566 9566 Misses 33692 33692 Partials 682 682 ``` | [Files](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin) | Coverage Δ | | |---|---|---| | [pkg/exchange/bitget/convert.go](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin#diff-cGtnL2V4Y2hhbmdlL2JpdGdldC9jb252ZXJ0Lmdv) | `91.73% <100.00%> (ø)` | | | [pkg/exchange/bitget/types.go](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin#diff-cGtnL2V4Y2hhbmdlL2JpdGdldC90eXBlcy5nbw==) | `51.64% <ø> (ø)` | | ------ [Continue to review full report in Codecov by Sentry](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin). > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin) > `Δ = absolute (impact)`, `ø = not affected`, `? = missing data` > Powered by [Codecov](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin). Last update [06c533f...5c75095](https://app.codecov.io/gh/c9s/bbgo/pull/1542?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Yo-An+Lin).
bbgokarma-bot commented 6 months ago

Hi @bailantaotao,

Well done! 228 BBG has been sent to your polygon wallet. Please check the following tx:

https://polygonscan.com/tx/0xb79f4da8870061f88a77a73155460369d21b8c944880918fbe992ccf48391581

Thank you for your contribution!