mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-26 08:45:16 +00:00
add binance paper trade endpoint
This commit is contained in:
parent
bc0429c0fd
commit
36a746d415
|
@ -29,9 +29,13 @@ import (
|
|||
const BNB = "BNB"
|
||||
|
||||
const BinanceUSBaseURL = "https://api.binance.us"
|
||||
const BinanceTestBaseURL = "https://testnet.binance.vision"
|
||||
const BinanceUSWebSocketURL = "wss://stream.binance.us:9443"
|
||||
const WebSocketURL = "wss://stream.binance.com:9443"
|
||||
const WebSocketTestURL = "wss://testnet.binance.vision"
|
||||
const FutureTestBaseURL = "https://testnet.binancefuture.com"
|
||||
const FuturesWebSocketURL = "wss://fstream.binance.com"
|
||||
const FuturesWebSocketTestURL = "wss://stream.binancefuture.com"
|
||||
|
||||
// 5 per second and a 2 initial bucket
|
||||
var orderLimiter = rate.NewLimiter(5, 2)
|
||||
|
@ -56,6 +60,11 @@ func isBinanceUs() bool {
|
|||
return err == nil && v
|
||||
}
|
||||
|
||||
func paperTrade() bool {
|
||||
v, err := strconv.ParseBool(os.Getenv("PAPER_TRADE"))
|
||||
return err == nil && v
|
||||
}
|
||||
|
||||
type Exchange struct {
|
||||
types.MarginSettings
|
||||
types.FuturesSettings
|
||||
|
@ -80,6 +89,11 @@ func New(key, secret string) *Exchange {
|
|||
client.BaseURL = BinanceUSBaseURL
|
||||
}
|
||||
|
||||
if paperTrade() {
|
||||
client.BaseURL = BinanceTestBaseURL
|
||||
futuresClient.BaseURL = FutureTestBaseURL
|
||||
}
|
||||
|
||||
var err error
|
||||
if len(key) > 0 && len(secret) > 0 {
|
||||
timeSetter.Do(func() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user