Open biancheng347 opened 5 months ago
Hi @biancheng347.
package 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)
}
You have 3 ways to retrieve your active orders:
data, err := c.Orders.All()
data, err := c.Orders.GetBySymbol("tBTCUSD")
order, err := c.Orders.GetByOrderId(33950998275)
Remember to check for errors:
if err != nil {
panic(err)
}
func (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)
You 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)
}
func (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"
})
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