models

package
v0.0.0-...-3f639d1 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckOptionCode

func CheckOptionCode(code string) (string, error)

Types

type ID

type ID struct {
	Id uint `gorm:"primary_key;AUTO_INCREMENT"`
}

自增ID主键

type Option

type Option struct {
	Code         string `gorm:"type:varchar(64);not null"` // 期权code
	Stock        string `gorm:"type:varchar(64);not null"` // 标的
	ExerciseDate string `gorm:"not null"`                  // 行权日
	Type         string `gorm:"type:varchar(64);not null"` // 期权类型:put or call
	StrikePrice  string `gorm:"not null"`                  // 行权价
	ContractSize int64  `gorm:"not null"`                  // 合约数量
}

func NewOption

func NewOption(code string) (*Option, error)

type OptionStrategy

type OptionStrategy struct {
	ID
	Timestamps
	Name      string `gorm:"type:varchar(128)"`
	Namespace string `gorm:"type:varchar(16)"`
	Labels    string `gorm:"type:varchar(512)"`
	Code      string `gorm:"type:varchar(64)"`
}

func NewOptionStrategy

func NewOptionStrategy(st enum.OptionStrategyEnum) *OptionStrategy

type OptionTrade

type OptionTrade struct {
	ID
	Timestamps
	Option
	Sid        uint      // optionstrategy关联id
	Position   string    `gorm:"type:varchar(32)"` // seller or buyer
	BuyPrice   string    `gorm:"type:varchar(32)"` // 买价格
	SellPrice  string    `gorm:"type:varchar(32)"` // 卖价格
	Profit     string    `gorm:"type:varchar(32)"` // 收益
	ProfitRate string    `gorm:"type:varchar(32)"` // 收益率
	Count      int64     `gorm:"not null"`         // 数量
	Premium    string    `gorm:"not null"`         // 期权权利金
	Status     string    `gorm:"not null"`         // 状态
	Market     string    `gorm:"type:varchar(8)"`  // 股票市场 HK/US
	OpenTime   time.Time // 开仓时间
	CloseTime  time.Time // 平仓时间
}

func NewOptionTrade

func NewOptionTrade(market, code string, optPositionEnum enum.OptionPositionEnum, price string) (*OptionTrade, error)

func (*OptionTrade) Close

func (trade *OptionTrade) Close(price string) error

平仓

func (*OptionTrade) Exercise

func (trade *OptionTrade) Exercise() error

行权

func (*OptionTrade) Invalid

func (trade *OptionTrade) Invalid() error

失效

func (*OptionTrade) Roll

func (trade *OptionTrade) Roll(closePrice, exerciseDate, sellPrice string) (*OptionTrade, error)

roll put

func (OptionTrade) TableName

func (OptionTrade) TableName() string

自定义表名

type Stock

type Stock struct {
	Code string `gorm:"type:varchar(64);not null"` // 股票code
}

type StockTrade

type StockTrade struct {
	ID
	Timestamps
	Stock
	OptionCode string `gorm:"type:varchar(8)"`           // 期权code
	CostPrice  string `gorm:"type:varchar(32);not null"` // 成本价
	SellPrice  string `gorm:"type:varchar(32);not null"` // 卖出价
	Count      int64  `gorm:"not null"`                  // 持仓数量
	Profit     string `gorm:"type:varchar(64)"`          // 收益
	Status     string `gorm:"type:varchar(16)"`          // 状态
	Market     string `gorm:"type:varchar(8)"`           // 股票市场 HK/US
}

func NewStockTrade

func NewStockTrade(market, code, optionCode, price string, count int) (*StockTrade, error)

func (StockTrade) TableName

func (StockTrade) TableName() string

自定义表名

type Timestamps

type Timestamps struct {
	CreateTime time.Time `gorm:"not null"`
	UpdateTime time.Time `gorm:"not null"`
}

创建、更新时间

type TradeHistory

type TradeHistory struct {
	ID
	Timestamps
	Code      string    `gorm:"type:varchar(16);not null"` // 代码
	Name      string    `gorm:"type:varchar(64);not null"` // 名称
	Direction string    `gorm:"type:varchar(8);not null"`  // 方向
	Count     string    `gorm:"not null"`                  // 成交数
	Price     string    `gorm:"not null"`                  // 成交价格
	Amount    string    `gorm:"not null"`                  // 金额
	TradeTime time.Time `gorm:"not null"`                  // 成交时间
}

func NewTradeHistory

func NewTradeHistory() *TradeHistory

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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