Documentation ¶
Index ¶
- Constants
- func ConvLogicToYamlString(l Logic) (string, error)
- func Migrate(db *gorm.DB) error
- type Balance
- type Chart
- type ExchangeID
- type Logic
- func And(a Logic, b Logic) Logic
- func NewEMADif(period int, difRate float64) Logic
- func NewFakeLogic(isPassed bool) Logic
- func NewGoldenCross(positionType PositionType, period int, param float64) Logic
- func NewOBV(positionType PositionType, period int, param float64) Logic
- func NewRSIContrarian(positionType PositionType, period int, param float64) Logic
- func NewRSIFollow(positionType PositionType, period int, param float64) Logic
- func NewSMADif(period int, difRate float64) Logic
- func NewSmaLineCross(positionType PositionType, shortPeriod int, longPeriod int, keepPeriod int) Logic
- func NewWMADif(period int, difRate float64) Logic
- func Not(a Logic) Logic
- func Or(a Logic, b Logic) Logic
- type LogicYaml
- type Order
- type OrderGorm
- type OrderType
- type Position
- type PositionType
- type Status
- type TradePhase
- type TraderGorm
- type YamlParser
Constants ¶
View Source
const ( Running = "running" Paused = "paused" Resuming = "resuming" Removed = "removed" Waiting = "waiting" )
Variables ¶
This section is empty.
Functions ¶
func ConvLogicToYamlString ¶
Types ¶
type Balance ¶
func NewBalance ¶
type ExchangeID ¶
type ExchangeID int
const ( Poloniex ExchangeID = iota + 1 Hitbtc Bitflyer Binance UnknownExchange )
func ExchangeIDString ¶
func ExchangeIDString(s string) (ExchangeID, error)
func (ExchangeID) String ¶
func (i ExchangeID) String() string
type Logic ¶
func NewFakeLogic ¶
func NewGoldenCross ¶
func NewGoldenCross(positionType PositionType, period int, param float64) Logic
func NewRSIContrarian ¶
func NewRSIContrarian(positionType PositionType, period int, param float64) Logic
func NewRSIFollow ¶
func NewRSIFollow(positionType PositionType, period int, param float64) Logic
func NewSmaLineCross ¶
func NewSmaLineCross(positionType PositionType, shortPeriod int, longPeriod int, keepPeriod int) Logic
type OrderGorm ¶
type OrderGorm struct { gorm.Model Order ExchangeID ExchangeID `json:"exchange_id"` TraderID uint `json:"trader_id"` PositionID uint Pair string `json:"currency_pair"` OrderID string `json:"order_id"` Datetime time.Time `json:"datetime"` Status bool `json:"status"` ExcutePrice float64 `json:"price"` ExcuteAmount float64 `json:"amount"` TradeType PositionType `json:"trade_type"` }
type Position ¶
type Position struct { ID uint `gorm:"primary_key" json:"position_id"` CreatedAt time.Time UpdatedAt time.Time DeletedAt *time.Time ExchangeID ExchangeID AssetDistributionRate float64 EntryPrice float64 `json:"entry_price"` ProfitTakeRate float64 LossCutRate float64 PositionType PositionType `json:"position_type" sql:"DEFAULT:false"` Trading string Settlement string WaitLimitSecond int EntryOrder OrderGorm EntryOrderID uint `gorm:"type:bigint" json:"entry_order_id"` ExitOrder OrderGorm ExitOrderID uint `gorm:"type:bigint" json:"exit_order_id"` IsMade bool `json:"is_made"` IsClosed bool `json:"is_closed"` TraderID uint `json:"trader_id"` }
A position is a struct used by Trader. It opens and closes positions according to evaluate methods it has.
func (*Position) IsLossCuttable ¶
func (*Position) IsProfitTakable ¶
type PositionType ¶
type PositionType int
Long:true False:false
const ( Long PositionType = 1 Short = 0 )
type TradePhase ¶
type TradePhase int
const ( Boot TradePhase = iota + 1 Resume JudgeEntry MakePosition JudgeExit ClosePosition Reset ShutDown )
type TraderGorm ¶
type TraderGorm struct { gorm.Model ExchangeID ExchangeID `yaml:"exchange_id"` APIKey string `yaml:"api_key"` SecretKey string `yaml:"secret_key"` Trading string `yaml:"trading"` Settlement string `yaml:"settlement"` LossCutRate float64 `yaml:"loss_cut_rate"` ProfitTakeRate float64 `yaml:"profit_take_rate"` AssetDistributionRate float64 `yaml:"asset_distribution_rate"` TradingAmount float64 PositionType PositionType `yaml:"position_type"` Duration int `yaml:"duration"` WaitLimitSecond int `yaml:"wait_limit_second"` MakePositionLogicsString string `yaml:"make_position_logics" sql:"type:text"` MakePositionLogicsYaml LogicYaml `sql:"-" yaml:"make_position_logics_yaml"` Status string `yaml:"status"` }
func (*TraderGorm) AfterFind ¶
func (t *TraderGorm) AfterFind() (err error)
func (*TraderGorm) BeforeSave ¶
func (t *TraderGorm) BeforeSave(scope *gorm.Scope) (err error)
type YamlParser ¶
type YamlParser struct { }
func NewYamlParser ¶
func NewYamlParser() *YamlParser
func (*YamlParser) ParseLogicYaml ¶
func (p *YamlParser) ParseLogicYaml(yml LogicYaml) (logic Logic, err error)
Click to show internal directories.
Click to hide internal directories.