-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Complete example #247
Comments
Hi @biancheng347. Setuppackage main
import (
"os"
"github.com/bitfinexcom/bitfinex-api-go/v2"
)
func main() {
key := os.Getenv("BFX_API_KEY")
secret := os.Getenv("BFX_API_SECRET")
c := bitfinex.NewClient().Credentials(key, secret)
} Retrieve your active ordersYou have 3 ways to retrieve your active orders:
Alldata, err := c.Orders.All() GetBySymboldata, err := c.Orders.GetBySymbol("tBTCUSD") GetByOrderIdorder, err := c.Orders.GetByOrderId(33950998275) NoteRemember to check for errors: if err != nil {
panic(err)
} Submit a new orderfunc (s *OrderService) SubmitOrder(onr *order.NewRequest) (*notification.Notification, error) First you need to define a NewRequest object: request := order.NewRequest{
Symbol: "tBTCUSD",
CID: time.Now().Unix() / 1000,
Amount: 0.02,
Type: "EXCHANGE LIMIT",
Price: 5000,
}) Then you can submit it: notification, err := c.Orders.SubmitOrder(&request) NotificationYou can use the notification object to access more information about the operation: order := notification.NotifyInfo.(*order.Order)
if notification.Status == "SUCCESS" {
fmt.Printf("Successful new order for %v at %v$.", order.Symbol, order.Price)
}
if notification.Status == "ERROR" {
fmt.Printf("Something went wrong: %v.", notification.Text)
} Cancel an active orderfunc (s *OrderService) SubmitCancelOrder(oc *order.CancelRequest) error You can delete an active order by passing its ID: err := c.Orders.SubmitCancelOrder(&order.CancelRequest{
ID: 33950998275
}) You can delete an active order via its CID and CIDDate: err := c.Orders.SubmitCancelOrder(&order.CancelRequest{
CID: 1573476747887,
CIDDate: "2014-11-12"
}) API referenceorder.Snapshotorder.Orderorder.NewRequestorder.CancelRequestnotification.Notification |
After studying sdk and documents for a long time, in v2 rest, I can't figure out create_order(limt, market), cancel_order, get_order, exchange_info, where rsp contains status. Please give a complete case, thank you
The text was updated successfully, but these errors were encountered: