github.com/bitfinexcom/bitfinex-api-go@v0.0.0-20210608095005-9e0b26f200fb/docs/ws_v2.md (about) 1 # websocket 2 -- 3 import "github.com/bitfinexcom/bitfinex-api-go/v2/websocket" 4 5 6 ## Usage 7 8 ```go 9 const ( 10 ChanBook = "book" 11 ChanTrades = "trades" 12 ChanTicker = "ticker" 13 ChanCandles = "candles" 14 ChanStatus = "status" 15 ) 16 ``` 17 Available channels 18 19 ```go 20 const ( 21 EventSubscribe = "subscribe" 22 EventUnsubscribe = "unsubscribe" 23 EventPing = "ping" 24 ) 25 ``` 26 Events 27 28 ```go 29 const ( 30 ErrorCodeUnknownEvent int = 10000 31 ErrorCodeUnknownPair int = 10001 32 ErrorCodeUnknownBookPrecision int = 10011 33 ErrorCodeUnknownBookLength int = 10012 34 ErrorCodeSubscriptionFailed int = 10300 35 ErrorCodeAlreadySubscribed int = 10301 36 ErrorCodeUnknownChannel int = 10302 37 ErrorCodeUnsubscribeFailed int = 10400 38 ErrorCodeNotSubscribed int = 10401 39 ) 40 ``` 41 error codes pulled from v2 docs & API usage 42 43 ```go 44 const DMSCancelOnDisconnect int = 4 45 ``` 46 DMSCancelOnDisconnect cancels session orders on disconnect. 47 48 ```go 49 const KEEP_ALIVE_TIMEOUT = 10 50 ``` 51 seconds to wait in between re-sending the keep alive ping 52 53 ```go 54 const MaxChannels = 25 55 ``` 56 57 ```go 58 const WS_READ_CAPACITY = 10 59 ``` 60 size of channel that the websocket reader routine pushes websocket updates into 61 62 ```go 63 const WS_WRITE_CAPACITY = 5000 64 ``` 65 size of channel that the websocket writer routine pulls from 66 67 ```go 68 var ( 69 ErrWSNotConnected = fmt.Errorf("websocket connection not established") 70 ErrWSAlreadyConnected = fmt.Errorf("websocket connection already established") 71 ) 72 ``` 73 ws-specific errors 74 75 #### func ConvertBytesToJsonNumberArray 76 77 ```go 78 func ConvertBytesToJsonNumberArray(b []byte) ([]interface{}, error) 79 ``` 80 81 #### type Asynchronous 82 83 ```go 84 type Asynchronous interface { 85 Connect() error 86 Send(ctx context.Context, msg interface{}) error 87 Listen() <-chan []byte 88 Close() 89 Done() <-chan error 90 } 91 ``` 92 93 Asynchronous interface decouples the underlying transport from API logic. 94 95 #### type AsynchronousFactory 96 97 ```go 98 type AsynchronousFactory interface { 99 Create() Asynchronous 100 } 101 ``` 102 103 AsynchronousFactory provides an interface to re-create asynchronous transports 104 during reconnect events. 105 106 #### func NewWebsocketAsynchronousFactory 107 108 ```go 109 func NewWebsocketAsynchronousFactory(parameters *Parameters) AsynchronousFactory 110 ``` 111 NewWebsocketAsynchronousFactory creates a new websocket factory with a given 112 URL. 113 114 #### type AuthEvent 115 116 ```go 117 type AuthEvent struct { 118 Event string `json:"event"` 119 Status string `json:"status"` 120 ChanID int64 `json:"chanId,omitempty"` 121 UserID int64 `json:"userId,omitempty"` 122 SubID string `json:"subId"` 123 AuthID string `json:"auth_id,omitempty"` 124 Message string `json:"msg,omitempty"` 125 Caps Capabilities `json:"caps"` 126 } 127 ``` 128 129 130 #### type AuthState 131 132 ```go 133 type AuthState authState // prevent user construction of authStates 134 135 ``` 136 137 AuthState provides a typed authentication state. 138 139 ```go 140 const ( 141 NoAuthentication AuthState = 0 142 PendingAuthentication AuthState = 1 143 SuccessfulAuthentication AuthState = 2 144 RejectedAuthentication AuthState = 3 145 ) 146 ``` 147 Authentication states 148 149 #### type BookFactory 150 151 ```go 152 type BookFactory struct { 153 } 154 ``` 155 156 157 #### func (*BookFactory) Build 158 159 ```go 160 func (f *BookFactory) Build(sub *subscription, objType string, raw []interface{}, b []byte) (interface{}, error) 161 ``` 162 163 #### func (*BookFactory) BuildSnapshot 164 165 ```go 166 func (f *BookFactory) BuildSnapshot(sub *subscription, raw [][]interface{}, b []byte) (interface{}, error) 167 ``` 168 169 #### func (BookFactory) Close 170 171 ```go 172 func (s BookFactory) Close() 173 ``` 174 Close is terminal. Do not call heartbeat after close. 175 176 #### func (BookFactory) ListenDisconnect 177 178 ```go 179 func (s BookFactory) ListenDisconnect() <-chan HeartbeatDisconnect 180 ``` 181 ListenDisconnect returns an error channel which receives a message when a 182 heartbeat has expired a channel. 183 184 #### func (BookFactory) ResetAll 185 186 ```go 187 func (s BookFactory) ResetAll() 188 ``` 189 Removes all tracked subscriptions 190 191 #### func (BookFactory) ResetSocketSubscriptions 192 193 ```go 194 func (s BookFactory) ResetSocketSubscriptions(socketId SocketId) []*subscription 195 ``` 196 Reset clears all subscriptions assigned to the given socket ID, and returns a 197 slice of the existing subscriptions prior to reset 198 199 #### type CandlesFactory 200 201 ```go 202 type CandlesFactory struct { 203 } 204 ``` 205 206 207 #### func (*CandlesFactory) Build 208 209 ```go 210 func (f *CandlesFactory) Build(sub *subscription, objType string, raw []interface{}, raw_bytes []byte) (interface{}, error) 211 ``` 212 213 #### func (*CandlesFactory) BuildSnapshot 214 215 ```go 216 func (f *CandlesFactory) BuildSnapshot(sub *subscription, raw [][]interface{}, raw_bytes []byte) (interface{}, error) 217 ``` 218 219 #### func (CandlesFactory) Close 220 221 ```go 222 func (s CandlesFactory) Close() 223 ``` 224 Close is terminal. Do not call heartbeat after close. 225 226 #### func (CandlesFactory) ListenDisconnect 227 228 ```go 229 func (s CandlesFactory) ListenDisconnect() <-chan HeartbeatDisconnect 230 ``` 231 ListenDisconnect returns an error channel which receives a message when a 232 heartbeat has expired a channel. 233 234 #### func (CandlesFactory) ResetAll 235 236 ```go 237 func (s CandlesFactory) ResetAll() 238 ``` 239 Removes all tracked subscriptions 240 241 #### func (CandlesFactory) ResetSocketSubscriptions 242 243 ```go 244 func (s CandlesFactory) ResetSocketSubscriptions(socketId SocketId) []*subscription 245 ``` 246 Reset clears all subscriptions assigned to the given socket ID, and returns a 247 slice of the existing subscriptions prior to reset 248 249 #### type Capabilities 250 251 ```go 252 type Capabilities struct { 253 Orders Capability `json:"orders"` 254 Account Capability `json:"account"` 255 Funding Capability `json:"funding"` 256 History Capability `json:"history"` 257 Wallets Capability `json:"wallets"` 258 Withdraw Capability `json:"withdraw"` 259 Positions Capability `json:"positions"` 260 } 261 ``` 262 263 264 #### type Capability 265 266 ```go 267 type Capability struct { 268 Read int `json:"read"` 269 Write int `json:"write"` 270 } 271 ``` 272 273 274 #### type Client 275 276 ```go 277 type Client struct { 278 Authentication AuthState 279 } 280 ``` 281 282 Client provides a unified interface for users to interact with the Bitfinex V2 283 Websocket API. nolint:megacheck,structcheck 284 285 #### func New 286 287 ```go 288 func New() *Client 289 ``` 290 New creates a default client. 291 292 #### func NewWithAsyncFactory 293 294 ```go 295 func NewWithAsyncFactory(async AsynchronousFactory) *Client 296 ``` 297 NewWithAsyncFactory creates a new default client with a given asynchronous 298 transport factory interface. 299 300 #### func NewWithAsyncFactoryNonce 301 302 ```go 303 func NewWithAsyncFactoryNonce(async AsynchronousFactory, nonce utils.NonceGenerator) *Client 304 ``` 305 NewWithAsyncFactoryNonce creates a new default client with a given asynchronous 306 transport factory and nonce generator. 307 308 #### func NewWithParams 309 310 ```go 311 func NewWithParams(params *Parameters) *Client 312 ``` 313 NewWithParams creates a new default client with a given set of parameters. 314 315 #### func NewWithParamsAsyncFactory 316 317 ```go 318 func NewWithParamsAsyncFactory(params *Parameters, async AsynchronousFactory) *Client 319 ``` 320 NewWithParamsAsyncFactory creates a new default client with a given set of 321 parameters and asynchronous transport factory interface. 322 323 #### func NewWithParamsAsyncFactoryNonce 324 325 ```go 326 func NewWithParamsAsyncFactoryNonce(params *Parameters, async AsynchronousFactory, nonce utils.NonceGenerator) *Client 327 ``` 328 NewWithParamsAsyncFactoryNonce creates a new client with a given set of 329 parameters, asynchronous transport factory, and nonce generator interfaces. 330 331 #### func NewWithParamsNonce 332 333 ```go 334 func NewWithParamsNonce(params *Parameters, nonce utils.NonceGenerator) *Client 335 ``` 336 NewWithParamsNonce creates a new default client with a given set of parameters 337 and nonce generator. 338 339 #### func (*Client) AvailableCapacity 340 341 ```go 342 func (c *Client) AvailableCapacity() int 343 ``` 344 Get the available capacity of the current websocket connections 345 346 #### func (*Client) CancelOnDisconnect 347 348 ```go 349 func (c *Client) CancelOnDisconnect(cxl bool) *Client 350 ``` 351 CancelOnDisconnect ensures all orders will be canceled if this API session is 352 disconnected. 353 354 #### func (*Client) Close 355 356 ```go 357 func (c *Client) Close() 358 ``` 359 Close the websocket client which will cause for all active sockets to be exited 360 and the Done() function to be called 361 362 #### func (*Client) CloseFundingCredit 363 364 ```go 365 func (c *Client) CloseFundingCredit(ctx context.Context, fundingOffer *fundingcredit.CancelRequest) error 366 ``` 367 CloseFundingCredit - cancels funding credit by ID. Emits an error if not 368 authenticated. 369 370 #### func (*Client) CloseFundingLoan 371 372 ```go 373 func (c *Client) CloseFundingLoan(ctx context.Context, flcr *fundingloan.CancelRequest) error 374 ``` 375 CloseFundingLoan - cancels funding loan by ID. Emits an error if not 376 authenticated. 377 378 #### func (*Client) Connect 379 380 ```go 381 func (c *Client) Connect() error 382 ``` 383 Connect to the Bitfinex API, this should only be called once. 384 385 #### func (*Client) ConnectionCount 386 387 ```go 388 func (c *Client) ConnectionCount() int 389 ``` 390 Gen the count of currently active websocket connections 391 392 #### func (*Client) Credentials 393 394 ```go 395 func (c *Client) Credentials(key string, secret string) *Client 396 ``` 397 Credentials assigns authentication credentials to a connection request. 398 399 #### func (*Client) EnableFlag 400 401 ```go 402 func (c *Client) EnableFlag(ctx context.Context, flag int) (string, error) 403 ``` 404 Submit a request to enable the given flag 405 406 #### func (*Client) GetAuthenticatedSocket 407 408 ```go 409 func (c *Client) GetAuthenticatedSocket() (*Socket, error) 410 ``` 411 Get the authenticated socket. Due to rate limitations there can only be one 412 authenticated socket active at a time 413 414 #### func (*Client) GetOrderbook 415 416 ```go 417 func (c *Client) GetOrderbook(symbol string) (*Orderbook, error) 418 ``` 419 Retrieve the Orderbook for the given symbol which is managed locally. This 420 requires ManageOrderbook=True and an active chanel subscribed to the given 421 symbols orderbook 422 423 #### func (*Client) IsConnected 424 425 ```go 426 func (c *Client) IsConnected() bool 427 ``` 428 Returns true if the underlying asynchronous transport is connected to an 429 endpoint. 430 431 #### func (*Client) Listen 432 433 ```go 434 func (c *Client) Listen() <-chan interface{} 435 ``` 436 Listen for all incoming api websocket messages When a websocket connection is 437 terminated, the publisher channel will close. 438 439 #### func (*Client) LookupSubscription 440 441 ```go 442 func (c *Client) LookupSubscription(subID string) (*SubscriptionRequest, error) 443 ``` 444 Get a subscription request using a subscription ID 445 446 #### func (*Client) Send 447 448 ```go 449 func (c *Client) Send(ctx context.Context, msg interface{}) error 450 ``` 451 Send publishes a generic message to the Bitfinex API. 452 453 #### func (*Client) StartNewConnection 454 455 ```go 456 func (c *Client) StartNewConnection() error 457 ``` 458 Start a new websocket connection. This function is only exposed in case you want 459 to implicitly add new connections otherwise connection management is already 460 handled for you. 461 462 #### func (*Client) SubmitCancel 463 464 ```go 465 func (c *Client) SubmitCancel(ctx context.Context, ocr *order.CancelRequest) error 466 ``` 467 Submit a cancel request for an existing order 468 469 #### func (*Client) SubmitFundingCancel 470 471 ```go 472 func (c *Client) SubmitFundingCancel(ctx context.Context, fundingOffer *fundingoffer.CancelRequest) error 473 ``` 474 Submit a request to cancel and existing funding offer 475 476 #### func (*Client) SubmitFundingOffer 477 478 ```go 479 func (c *Client) SubmitFundingOffer(ctx context.Context, fundingOffer *fundingoffer.SubmitRequest) error 480 ``` 481 Submit a new funding offer request 482 483 #### func (*Client) SubmitOrder 484 485 ```go 486 func (c *Client) SubmitOrder(ctx context.Context, onr *order.NewRequest) error 487 ``` 488 Submit a request to create a new order 489 490 #### func (*Client) SubmitUpdateOrder 491 492 ```go 493 func (c *Client) SubmitUpdateOrder(ctx context.Context, our *order.UpdateRequest) error 494 ``` 495 Submit and update request to change an existing orders values 496 497 #### func (*Client) Subscribe 498 499 ```go 500 func (c *Client) Subscribe(ctx context.Context, req *SubscriptionRequest) (string, error) 501 ``` 502 Submit a request to subscribe to the given SubscriptionRequuest 503 504 #### func (*Client) SubscribeBook 505 506 ```go 507 func (c *Client) SubscribeBook(ctx context.Context, symbol string, precision common.BookPrecision, frequency common.BookFrequency, priceLevel int) (string, error) 508 ``` 509 Submit a subscription request for market data for the given symbol, at the given 510 frequency, with the given precision, returning no more than priceLevels price 511 entries. Default values are Precision0, Frequency0, and priceLevels=25. 512 513 #### func (*Client) SubscribeCandles 514 515 ```go 516 func (c *Client) SubscribeCandles(ctx context.Context, symbol string, resolution common.CandleResolution) (string, error) 517 ``` 518 Submit a subscription request to receive candle updates 519 520 #### func (*Client) SubscribeStatus 521 522 ```go 523 func (c *Client) SubscribeStatus(ctx context.Context, symbol string, sType common.StatusType) (string, error) 524 ``` 525 Submit a subscription request for status updates 526 527 #### func (*Client) SubscribeTicker 528 529 ```go 530 func (c *Client) SubscribeTicker(ctx context.Context, symbol string) (string, error) 531 ``` 532 Submit a request to receive ticker updates 533 534 #### func (*Client) SubscribeTrades 535 536 ```go 537 func (c *Client) SubscribeTrades(ctx context.Context, symbol string) (string, error) 538 ``` 539 Submit a request to receive trade updates 540 541 #### func (*Client) Unsubscribe 542 543 ```go 544 func (c *Client) Unsubscribe(ctx context.Context, id string) error 545 ``` 546 Unsubscribe from the existing subscription with the given id 547 548 #### type ConfEvent 549 550 ```go 551 type ConfEvent struct { 552 Flags int `json:"flags"` 553 } 554 ``` 555 556 557 #### type ErrorEvent 558 559 ```go 560 type ErrorEvent struct { 561 Code int `json:"code"` 562 Message string `json:"msg"` 563 564 // also contain members related to subscription reject 565 SubID string `json:"subId"` 566 Channel string `json:"channel"` 567 ChanID int64 `json:"chanId"` 568 Symbol string `json:"symbol"` 569 Precision string `json:"prec,omitempty"` 570 Frequency string `json:"freq,omitempty"` 571 Key string `json:"key,omitempty"` 572 Len string `json:"len,omitempty"` 573 Pair string `json:"pair"` 574 } 575 ``` 576 577 578 #### type FlagRequest 579 580 ```go 581 type FlagRequest struct { 582 Event string `json:"event"` 583 Flags int `json:"flags"` 584 } 585 ``` 586 587 588 #### type Heartbeat 589 590 ```go 591 type Heartbeat struct { 592 } 593 ``` 594 595 596 #### type HeartbeatDisconnect 597 598 ```go 599 type HeartbeatDisconnect struct { 600 Subscription *subscription 601 Error error 602 } 603 ``` 604 605 606 #### type InfoEvent 607 608 ```go 609 type InfoEvent struct { 610 Version float64 `json:"version"` 611 ServerId string `json:"serverId"` 612 Platform PlatformInfo `json:"platform"` 613 Code int `json:"code"` 614 Msg string `json:"msg"` 615 } 616 ``` 617 618 619 #### type Orderbook 620 621 ```go 622 type Orderbook struct { 623 } 624 ``` 625 626 627 #### func (*Orderbook) Asks 628 629 ```go 630 func (ob *Orderbook) Asks() []book.Book 631 ``` 632 633 #### func (*Orderbook) Bids 634 635 ```go 636 func (ob *Orderbook) Bids() []book.Book 637 ``` 638 639 #### func (*Orderbook) Checksum 640 641 ```go 642 func (ob *Orderbook) Checksum() uint32 643 ``` 644 645 #### func (*Orderbook) SetWithSnapshot 646 647 ```go 648 func (ob *Orderbook) SetWithSnapshot(bs *book.Snapshot) 649 ``` 650 651 #### func (*Orderbook) Symbol 652 653 ```go 654 func (ob *Orderbook) Symbol() string 655 ``` 656 657 #### func (*Orderbook) UpdateWith 658 659 ```go 660 func (ob *Orderbook) UpdateWith(b *book.Book) 661 ``` 662 663 #### type Parameters 664 665 ```go 666 type Parameters struct { 667 AutoReconnect bool 668 ReconnectInterval time.Duration 669 ReconnectAttempts int 670 671 ShutdownTimeout time.Duration 672 CapacityPerConnection int 673 Logger *logging.Logger 674 675 ResubscribeOnReconnect bool 676 677 HeartbeatTimeout time.Duration 678 LogTransport bool 679 680 URL string 681 ManageOrderbook bool 682 } 683 ``` 684 685 Parameters defines adapter behavior. 686 687 #### func NewDefaultParameters 688 689 ```go 690 func NewDefaultParameters() *Parameters 691 ``` 692 693 #### type PlatformInfo 694 695 ```go 696 type PlatformInfo struct { 697 Status int `json:"status"` 698 } 699 ``` 700 701 702 #### type RawEvent 703 704 ```go 705 type RawEvent struct { 706 Data interface{} 707 } 708 ``` 709 710 711 #### type Socket 712 713 ```go 714 type Socket struct { 715 Id SocketId 716 Asynchronous 717 IsConnected bool 718 ResetSubscriptions []*subscription 719 IsAuthenticated bool 720 } 721 ``` 722 723 724 #### type SocketId 725 726 ```go 727 type SocketId int 728 ``` 729 730 731 #### type StatsFactory 732 733 ```go 734 type StatsFactory struct { 735 } 736 ``` 737 738 739 #### func (*StatsFactory) Build 740 741 ```go 742 func (f *StatsFactory) Build(sub *subscription, objType string, raw []interface{}, raw_bytes []byte) (interface{}, error) 743 ``` 744 745 #### func (*StatsFactory) BuildSnapshot 746 747 ```go 748 func (f *StatsFactory) BuildSnapshot(sub *subscription, raw [][]interface{}, raw_bytes []byte) (interface{}, error) 749 ``` 750 751 #### func (StatsFactory) Close 752 753 ```go 754 func (s StatsFactory) Close() 755 ``` 756 Close is terminal. Do not call heartbeat after close. 757 758 #### func (StatsFactory) ListenDisconnect 759 760 ```go 761 func (s StatsFactory) ListenDisconnect() <-chan HeartbeatDisconnect 762 ``` 763 ListenDisconnect returns an error channel which receives a message when a 764 heartbeat has expired a channel. 765 766 #### func (StatsFactory) ResetAll 767 768 ```go 769 func (s StatsFactory) ResetAll() 770 ``` 771 Removes all tracked subscriptions 772 773 #### func (StatsFactory) ResetSocketSubscriptions 774 775 ```go 776 func (s StatsFactory) ResetSocketSubscriptions(socketId SocketId) []*subscription 777 ``` 778 Reset clears all subscriptions assigned to the given socket ID, and returns a 779 slice of the existing subscriptions prior to reset 780 781 #### type SubscribeEvent 782 783 ```go 784 type SubscribeEvent struct { 785 SubID string `json:"subId"` 786 Channel string `json:"channel"` 787 ChanID int64 `json:"chanId"` 788 Symbol string `json:"symbol"` 789 Precision string `json:"prec,omitempty"` 790 Frequency string `json:"freq,omitempty"` 791 Key string `json:"key,omitempty"` 792 Len string `json:"len,omitempty"` 793 Pair string `json:"pair"` 794 } 795 ``` 796 797 798 #### type SubscriptionRequest 799 800 ```go 801 type SubscriptionRequest struct { 802 SubID string `json:"subId"` 803 Event string `json:"event"` 804 805 // authenticated 806 APIKey string `json:"apiKey,omitempty"` 807 AuthSig string `json:"authSig,omitempty"` 808 AuthPayload string `json:"authPayload,omitempty"` 809 AuthNonce string `json:"authNonce,omitempty"` 810 Filter []string `json:"filter,omitempty"` 811 DMS int `json:"dms,omitempty"` // dead man switch 812 813 // unauthenticated 814 Channel string `json:"channel,omitempty"` 815 Symbol string `json:"symbol,omitempty"` 816 Precision string `json:"prec,omitempty"` 817 Frequency string `json:"freq,omitempty"` 818 Key string `json:"key,omitempty"` 819 Len string `json:"len,omitempty"` 820 Pair string `json:"pair,omitempty"` 821 } 822 ``` 823 824 825 #### func (*SubscriptionRequest) String 826 827 ```go 828 func (s *SubscriptionRequest) String() string 829 ``` 830 831 #### type SubscriptionSet 832 833 ```go 834 type SubscriptionSet []*subscription 835 ``` 836 837 SubscriptionSet is a typed version of an array of subscription pointers, 838 intended to meet the sortable interface. We need to sort Reset()'s return values 839 for tests with more than 1 subscription (range map order is undefined) 840 841 #### func (SubscriptionSet) Len 842 843 ```go 844 func (s SubscriptionSet) Len() int 845 ``` 846 847 #### func (SubscriptionSet) Less 848 849 ```go 850 func (s SubscriptionSet) Less(i, j int) bool 851 ``` 852 853 #### func (SubscriptionSet) RemoveByChannelId 854 855 ```go 856 func (s SubscriptionSet) RemoveByChannelId(chanId int64) SubscriptionSet 857 ``` 858 859 #### func (SubscriptionSet) RemoveBySubscriptionId 860 861 ```go 862 func (s SubscriptionSet) RemoveBySubscriptionId(subID string) SubscriptionSet 863 ``` 864 865 #### func (SubscriptionSet) Swap 866 867 ```go 868 func (s SubscriptionSet) Swap(i, j int) 869 ``` 870 871 #### type TickerFactory 872 873 ```go 874 type TickerFactory struct { 875 } 876 ``` 877 878 879 #### func (*TickerFactory) Build 880 881 ```go 882 func (f *TickerFactory) Build(sub *subscription, objType string, raw []interface{}, raw_bytes []byte) (interface{}, error) 883 ``` 884 885 #### func (*TickerFactory) BuildSnapshot 886 887 ```go 888 func (f *TickerFactory) BuildSnapshot(sub *subscription, raw [][]interface{}, raw_bytes []byte) (interface{}, error) 889 ``` 890 891 #### func (TickerFactory) Close 892 893 ```go 894 func (s TickerFactory) Close() 895 ``` 896 Close is terminal. Do not call heartbeat after close. 897 898 #### func (TickerFactory) ListenDisconnect 899 900 ```go 901 func (s TickerFactory) ListenDisconnect() <-chan HeartbeatDisconnect 902 ``` 903 ListenDisconnect returns an error channel which receives a message when a 904 heartbeat has expired a channel. 905 906 #### func (TickerFactory) ResetAll 907 908 ```go 909 func (s TickerFactory) ResetAll() 910 ``` 911 Removes all tracked subscriptions 912 913 #### func (TickerFactory) ResetSocketSubscriptions 914 915 ```go 916 func (s TickerFactory) ResetSocketSubscriptions(socketId SocketId) []*subscription 917 ``` 918 Reset clears all subscriptions assigned to the given socket ID, and returns a 919 slice of the existing subscriptions prior to reset 920 921 #### type TradeFactory 922 923 ```go 924 type TradeFactory struct { 925 } 926 ``` 927 928 929 #### func (*TradeFactory) Build 930 931 ```go 932 func (f *TradeFactory) Build(sub *subscription, objType string, raw []interface{}, raw_bytes []byte) (interface{}, error) 933 ``` 934 935 #### func (*TradeFactory) BuildSnapshot 936 937 ```go 938 func (f *TradeFactory) BuildSnapshot(sub *subscription, raw [][]interface{}, raw_bytes []byte) (interface{}, error) 939 ``` 940 941 #### func (TradeFactory) Close 942 943 ```go 944 func (s TradeFactory) Close() 945 ``` 946 Close is terminal. Do not call heartbeat after close. 947 948 #### func (TradeFactory) ListenDisconnect 949 950 ```go 951 func (s TradeFactory) ListenDisconnect() <-chan HeartbeatDisconnect 952 ``` 953 ListenDisconnect returns an error channel which receives a message when a 954 heartbeat has expired a channel. 955 956 #### func (TradeFactory) ResetAll 957 958 ```go 959 func (s TradeFactory) ResetAll() 960 ``` 961 Removes all tracked subscriptions 962 963 #### func (TradeFactory) ResetSocketSubscriptions 964 965 ```go 966 func (s TradeFactory) ResetSocketSubscriptions(socketId SocketId) []*subscription 967 ``` 968 Reset clears all subscriptions assigned to the given socket ID, and returns a 969 slice of the existing subscriptions prior to reset 970 971 #### type UnsubscribeEvent 972 973 ```go 974 type UnsubscribeEvent struct { 975 Status string `json:"status"` 976 ChanID int64 `json:"chanId"` 977 } 978 ``` 979 980 981 #### type UnsubscribeRequest 982 983 ```go 984 type UnsubscribeRequest struct { 985 Event string `json:"event"` 986 ChanID int64 `json:"chanId"` 987 } 988 ``` 989 990 991 #### type WebsocketAsynchronousFactory 992 993 ```go 994 type WebsocketAsynchronousFactory struct { 995 } 996 ``` 997 998 WebsocketAsynchronousFactory creates a websocket-based asynchronous transport. 999 1000 #### func (*WebsocketAsynchronousFactory) Create 1001 1002 ```go 1003 func (w *WebsocketAsynchronousFactory) Create() Asynchronous 1004 ``` 1005 Create returns a new websocket transport.