Categorygithub.com/DBoyara/QuikGo
modulepackage
0.4.1
Repository: https://github.com/dboyara/quikgo.git
Documentation: pkg.go.dev

# README

QuikGo

Доступ к функционалу Quik из связки Lua&Golang

CI Status Go Report Card GoDoc License GitHub release Known Vulnerabilities

Install

go get -u github.com/DBoyara/[email protected]

Examples

Пример подключения к серверу LUA и команды Ping

func main() {
	logger, _ := zap.NewDevelopment()
	client, err := quik.NewQuikClient("127.0.0.1", 54320, true) // development = true — режим разработки, false — продакшен
	if err != nil {
		logger.Error("Failed to create Quik client", zap.Error(err))
		return
	}
	defer client.Close()

	context := context.Background()

	response, err := client.Ping(context)
	if err != nil {
		logger.Error("Failed to ping Quik server", zap.Error(err))
		return
	}

	logger.Info("Ping response", zap.Any("response", response))
}

Пример создания DataSource и получения свечей

func main() {
	dataDataSource := quik.CreateDataSourceRequest{
		Ticker:   "SBER",
		Interval: 1,
		Class:    "TQBR",
	}
	err := client.CreateDataSource(dataDataSource, context)
	if err != nil {
		logger.Error("Failed to create data source", zap.Error(err))
		return
	}

	dataCandles := quik.GetCandlesRequest{
		Ticker:   "SBER",
		Interval: 1,
		Count:    10,
		Class:    "TQBR",
	}
	candles, err := client.GetCandles(dataCandles, context)
	if err != nil {
		logger.Error("Failed to get candles", zap.Error(err))
		return
	}

	for _, candle := range candles {
		fmt.Printf("Candle: %s O: %.2f H: %.2f L: %.2f C: %.2f V: %d\n",
			candle.Timestamp,
			candle.Open,
			candle.High,
			candle.Low,
			candle.Close,
			candle.Volume,
		)
	}
}

Пример получения аккаунтов

accounts, err := client.GetTradeAccounts(context)
if err != nil {
    logger.Error("Failed to get trade accounts", zap.Error(err))
    return
}

fmt.Println(accounts)

Пример денежных лимитов

limits, err := client.GetMoneyLimits(context)
if err != nil {
    logger.Error("Failed to get limits", zap.Error(err))
    return
}

fmt.Println(limits)

Account, ClientCode, FirmId - можно разово получить из GetTradeAccounts и GetMoneyLimits

Пример заявок на покупку

transID := quik.NewCounter(1)
dataOrder := quik.CreateOrderRequest{
    ClassCode: "TQBR",
    SecCode:   "SBER",
    Account:   "your-account-code",
    Trans_id:  transID.Next(),
    Operation: "B",
    Price:     "100.00",
    Quantity:  "1",
    Action:    "NEW_ORDER",
    Type:      "L",
}
err = client.SendTransaction(dataOrder, context)
if err != nil {
    logger.Error("Failed to create order", zap.Error(err))
    return
}

Пример портфолио

dataPortfolio := quik.GetPortfolioRequest{
    ClientCode: "your-client-code",
    FirmId:     "your-firm-id",
}
portfolio, err := client.GetPortfolioInfo(dataPortfolio, context)
if err != nil {
    logger.Error("Failed to get portfolio", zap.Error(err))
    return
}

fmt.Println(portfolio)

Пример обработки Callback

func eventHandler(event quik.Event) {
	switch event.Cmd {
	case "OnConnected":
		fmt.Println("✅ Подключение установлено:", event.Data)
	case "OnDisconnected":
		fmt.Println("❌ Подключение разорвано:", event.Data)
	case "OnTrade":
		fmt.Println("📊 Новая сделка:", event.Data)
	default:
		fmt.Println("⚠️ Неизвестное событие:", event.Cmd, "| Данные:", event.Data)
	}
}

func main() {
	logger, _ := quik.NewLogger(true)
	quik.RunServer(54321, true, eventHandler, logger)
}

# Variables

No description provided by the author
No description provided by the author
Реэкспортируем функции.
No description provided by the author
No description provided by the author

# Type aliases

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Реэкспортируем типы.
No description provided by the author
No description provided by the author