Documentation ¶
Index ¶
- Constants
- Variables
- func AddBiasAnalysis(tx *gorm.DB, c *auth.Context, bas *BiasAnalysisSpec) (*db.BiasAnalysis, error)
- func AddBiasConfig(tx *gorm.DB, c *auth.Context, baId uint, bcs *BiasConfigSpec) (*db.BiasConfig, error)
- func AddDataInstrumentAndJob(tx *gorm.DB, c *auth.Context, productId uint, spec *DatafileUploadSpec, ...) error
- func CreateDataConfig(tx *gorm.DB, id uint) (*ds.DataConfig, error)
- func DeleteBiasConfig(tx *gorm.DB, c *auth.Context, baId uint, id uint) (bool, error)
- func GetBiasAnalyses(tx *gorm.DB, c *auth.Context, filter map[string]any, offset int, limit int, ...) (*[]db.BiasAnalysisFull, error)
- func GetBiasConfigsByAnalysisId(tx *gorm.DB, c *auth.Context, baId uint) (*[]*BiasConfig, error)
- func GetBiasSummaryData(c *auth.Context, id uint, bsr *BiasSummaryResponse) error
- func GetDataInstruments(tx *gorm.DB, c *auth.Context) (*[]db.DataInstrumentFull, error)
- func GetDataInstrumentsByProductId(tx *gorm.DB, c *auth.Context, productId uint) (*[]db.DataInstrument, error)
- func RunBacktest(c *auth.Context, bbr *BiasBacktestResponse) error
- func UpdateBiasAnalysis(tx *gorm.DB, c *auth.Context, id uint, bas *BiasAnalysisSpec) (*db.BiasAnalysis, error)
- func UpdateBiasConfig(tx *gorm.DB, c *auth.Context, baId uint, id uint, bcs *BiasConfigSpec) (*db.BiasConfig, error)
- type BacktestedConfig
- func (btc *BacktestedConfig) EndTrade(currDp *ds.DataPoint, exitCondition int8)
- func (btc *BacktestedConfig) Finish()
- func (btc *BacktestedConfig) IsDayAllowed(ti *TimeInfo) bool
- func (btc *BacktestedConfig) IsEndOfTrade(ti *TimeInfo) bool
- func (btc *BacktestedConfig) IsStartOfTrade(ti *TimeInfo) bool
- func (btc *BacktestedConfig) RunBacktest(ti *TimeInfo, currDp *ds.DataPoint, prevDp *ds.DataPoint, i int, ...)
- func (btc *BacktestedConfig) StartTrade(currDp, prevDp *ds.DataPoint, index int, dataPoints []*ds.DataPoint)
- type BiasAnalysisExt
- type BiasAnalysisSpec
- type BiasBacktestResponse
- type BiasBacktestSpec
- type BiasConfig
- type BiasConfigSpec
- type BiasSummaryResponse
- type BiasTrade
- type DataInstrumentDataParams
- type DataInstrumentDataResponse
- type DataInstrumentDataSpec
- type DataInstrumentExt
- type DataPointDelta
- type DataPointDowList
- type DataPointEntry
- type DataPointSlotList
- type DatafileUploadResponse
- type DatafileUploadSpec
- type Equity
- type ExcludedPeriod
- type ExcludedSet
- type ProfitDistribution
- type TimeInfo
- type TriggeringSequence
Constants ¶
View Source
const ( ExitConditionNormal = 0 ExitConditionStop = -1 ExitConditionProfit = +1 )
View Source
const SlotNum int = 48 * 5
Variables ¶
View Source
var DefaultFrom = time.Date(2000, 1, 1, 0, 0, 0, 0, time.UTC)
View Source
var DefaultTo = time.Date(3000, 1, 1, 0, 0, 0, 0, time.UTC)
Functions ¶
func AddBiasAnalysis ¶
func AddBiasAnalysis(tx *gorm.DB, c *auth.Context, bas *BiasAnalysisSpec) (*db.BiasAnalysis, error)
func AddBiasConfig ¶
func AddBiasConfig(tx *gorm.DB, c *auth.Context, baId uint, bcs *BiasConfigSpec) (*db.BiasConfig, error)
func AddDataInstrumentAndJob ¶
func CreateDataConfig ¶
func DeleteBiasConfig ¶
func GetBiasAnalyses ¶
func GetBiasSummaryData ¶
func GetBiasSummaryData(c *auth.Context, id uint, bsr *BiasSummaryResponse) error
func GetDataInstruments ¶
func RunBacktest ¶
func RunBacktest(c *auth.Context, bbr *BiasBacktestResponse) error
func UpdateBiasAnalysis ¶
func UpdateBiasAnalysis(tx *gorm.DB, c *auth.Context, id uint, bas *BiasAnalysisSpec) (*db.BiasAnalysis, error)
func UpdateBiasConfig ¶
func UpdateBiasConfig(tx *gorm.DB, c *auth.Context, baId uint, id uint, bcs *BiasConfigSpec) (*db.BiasConfig, error)
Types ¶
type BacktestedConfig ¶
type BacktestedConfig struct { BiasConfig *BiasConfig `json:"biasConfig"` GrossProfit float64 `json:"grossProfit"` NetProfit float64 `json:"netProfit"` GrossAvgTrade float64 `json:"grossAvgTrade"` NetAvgTrade float64 `json:"netAvgTrade"` Trades []*BiasTrade `json:"biasTrades"` Sequences []*TriggeringSequence `json:"sequences"` Equity *Equity `json:"equity"` ProfitDistrib *ProfitDistribution `json:"profitDistrib"` // contains filtered or unexported fields }
func NewBacktestedConfig ¶
func NewBacktestedConfig(bc *BiasConfig, bp *db.BrokerProduct, spec *BiasBacktestSpec) (*BacktestedConfig, error)
func (*BacktestedConfig) EndTrade ¶
func (btc *BacktestedConfig) EndTrade(currDp *ds.DataPoint, exitCondition int8)
func (*BacktestedConfig) Finish ¶
func (btc *BacktestedConfig) Finish()
func (*BacktestedConfig) IsDayAllowed ¶
func (btc *BacktestedConfig) IsDayAllowed(ti *TimeInfo) bool
func (*BacktestedConfig) IsEndOfTrade ¶
func (btc *BacktestedConfig) IsEndOfTrade(ti *TimeInfo) bool
func (*BacktestedConfig) IsStartOfTrade ¶
func (btc *BacktestedConfig) IsStartOfTrade(ti *TimeInfo) bool
func (*BacktestedConfig) RunBacktest ¶
func (*BacktestedConfig) StartTrade ¶
type BiasAnalysisExt ¶
type BiasAnalysisExt struct { db.BiasAnalysis DataInstrument db.DataInstrument `json:"dataInstrument"` BrokerProduct db.BrokerProduct `json:"brokerProduct"` Configs *[]*BiasConfig `json:"configs"` }
func GetBiasAnalysisById ¶
type BiasAnalysisSpec ¶
type BiasBacktestResponse ¶
type BiasBacktestResponse struct { BiasAnalysis *db.BiasAnalysis `json:"biasAnalysis"` BrokerProduct *db.BrokerProduct `json:"brokerProduct"` Spec *BiasBacktestSpec `json:"spec"` BacktestedConfigs []*BacktestedConfig `json:"backtestedConfigs"` // contains filtered or unexported fields }
func GetBacktestInfo ¶
func GetBacktestInfo(tx *gorm.DB, c *auth.Context, id uint, spec *BiasBacktestSpec) (*BiasBacktestResponse, error)
type BiasBacktestSpec ¶
type BiasBacktestSpec struct { StopLoss float64 `json:"stopLoss"` TakeProfit float64 `json:"takeProfit"` Session *session.TradingSession `json:"session"` }
type BiasConfig ¶
type BiasConfig struct { BiasConfigSpec Id uint `json:"id"` BiasAnalysisId uint `json:"biasAnalysisId"` }
func (*BiasConfig) FromBiasConfig ¶
func (bc *BiasConfig) FromBiasConfig(dbc *db.BiasConfig)
type BiasConfigSpec ¶
type BiasConfigSpec struct { StartDay int16 `json:"startDay"` StartSlot int16 `json:"startSlot"` EndDay int16 `json:"endDay"` EndSlot int16 `json:"endSlot"` Months []bool `json:"months"` Excludes []string `json:"excludes"` Operation int8 `json:"operation"` GrossProfit float64 `json:"grossProfit"` NetProfit float64 `json:"netProfit"` }
func (*BiasConfigSpec) ToBiasConfig ¶
func (bcs *BiasConfigSpec) ToBiasConfig() *db.BiasConfig
type BiasSummaryResponse ¶
type BiasSummaryResponse struct { BiasAnalysis *db.BiasAnalysis `json:"biasAnalysis"` BrokerProduct *db.BrokerProduct `json:"brokerProduct"` Result [7]*DataPointDowList `json:"result"` // contains filtered or unexported fields }
func GetBiasSummaryInfo ¶
func (*BiasSummaryResponse) Add ¶
func (r *BiasSummaryResponse) Add(dpd *DataPointDelta)
type BiasTrade ¶
type BiasTrade struct { EntryTime time.Time `json:"entryTime"` EntryValue float64 `json:"entryValue"` ExitTime time.Time `json:"exitTime"` ExitValue float64 `json:"exitValue"` Operation int8 `json:"operation"` GrossProfit float64 `json:"grossProfit"` NetProfit float64 `json:"netProfit"` ExitCondition int8 `json:"exitCondition"` // contains filtered or unexported fields }
func NewBiasTrade ¶
func NewBiasTrade(currDp, prevDp *ds.DataPoint, btc *BacktestedConfig) *BiasTrade
type DataInstrumentDataResponse ¶
type DataInstrumentDataResponse struct { Id uint `json:"id"` Symbol string `json:"symbol"` From string `json:"from"` To string `json:"to"` Timeframe string `json:"timeframe"` Timezone string `json:"timezone"` Reduction int `json:"reduction,omitempty"` Reduced bool `json:"reduced"` Records int `json:"records"` DataPoints []*ds.DataPoint `json:"dataPoints"` }
func GetDataInstrumentDataById ¶
func GetDataInstrumentDataById(c *auth.Context, spec *DataInstrumentDataSpec) (*DataInstrumentDataResponse, error)
type DataInstrumentDataSpec ¶
type DataInstrumentExt ¶
type DataInstrumentExt struct {
db.DataInstrument
}
func GetDataInstrumentById ¶
type DataPointDelta ¶
type DataPointDowList ¶
type DataPointDowList struct {
Slots [48]*DataPointSlotList `json:"slots"`
}
func (*DataPointDowList) Add ¶
func (l *DataPointDowList) Add(dpd *DataPointDelta)
type DataPointEntry ¶
type DataPointSlotList ¶
type DataPointSlotList struct {
List []*DataPointEntry `json:"list"`
}
func (*DataPointSlotList) Add ¶
func (l *DataPointSlotList) Add(dpd *DataPointDelta)
type DatafileUploadResponse ¶
type DatafileUploadSpec ¶
type Equity ¶
type ExcludedPeriod ¶
func NewExcludedPeriod ¶
func NewExcludedPeriod(value string) (*ExcludedPeriod, error)
func (*ExcludedPeriod) ShouldBeExcluded ¶
func (ep *ExcludedPeriod) ShouldBeExcluded(month, year int16) bool
type ExcludedSet ¶
type ExcludedSet struct {
// contains filtered or unexported fields
}
func NewExcludedSet ¶
func NewExcludedSet(items []string) (*ExcludedSet, error)
func (*ExcludedSet) ShouldBeExcluded ¶
func (es *ExcludedSet) ShouldBeExcluded(month, year int16) bool
type ProfitDistribution ¶
type ProfitDistribution struct { NetProfits [16]float64 `json:"netProfits"` NumTrades [16]int `json:"numTrades"` AvgTrades [16]float64 `json:"avgTrades"` }
func NewProfitDistribution ¶
func NewProfitDistribution(trades []*BiasTrade, costPerOperation float64) *ProfitDistribution
type TriggeringSequence ¶
func NewTriggeringSequence ¶
func NewTriggeringSequence(index int, dataPoints []*ds.DataPoint, slotNum int) *TriggeringSequence
Click to show internal directories.
Click to hide internal directories.