db

package
v0.0.0-...-77db920 Latest Latest
Warning

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

Go to latest
Published: May 9, 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 AddProductBroker

func AddProductBroker(tx *gorm.DB, pb *ProductBroker) error

func AddProductData

func AddProductData(tx *gorm.DB, ts *ProductData) 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 GetCurrencies

func GetCurrencies(tx *gorm.DB) (*[]Currency, error)

func GetExchanges

func GetExchanges(tx *gorm.DB) (*[]Exchange, error)

func GetInstrumentsByBrokerId

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

func GetInstrumentsByDataId

func GetInstrumentsByDataId(tx *gorm.DB, id uint) (*[]InstrumentData, 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 GetProductData

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

func GetProductDataFull

func GetProductDataFull(tx *gorm.DB, filter map[string]any, offset int, limit int) (*[]ProductDataFull, 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 UpdateProductBroker

func UpdateProductBroker(tx *gorm.DB, pb *ProductBroker)

func UpdateProductData

func UpdateProductData(tx *gorm.DB, ts *ProductData)

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"`
	SupportsData         bool   `json:"supportsData"`
	SupportsBroker       bool   `json:"supportsBroker"`
	SupportsMultipleData bool   `json:"supportsMultipleData"`
	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 Exchange

type Exchange struct {
	Id         uint   `json:"id"`
	CurrencyId uint   `json:"currencyId"`
	Code       string `json:"code"`
	Name       string `json:"name"`
	Timezone   string `json:"timezone"`
	Url        string `json:"url"`
}

func GetExchangeById

func GetExchangeById(tx *gorm.DB, id uint) (*Exchange, error)

func (Exchange) TableName

func (Exchange) 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  int    `json:"expirationDate"`
}

func (InstrumentBroker) TableName

func (InstrumentBroker) TableName() string

type InstrumentData

type InstrumentData struct {
	Id             uint   `json:"id" gorm:"primaryKey"`
	ProductDataId  uint   `json:"productDataId"`
	Symbol         string `json:"symbol"`
	Name           string `json:"name"`
	ExpirationDate int    `json:"expirationDate,omitempty"`
	IsContinuous   bool   `json:"isContinuous"`
}

func (InstrumentData) TableName

func (InstrumentData) 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"`
	ExchangeId   uint    `json:"exchangeId"`
	Username     string  `json:"username"`
	Symbol       string  `json:"symbol"`
	Name         string  `json:"name"`
	PointValue   float32 `json:"pointValue"`
	CostPerTrade float32 `json:"costPerTrade"`
	MarginValue  float32 `json:"marginValue"`
	MarketType   string  `json:"marketType"`
	ProductType  string  `json:"productType"`
	LocalClass   string  `json:"localClass"`
}

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"`
	ExchangeCode   string `json:"exchangeCode,omitempty"`
}

type ProductData

type ProductData struct {
	Common
	ConnectionId uint    `json:"connectionId"`
	ExchangeId   uint    `json:"exchangeId"`
	Username     string  `json:"username"`
	Symbol       string  `json:"symbol"`
	Name         string  `json:"name"`
	Increment    float64 `json:"increment"`
	MarketType   string  `json:"marketType"`
	ProductType  string  `json:"productType"`
	LocalClass   string  `json:"localClass"`
}

func GetProductDataById

func GetProductDataById(tx *gorm.DB, id uint) (*ProductData, error)

func (ProductData) TableName

func (ProductData) TableName() string

type ProductDataFull

type ProductDataFull struct {
	ProductData
	ConnectionCode string `json:"connectionCode,omitempty"`
	SystemCode     string `json:"systemCode,omitempty"`
	ExchangeCode   string `json:"exchangeCode,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"`
	ProductDataId    uint   `json:"productDataId"`
	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
	DataSymbol     string `json:"dataSymbol,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