BTC-USDT, cancels it, and prints how long the exchange took to acknowledge and to answer each command.
Source on GitHub · Package reference on pkg.go.dev
Before You Begin
- A Rails account and an API key: see Get Set Up with Rails.
- Go 1.25 or later.
1
Install the SDK
2
Create a client
The client takes your API key and secret (Credentials and Environments).
3
Connect to a market
Connect opens a WebSocket connection for one market, and returns once it is up. The connection always receives the Order Creation Stream, which carries the answers to your commands.4
Place and cancel an order
CreateOrder returns a *perps.OrderResult once the exchange has answered, after the acknowledgment and the confirmation: the order as the exchange last described it, and both moments as Ack.At and TerminalAt.5
Run it
The program reads the market, price and quantity from its
-market, -price and -quantity flags. Pass a price well below the market, so the bid rests on the book instead of trading.Full Program
main.go
SDK and API Names
Where each SDK name is documented in the API reference:Next Steps
Orders
Modify and cancel orders, and recover from a command that got no answer.
Streams & Account
Read your account, follow fills and market data, and keep a local order book.