Documentation
¶
Overview ¶
Package backtest calculates portfolio returns and asset weights from historic asset returns. It re-balances asset weights and updates policies based on provided functions. See Run.
DailyRebalancedWithStaticWeights is a simplified "back-tester" for calculating daily rebalanced returns of a portfolio given static policy asset weights.
Please remember, investing carries inherent risks including but not limited to the potential loss of principal. Past performance is no guarantee of future results. The data, equations, and calculations in these docs and code are for informational purposes only and should not be considered financial advice. It is important to carefully consider your own financial situation before making any investment decisions. You should seek the advice of a licensed financial professional before making any investment decisions. You should seek code review of an experienced software developer before consulting this library (or any library that imports it) to make investment decisions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ErrorNotEnoughData ¶
type ErrorNotEnoughData struct{}
func (ErrorNotEnoughData) Error ¶
func (err ErrorNotEnoughData) Error() string
type PolicyWeightCalculator ¶ added in v0.1.1
type Result ¶
type Result struct { ReturnsTable returns.Table `json:"returnsTable" bson:"returnsTable"` Weights [][]float64 `json:"weights" bson:"weights"` FinalPolicyWeights []float64 `json:"policyWeights" bson:"policyWeights"` RebalanceTimes []time.Time `json:"rebalanceDates" bson:"rebalanceDates"` PolicyUpdateTimes []time.Time `json:"policyUpdatesDates" bson:"policyUpdatesDates"` }
func Run ¶
func Run(ctx context.Context, end, start time.Time, assetReturns returns.Table, alg PolicyWeightCalculator, lookBackWindow WindowFunc, shouldCalculatePolicy, shouldRebalanceAssetWeights TriggerFunc, ) (Result, error)
Run runs a portfolio back-test. It calls function parameters for policy updates and to check when a policy update or rebalancing is required. Generally you should call Run or RunWithFullData.
func (Result) DailyRebalancedReturns ¶
type WeightSnapshot ¶
type WeightSnapshotList ¶
type WeightSnapshotList []WeightSnapshot
WeightSnapshotList should be ordered where the WeightSnapshot at index 0 is the most recent and at len(list)-1 least recent.
func (WeightSnapshotList) AverageWeightForIndex ¶
func (list WeightSnapshotList) AverageWeightForIndex(index int) (float64, error)
func (WeightSnapshotList) Times ¶
func (list WeightSnapshotList) Times() []time.Time
Directories
¶
Path | Synopsis |
---|---|