Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes, ReplaceStopOrder, FullUrl, Deprecated endpoints #7

Merged
merged 36 commits into from Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
fd08b4e
Added ReplaceStopOrder, and fixes.
Nov 4, 2020
7d11ff5
Fixes.
Nov 5, 2020
c38bb07
Adding funding api.
Nov 11, 2020
435a349
Adding getting conditional orders.
Nov 11, 2020
99279e4
Adding limit to get funding.
Nov 11, 2020
baa1d74
Adding limit to get funding.
Nov 12, 2020
4499f9e
Update for the RestAPI update. https://bybit-exchange.github.io/docs/…
Nov 17, 2020
47e734e
Merge remote-tracking branch 'fork/master'
Nov 17, 2020
e8f5092
Review bybit new news about depreacted endpoints and make sure it wor…
Nov 21, 2020
18f1a25
Added fullURL to be returned for better logging.
Nov 25, 2020
b39e527
Added stop order status.
Nov 25, 2020
e6c21a5
Added StopPx.
Nov 27, 2020
15b6bac
Fix with the new tickers without funding.
Nov 28, 2020
3f7871e
NextFundingTime as string.
Dec 6, 2020
f15edb4
Added active orders and stop orders.
Dec 18, 2020
3ce8a46
GetWalletRecords.
Dec 27, 2020
8871aeb
Added GetWalletFunds History.
Dec 27, 2020
911182a
Fix.
Dec 27, 2020
9ee88e3
BidPrice and AskPrice in ticker fix.
Dec 28, 2020
5d2481b
Return the response.
Dec 29, 2020
d626bdc
Merge remote-tracking branch 'fork/master'
Dec 29, 2020
3375558
Refactoring for linear.
Jan 6, 2021
a8ab447
Refactoring for linear.
Jan 6, 2021
0fd1ca2
Integrate bybit linear in the rest library. Bybit add indexes and pre…
Jan 7, 2021
d381c41
Integrate bybit linear in the rest library. Bybit add indexes and pre…
Jan 7, 2021
a50cfc6
Integrate bybit linear in the rest library. Bybit add indexes and pre…
Jan 7, 2021
521b177
Integrate bybit linear in the rest library. Bybit add indexes and pre…
Jan 8, 2021
a461bdb
Integrate bybit linear in the rest library. Bybit add indexes and pre…
Jan 8, 2021
969da5a
Added recws to modify it.
Jan 27, 2021
fca2f52
Added recws to modify it.
Jan 27, 2021
1213be1
Avoid burning the CPU.
Jan 27, 2021
5820df5
Avoid burning the CPU.
Jan 27, 2021
5debd22
Avoid burning the CPU.
Jan 27, 2021
ecb11dd
Avoid burning the CPU.
Jan 27, 2021
b2f19ba
Reconnect if fails. Adding more info when logging.
Jan 29, 2021
c7c7861
Create a flag of ended that actives when closing.
Feb 1, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 3 additions & 5 deletions examples/rest/main.go
Expand Up @@ -9,10 +9,10 @@ func main() {
//baseURL := "https://api.bybit.com/" // 主网络
baseURL := "https://api-testnet.bybit.com/" // 测试网络
b := rest.New(nil,
baseURL, "YIxOY2RhFkylPudq96", "Bg9G2oFOb3aaIMguD3FOvOJJVBycaoXqXNcI")
baseURL, "YIxOY2RhFkylPudq96", "Bg9G2oFOb3aaIMguD3FOvOJJVBycaoXqXNcI", true)

// 获取持仓
positions, err := b.GetPositions()
_, positions, err := b.GetPositions()
if err != nil {
log.Printf("%v", err)
return
Expand All @@ -27,9 +27,7 @@ func main() {
qty := 30
price := 7000.0
timeInForce := "GoodTillCancel"
reduceOnly := false
order, err := b.CreateOrder(side,
orderType, price, qty, timeInForce, reduceOnly, symbol)
_, order, err := b.CreateOrder(side, orderType, price, qty, timeInForce, 0, 0, false, false, "", symbol)
if err != nil {
log.Println(err)
return
Expand Down
1 change: 1 addition & 0 deletions go.mod
Expand Up @@ -5,6 +5,7 @@ go 1.13
require (
github.com/chuckpreslar/emission v0.0.0-20170206194824-a7ddd980baf9
github.com/gorilla/websocket v1.4.2
github.com/jpillora/backoff v0.0.0-20180909062703-3050d21c67d7
github.com/json-iterator/go v1.1.9
github.com/recws-org/recws v1.2.1
github.com/stretchr/testify v1.5.1
Expand Down
4 changes: 0 additions & 4 deletions go.sum
Expand Up @@ -23,12 +23,8 @@ github.com/recws-org/recws v1.2.1 h1:bYocRkAsS71hlQ9AMCVS+hYXHEgEyQsAbYKXf394gZ8
github.com/recws-org/recws v1.2.1/go.mod h1:SxTgwQU/jqYSzEgUh4ifDxq/7enApS150f8nZ5Sczk8=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
github.com/stretchr/testify v1.5.1 h1:nOGnQDM7FYENwehXlg/kFVnos3rEvtKTjRvOWSzb6H4=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/tidwall/gjson v1.3.5 h1:2oW9FBNu8qt9jy5URgrzsVx/T/KSn3qn/smJQ0crlDQ=
github.com/tidwall/gjson v1.3.5/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/gjson v1.6.0 h1:9VEQWz6LLMUsUl6PueE49ir4Ka6CzLymOAZDxpFsTDc=
github.com/tidwall/gjson v1.6.0/go.mod h1:P256ACg0Mn+j1RXIDXoss50DeIABTYK1PULOJHhxOls=
github.com/tidwall/match v1.0.1 h1:PnKP62LPNxHKTwvHHZZzdOAOCtsJTjo6dZLCwpKm5xc=
Expand Down
25 changes: 25 additions & 0 deletions recws/keepalive.go
@@ -0,0 +1,25 @@
package recws

import (
"sync"
"time"
)

type keepAliveResponse struct {
lastResponse time.Time
sync.RWMutex
}

func (k *keepAliveResponse) setLastResponse() {
k.Lock()
defer k.Unlock()

k.lastResponse = time.Now()
}

func (k *keepAliveResponse) getLastResponse() time.Time {
k.RLock()
defer k.RUnlock()

return k.lastResponse
}