Skip to content

Commit

Permalink
small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
vodolaz095 committed Aug 25, 2024
1 parent 592c584 commit 732c7dd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Stocks Broadcaster
=================================
Application subscribes to [GRPC stream](https://tinkoff.github.io/investAPI/marketdata/#marketdataserversidestream)
with last prices and broadcasts data via redis server to trade bots.
with last prices and broadcasts by pub/sub channels data via redis server to trade bots.

Приложение подписывается на GRPC-поток и транслирует котировки через потоки базы данных redis для торговых ботов.
Приложение подписывается на GRPC-поток и транслирует котировки через каналы (pub/sub channels) базы данных redis для торговых ботов.

Create broker account / Открыть брокерский счёт в [T-Bank Open Investment API](https://www.tbank.ru/sl/AugaFvDlqEP)

Expand Down
13 changes: 11 additions & 2 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,39 @@ package config

import "gopkg.in/yaml.v3"

// Input defines reader's configuration which helps it to obtain last price data
type Input struct {
Name string `yaml:"name" validate:"required"`
Token string `yaml:"token" validate:"required"`
// Name makes this input different
Name string `yaml:"name" validate:"required"`
// Token is required to access OpenInvestement API - see readme how to obtain it
Token string `yaml:"token" validate:"required"`
// Figis defines list of instruments' last price feeds this reader will subscribe on
Figis []string `yaml:"figis" validate:"required"`
}

// Output defines redis servers configuration where we broadcast last price data from Input
type Output struct {
Name string `yaml:"name" validate:"required"`
RedisURL string `yaml:"redis_url" validate:"required"`
}

// Instrument defines routing parameters (where we broadcast messages) and
// how to provide instrument name in last price update
type Instrument struct {
FIGI string `yaml:"figi" validate:"required"`
Name string `yaml:"name" validate:"required"`
Channel string `yaml:"channel" validate:"required"`
}

// Config defines structure we expect in configuration file of application
type Config struct {
Inputs []Input `yaml:"inputs" validate:"required"`
Instruments []Instrument `yaml:"instruments" validate:"required"`
Outputs []Output `yaml:"outputs" validate:"required"`
Log Log `yaml:"log" validate:"required"`
}

// Dump writes current runtime config
func (c *Config) Dump() ([]byte, error) {
return yaml.Marshal(c)
}
3 changes: 3 additions & 0 deletions internal/transport/reader/invest_api/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (r *Reader) Start(ctx context.Context, updateFeed chan model.Update) (err e
}
updateFeed <- upd
}
if msg.GetPing() != nil {
log.Debug().Msgf("Reader %s: connection is alive", r.Name())
}
}
return err
}

0 comments on commit 732c7dd

Please sign in to comment.