MCPcopy Create free account
hub / github.com/chronoxor/FastBinaryEncoding / main

Function main

projects/Go/examples/send_receive.go:43–71  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

41}
42
43func main() {
44 sender := NewMySender()
45
46 // Enable logging
47 sender.SetLogging(true)
48
49 // Create and send a new order
50 order := proto.OrderMessage{Body: proto.Order{Id: 1, Symbol: "EURUSD", Side: proto.OrderSide_buy, Type: proto.OrderType_market, Price: 1.23456, Volume: 1000.0}}
51 _, _ = sender.Send(&order)
52
53 // Create and send a new balance wallet
54 balance := proto.BalanceMessage{Body: proto.Balance{Currency: "USD", Amount: 1000.0}}
55 _, _ = sender.Send(&balance)
56
57 // Create and send a new account with some orders
58 account := proto.AccountMessage{Body: *proto.NewAccountFromFieldValues(1, "Test", proto.State_good, proto.Balance{Currency: "USD", Amount: 1000.0}, &proto.Balance{Currency: "EUR", Amount: 100.0}, make([]proto.Order, 0))}
59 account.Body.Orders = append(account.Body.Orders, proto.Order{Id: 1, Symbol: "EURUSD", Side: proto.OrderSide_buy, Type: proto.OrderType_market, Price: 1.23456, Volume: 1000.0})
60 account.Body.Orders = append(account.Body.Orders, proto.Order{Id: 2, Symbol: "EURUSD", Side: proto.OrderSide_sell, Type: proto.OrderType_limit, Price: 1.0, Volume: 100.0})
61 account.Body.Orders = append(account.Body.Orders, proto.Order{Id: 3, Symbol: "EURUSD", Side: proto.OrderSide_buy, Type: proto.OrderType_stop, Price: 1.5, Volume: 10.0})
62 _, _ = sender.Send(&account)
63
64 receiver := NewMyReceiver()
65
66 // Enable logging
67 receiver.SetLogging(true)
68
69 // Receive all data from the sender
70 _ = receiver.ReceiveBuffer(sender.Buffer())
71}

Callers

nothing calls this directly

Calls 6

ReceiveBufferMethod · 0.80
NewMySenderFunction · 0.70
NewMyReceiverFunction · 0.70
SetLoggingMethod · 0.45
SendMethod · 0.45
BufferMethod · 0.45

Tested by

no test coverage detected