func (e *Exchange) Close() error {
	e.mutex.Lock()
	e.isClosed = true
	e.mutex.Unlock()
	if err := e.conn.WriteMessage(websocket.CloseMessage, websocket.FormatCloseMessage(websocket.CloseNormalClosure, "")); err != nil {
		return err
	}
	return e.conn.Close()
}
Close the websocket connection
package deribit
import (
	"errors"
	"sync"
	"github.com/adampointer/go-deribit/client/operations"
	"github.com/adampointer/go-deribit/models"
	"github.com/gorilla/websocket"
)
const (
	liveURL = "wss://www.deribit.com/ws/api/v2/"
	testURL = "wss://test.deribit.com/ws/api/v2/"
)
var ErrTimeout = errors.New("timed out waiting for a response")
type Exchange struct {
	OnDisconnect func(*Exchange)  
	url           string
	test          bool
	conn          *websocket.Conn
	mutex         sync.Mutex
	pending       map[uint64]*RPCCall
	subscriptions map[string]*RPCSubscription
	counter       uint64
	errors        chan error
	stop          chan bool
	auth          *models.PublicAuthResponseResult
	client        *operations.Client
	isClosed      bool
}
func NewExchange(test bool, errs chan error, stop chan bool) (*Exchange, error) {
	exc := &Exchange{
		pending:       make(map[uint64]*RPCCall, 1),
		subscriptions: make(map[string]*RPCSubscription),
		counter:       1,
		errors:        errs,
		stop:          stop,
	}
	exc.url = liveURL
	if test {
		exc.test = true
		exc.url = testURL
	}
	return exc, nil
}
func (e *Exchange) Connect() error {
	c, _, err := websocket.DefaultDialer.Dial(e.url, nil)
	if err != nil {
		return err
	}
	e.conn = c
	go e.read()
	return nil
}