123456789101112131415161718192021222324252627282930313233343536 |
- package main
- import (
- "fmt"
- "tickserver/api/lmaxapi"
- "tickserver/api/lmaxapi/main/common"
- "tickserver/api/lmaxapi/request"
- "tickserver/api/lmaxapi/response"
- )
- func main() {
- fmt.Println("BasicOrderClient")
- common.EnableLog("proto.log")
- session, err := common.CreateSession()
- if err != nil {
- fmt.Println("Login Failed:", err)
- return
- }
- session.RegisterOrderBookEvent(OrderBookEventListener)
- session.RegisterStreamFailureEvent(common.DefaultStreamFailureCB)
- session.RegisterOrderEvent(common.DefaultOrderCB)
- session.RegisterInstructionRejectedEvent(common.DefaultInstructionRejectedCB)
- session.RegisterExecutionEvent(common.DefaultExecutionCB)
- session.Subscribe(request.NewOrderSubscriptionRequest(), common.DefaultSubscribeCB)
- session.Subscribe(request.NewOrderBookSubscriptionRequest(4001), common.DefaultSubscribeCB)
- session.Start()
- }
- var qu float64 = 1
- func OrderBookEventListener(s *lmaxapi.Session, event *response.OrderBookEvent) {
- fmt.Println("OrderBookEvent:", event)
- qu = -qu
- orderReq := request.NewMarketOrderRequest(4001, "", qu, request.TimeInForce.IMMEDIATE_OR_CANCEL, 0, 0)
- s.PlaceMarketOrder(orderReq, nil)
- }
|