db

package
v0.0.0-...-7dcca89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddConnection

func AddConnection(tx *gorm.DB, conn *Connection) error

func AddTradingSystem

func AddTradingSystem(tx *gorm.DB, ts *TradingSystem) error

func GetConnections

func GetConnections(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]Connection, error)

func GetInstrumentsByBrokerId

func GetInstrumentsByBrokerId(tx *gorm.DB, id uint) (*[]InstrumentBroker, error)

func GetPortfolios

func GetPortfolios(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]Portfolio, error)

func GetProductBrokers

func GetProductBrokers(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]ProductBrokerFull, error)

func GetProductBrokersFull

func GetProductBrokersFull(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]ProductBrokerFull, error)

func GetProductFeeds

func GetProductFeeds(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]ProductFeedFull, error)

func GetProductFeedsFull

func GetProductFeedsFull(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]ProductFeedFull, error)

func GetTradingSessions

func GetTradingSessions(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]TradingSession, error)

func GetTradingSystems

func GetTradingSystems(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]TradingSystemFull, error)

func GetTradingSystemsFull

func GetTradingSystemsFull(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]TradingSystemFull, error)

func InitDatabase

func InitDatabase(cfg *core.Database)

func RunInTransaction

func RunInTransaction(f func(tx *gorm.DB) error) error

func UpdateTradingSystem

func UpdateTradingSystem(tx *gorm.DB, ts *TradingSystem)

Types

type Common

type Common struct {
	Id        uint      `json:"id" gorm:"primaryKey"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

type Connection

type Connection struct {
	Common
	Username              string `json:"username"`
	Code                  string `json:"code"`
	Name                  string `json:"name"`
	SystemCode            string `json:"systemCode"`
	SystemName            string `json:"systemName"`
	SystemConfig          string `json:"systemConfig"`
	ConnectionCode        string `json:"connectionCode"`
	SupportsFeed          bool   `json:"supportsFeed"`
	SupportsBroker        bool   `json:"supportsBroker"`
	SupportsMultipleFeeds bool   `json:"supportsMultipleFeeds"`
	SupportsInventory     bool   `json:"supportsInventory"`
}

func GetConnectionById

func GetConnectionById(tx *gorm.DB, id uint) (*Connection, error)

func (Connection) TableName

func (Connection) TableName() string

type Currency

type Currency struct {
	Id   uint   `json:"id"`
	Code string `json:"code"`
	Name string `json:"name"`
}

func GetCurrencyById

func GetCurrencyById(tx *gorm.DB, id uint) (*Currency, error)

func (Currency) TableName

func (Currency) TableName() string

type InstrumentBroker

type InstrumentBroker struct {
	Id              uint      `json:"id" gorm:"primaryKey"`
	ProductBrokerId uint      `json:"productBrokerId"`
	Symbol          string    `json:"symbol"`
	Name            string    `json:"name"`
	ExpirationDate  time.Time `json:"expirationDate"`
}

func (InstrumentBroker) TableName

func (InstrumentBroker) TableName() string

type InstrumentFeed

type InstrumentFeed struct {
	Id             uint      `json:"id" gorm:"primaryKey"`
	ProductFeedId  uint      `json:"productFeedId"`
	Symbol         string    `json:"symbol"`
	Name           string    `json:"name"`
	ExpirationDate time.Time `json:"expirationDate"`
	IsContinuous   bool      `json:"isContinuous"`
}

func (InstrumentFeed) TableName

func (InstrumentFeed) TableName() string

type Portfolio

type Portfolio struct {
	Common
	ParentId uint   `json:"parentId"`
	Username string `json:"username"`
	Name     string `json:"name"`
}

func (Portfolio) TableName

func (Portfolio) TableName() string

type ProductBroker

type ProductBroker struct {
	Common
	ConnectionId uint    `json:"connectionId"`
	Username     string  `json:"username"`
	Symbol       string  `json:"symbol"`
	Name         string  `json:"name"`
	PointValue   float32 `json:"pointValue"`
	CostPerTrade float32 `json:"costPerTrade"`
	MarginValue  float32 `json:"marginValue"`
	CurrencyId   uint    `json:"currencyId"`
	MarketType   string  `json:"marketType"`
	ProductType  string  `json:"productType"`
	Exchange     string  `json:"exchange"`
}

func GetProductBrokerById

func GetProductBrokerById(tx *gorm.DB, id uint) (*ProductBroker, error)

func (ProductBroker) TableName

func (ProductBroker) TableName() string

type ProductBrokerFull

type ProductBrokerFull struct {
	ProductBroker
	CurrencyCode   string `json:"currencyCode,omitempty"`
	ConnectionCode string `json:"connectionCode,omitempty"`
}

type ProductFeed

type ProductFeed struct {
	Common
	ConnectionId uint    `json:"connectionId"`
	Username     string  `json:"username"`
	Symbol       string  `json:"symbol"`
	Name         string  `json:"name"`
	PriceScale   int     `json:"priceScale"`
	MinMovement  float32 `json:"minMovement"`
	MarketType   string  `json:"marketType"`
	ProductType  string  `json:"productType"`
	Exchange     string  `json:"exchange"`
}

func (ProductFeed) TableName

func (ProductFeed) TableName() string

type ProductFeedFull

type ProductFeedFull struct {
	ProductFeed
	ConnectionCode string `json:"connectionCode,omitempty"`
}

type TradingSession

type TradingSession struct {
	Common
	Username string `json:"username"`
	Name     string `json:"name"`
	Config   string `json:"config"`
}

func (TradingSession) TableName

func (TradingSession) TableName() string

type TradingSystem

type TradingSystem struct {
	Common
	PortfolioId      uint   `json:"portfolioId"`
	ProductFeedId    uint   `json:"productFeedId"`
	ProductBrokerId  uint   `json:"productBrokerId"`
	TradingSessionId uint   `json:"tradingSessionId"`
	Username         string `json:"username"`
	WorkspaceCode    string `json:"workspaceCode"`
	Name             string `json:"name"`
}

func GetTradingSystemById

func GetTradingSystemById(tx *gorm.DB, id uint) (*TradingSystem, error)

func (TradingSystem) TableName

func (TradingSystem) TableName() string

type TradingSystemFull

type TradingSystemFull struct {
	TradingSystem
	FeedSymbol     string `json:"feedSymbol,omitempty"`
	BrokerSymbol   string `json:"brokerSymbol,omitempty"`
	PortfolioName  string `json:"portfolioName,omitempty"`
	TradingSession string `json:"tradingSession,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL