Skip to content

Commit b34968f

Browse files
author
Ryan O'Hara-Reid
committed
bitget_api_creation: thrasher-corp#1844
1 parent 10585fd commit b34968f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+17599
-96
lines changed

CONTRIBUTORS

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ MadCozBadd | https://github.com/MadCozBadd
1818
Copilot | https://github.com/apps/copilot-swe-agent
1919
vadimzhukck | https://github.com/vadimzhukck
2020
junnplus | https://github.com/junnplus
21-
geseq | https://github.com/geseq
22-
marcofranssen | https://github.com/marcofranssen
2321
140am | https://github.com/140am
2422
cranktakular | https://github.com/cranktakular
2523
TaltaM | https://github.com/TaltaM
@@ -40,9 +38,6 @@ mshogin | https://github.com/mshogin
4038
andreygrehov | https://github.com/andreygrehov
4139
bretep | https://github.com/bretep
4240
Christian-Achilli | https://github.com/Christian-Achilli
43-
dsinuela-taurus | https://github.com/dsinuela-taurus
44-
cornelk | https://github.com/cornelk
45-
gam-phon | https://github.com/gam-phon
4641
MarkDzulko | https://github.com/MarkDzulko
4742
MathieuCesbron | https://github.com/MathieuCesbron
4843
aidan-bailey | https://github.com/aidan-bailey

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
2020
|----------|------|-----------|-----|
2121
| Binance.US| Yes | Yes | NA |
2222
| Binance| Yes | Yes | NA |
23+
| Bitget | Yes | Yes | NA |
2324
| Bitfinex | Yes | Yes | NA |
2425
| Bitflyer | Yes | No | NA |
2526
| Bithumb | Yes | Yes | NA |
@@ -167,8 +168,6 @@ Binaries will be published once the codebase reaches a stable condition.
167168
| [Copilot](https://github.com/apps/copilot-swe-agent) | 13 |
168169
| [vadimzhukck](https://github.com/vadimzhukck) | 10 |
169170
| [junnplus](https://github.com/junnplus) | 9 |
170-
| [geseq](https://github.com/geseq) | 8 |
171-
| [marcofranssen](https://github.com/marcofranssen) | 8 |
172171
| [140am](https://github.com/140am) | 8 |
173172
| [cranktakular](https://github.com/cranktakular) | 7 |
174173
| [TaltaM](https://github.com/TaltaM) | 6 |
@@ -189,9 +188,6 @@ Binaries will be published once the codebase reaches a stable condition.
189188
| [andreygrehov](https://github.com/andreygrehov) | 2 |
190189
| [bretep](https://github.com/bretep) | 2 |
191190
| [Christian-Achilli](https://github.com/Christian-Achilli) | 2 |
192-
| [dsinuela-taurus](https://github.com/dsinuela-taurus) | 2 |
193-
| [cornelk](https://github.com/cornelk) | 2 |
194-
| [gam-phon](https://github.com/gam-phon) | 2 |
195191
| [MarkDzulko](https://github.com/MarkDzulko) | 2 |
196192
| [MathieuCesbron](https://github.com/MathieuCesbron) | 2 |
197193
| [aidan-bailey](https://github.com/aidan-bailey) | 1 |
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
{{define "exchanges bitget" -}}
2+
{{template "header" .}}
3+
## Bitget Exchange
4+
5+
### Current Features
6+
7+
+ REST Support
8+
+ Websocket Support
9+
10+
### How to enable
11+
12+
+ [Enable via configuration](https://github.com/thrasher-corp/gocryptotrader/tree/master/config#enable-exchange-via-config-example)
13+
14+
+ Individual package example below:
15+
16+
```go
17+
// Exchanges will be abstracted out in further updates and examples will be
18+
// supplied then
19+
```
20+
21+
### How to do REST public/private calls
22+
23+
+ If enabled via "configuration".json file the exchange will be added to the
24+
IBotExchange array in the ```go var bot Bot``` and you will only be able to use
25+
the wrapper interface functions for accessing exchange data. View routines.go
26+
for an example of integration usage with GoCryptoTrader. Rudimentary example
27+
below:
28+
29+
main.go
30+
```go
31+
var b exchange.IBotExchange
32+
33+
for i := range bot.Exchanges {
34+
if bot.Exchanges[i].GetName() == "Bitget" {
35+
b = bot.Exchanges[i]
36+
}
37+
}
38+
39+
// Public calls - wrapper functions
40+
41+
// Fetches current ticker information
42+
tick, err := e.UpdateTicker(...)
43+
if err != nil {
44+
// Handle error
45+
}
46+
47+
// Fetches current orderbook information
48+
ob, err := e.UpdateOrderbook(...)
49+
if err != nil {
50+
// Handle error
51+
}
52+
53+
// Private calls - wrapper functions - make sure your APIKEY, APISECRET, and
54+
// CLIENTID are set and AuthenticatedAPISupport is set to true
55+
56+
// Fetches current account information
57+
accountInfo, err := e.GetAccountInfo()
58+
if err != nil {
59+
// Handle error
60+
}
61+
```
62+
63+
+ If enabled via individually importing package, rudimentary example below:
64+
65+
```go
66+
// Public calls
67+
68+
// Fetches current ticker information
69+
ticker, err := e.GetTicker()
70+
if err != nil {
71+
// Handle error
72+
}
73+
74+
// Fetches current orderbook information
75+
ob, err := e.GetOrderBook()
76+
if err != nil {
77+
// Handle error
78+
}
79+
80+
// Private calls - make sure your APIKEY, APISECRET, and CLIENTID are set
81+
// and AuthenticatedAPISupport is set to true
82+
83+
// GetUserInfo returns account info
84+
accountInfo, err := e.GetUserInfo(...)
85+
if err != nil {
86+
// Handle error
87+
}
88+
89+
// Submits an order and the exchange and returns its tradeID
90+
tradeID, err := e.Trade(...)
91+
if err != nil {
92+
// Handle error
93+
}
94+
```
95+
96+
### How to do Websocket public/private calls
97+
98+
```go
99+
// Exchanges will be abstracted out in further updates and examples will be
100+
// supplied then
101+
```
102+
103+
{{template "donations" .}}
104+
{{end}}

cmd/documentation/root_templates/root_readme.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Join our slack to discuss all things related to GoCryptoTrader! [GoCryptoTrader
2121
|----------|------|-----------|-----|
2222
| Binance.US| Yes | Yes | NA |
2323
| Binance| Yes | Yes | NA |
24+
| Bitget | Yes | Yes | NA |
2425
| Bitfinex | Yes | Yes | NA |
2526
| Bitflyer | Yes | No | NA |
2627
| Bithumb | Yes | Yes | NA |

cmd/exchange_wrapper_issues/main.go

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -912,24 +912,6 @@ func testWrappers(e exchange.IBotExchange, base *exchange.Base, cfg *Config) []E
912912
Response: marginRateHistoryResponse,
913913
})
914914

915-
positionSummaryRequest := &futures.PositionSummaryRequest{
916-
Asset: assetTypes[i],
917-
Pair: p,
918-
}
919-
var positionSummaryResponse *futures.PositionSummary
920-
positionSummaryResponse, err = e.GetPositionSummary(context.TODO(), positionSummaryRequest)
921-
msg = ""
922-
if err != nil {
923-
msg = err.Error()
924-
responseContainer.ErrorCount++
925-
}
926-
responseContainer.EndpointResponses = append(responseContainer.EndpointResponses, EndpointResponse{
927-
SentParams: jsonifyInterface([]any{positionSummaryRequest}),
928-
Function: "GetFuturesPositionSummary",
929-
Error: msg,
930-
Response: jsonifyInterface([]any{positionSummaryResponse}),
931-
})
932-
933915
calculatePNLRequest := &futures.PNLCalculatorRequest{
934916
Pair: p,
935917
Underlying: p.Base,

cmd/exchange_wrapper_standards/exchange_wrapper_standards_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ func generateMethodArg(ctx context.Context, t *testing.T, argGenerator *MethodAr
460460
ClientOrderID: "13371337",
461461
TimeInForce: order.ImmediateOrCancel,
462462
Leverage: 1,
463+
MarginType: margin.Isolated,
463464
})
464465
case argGenerator.MethodInputType.AssignableTo(orderModifyParam):
465466
input = reflect.ValueOf(&order.Modify{
@@ -473,6 +474,7 @@ func generateMethodArg(ctx context.Context, t *testing.T, argGenerator *MethodAr
473474
ClientOrderID: "13371337",
474475
OrderID: "1337",
475476
TimeInForce: order.ImmediateOrCancel,
477+
TriggerPrice: 149,
476478
})
477479
case argGenerator.MethodInputType.AssignableTo(orderCancelParam):
478480
input = reflect.ValueOf(&order.Cancel{
@@ -587,7 +589,6 @@ var excludedMethodNames = map[string]struct{}{
587589
"CalculatePNL": {},
588590
"CalculateTotalCollateral": {},
589591
"ScaleCollateral": {},
590-
"GetPositionSummary": {},
591592
"GetFuturesPositionSummary": {},
592593
"GetFuturesPositionOrders": {},
593594
"SetCollateralMode": {},

common/common.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ var (
5050
_HTTPClient *http.Client
5151
_HTTPUserAgent string
5252
m sync.RWMutex
53-
zeroValueUnix = time.Unix(0, 0)
53+
ZeroValueUnix = time.Unix(0, 0)
5454
)
5555

5656
// Public common Errors
@@ -586,10 +586,10 @@ func (e *ErrorCollector) Go(f func() error) {
586586
// StartEndTimeCheck provides some basic checks which occur
587587
// frequently in the codebase
588588
func StartEndTimeCheck(start, end time.Time) error {
589-
if start.IsZero() || start.Equal(zeroValueUnix) {
589+
if start.IsZero() || start.Equal(ZeroValueUnix) {
590590
return fmt.Errorf("start %w", ErrDateUnset)
591591
}
592-
if end.IsZero() || end.Equal(zeroValueUnix) {
592+
if end.IsZero() || end.Equal(ZeroValueUnix) {
593593
return fmt.Errorf("end %w", ErrDateUnset)
594594
}
595595
if start.After(end) {

common/common_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,10 +498,10 @@ func TestParseStartEndDate(t *testing.T) {
498498
err = StartEndTimeCheck(et, nt)
499499
assert.ErrorIs(t, err, ErrDateUnset)
500500

501-
err = StartEndTimeCheck(et, zeroValueUnix)
501+
err = StartEndTimeCheck(et, ZeroValueUnix)
502502
assert.ErrorIs(t, err, ErrDateUnset)
503503

504-
err = StartEndTimeCheck(zeroValueUnix, et)
504+
err = StartEndTimeCheck(ZeroValueUnix, et)
505505
assert.ErrorIs(t, err, ErrDateUnset)
506506

507507
err = StartEndTimeCheck(et, et)

config/config.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,14 @@ import (
3030
"github.com/thrasher-corp/gocryptotrader/portfolio/banking"
3131
)
3232

33+
// Public errors
3334
var (
34-
errExchangeConfigIsNil = errors.New("exchange config is nil")
35-
errPairsManagerIsNil = errors.New("currency pairs manager is nil")
36-
errDecryptFailed = errors.New("failed to decrypt config after 3 attempts")
35+
ErrExchangeConfigIsNil = errors.New("exchange config is nil")
36+
)
37+
38+
var (
39+
errPairsManagerIsNil = errors.New("currency pairs manager is nil")
40+
errDecryptFailed = errors.New("failed to decrypt config after 3 attempts")
3741
)
3842

3943
// GetCurrencyConfig returns currency configurations
@@ -1734,7 +1738,7 @@ func (c *Config) GetDataPath(elem ...string) string {
17341738
// Validate checks if exchange config is valid
17351739
func (c *Exchange) Validate() error {
17361740
if c == nil {
1737-
return errExchangeConfigIsNil
1741+
return ErrExchangeConfigIsNil
17381742
}
17391743

17401744
if c.ConnectionMonitorDelay <= 0 {

config/config_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ func TestMigrateConfig(t *testing.T) {
19861986

19871987
func TestExchangeConfigValidate(t *testing.T) {
19881988
err := (*Exchange)(nil).Validate()
1989-
require.ErrorIs(t, err, errExchangeConfigIsNil)
1989+
require.ErrorIs(t, err, ErrExchangeConfigIsNil)
19901990

19911991
err = (&Exchange{}).Validate()
19921992
require.NoError(t, err)

0 commit comments

Comments
 (0)