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
Find a contract
Get Expirations lists a market’s expiry dates, and Get Contracts the contracts of one of them. The program picks the most expensive one, where a small bid rests instead of trading.
4
Connect to the contract's expiry
Connect opens a WebSocket connection for the contracts of an options.Scope, the SDK’s contract filter, and returns once it is up. Contract names spell the expiry second, as in BTC-7FEB26-100000-C. The connection always receives the Order Management Stream, which carries the answers to your commands.5
Place and cancel an order
CreateOrder returns an *options.OrderResult once the exchange has answered, after the acknowledgment and the answer: the order as the exchange last described it, and both moments as AckAt and TerminalAt.6
Run it
The program reads the market and price from its
-market and -price flags.Full Program
main.go
SDK and API Names
Where each SDK name is documented in the API reference; Streams & Account lists every stream with its event and snapshot:Next Steps
Orders
Place, modify and cancel orders, and sweep a contract with a cancel-all.
Streams & Account
Read your account, and follow quotes, Greeks, positions and open orders.