Documentation ¶
Index ¶
- Constants
- func CalcOrderPrices(...) (pricesIn, pricesOut []float64)
- func CalcOrderPricesSizes(...) (pricesIn, pricesOut, sizes []float64, stopLoss float64)
- func CalcOrderSizes(pricesIn []float64, balance float64) (sizes []float64)
- func CalcOrderSizesStep(pricesIn []float64, balance, step float64) (sizes []float64)
- func CalcOrderSizesWeighted(pricesIn []float64, balance float64) (sizes []float64)
- func CalcProfitAndLoss(pricesIn, pricesOut, sizes []float64, side Side) (totalReturn float64, slice []float64)
- func CalcProfitOut(pricesIn, sizes []float64, stopLossPercentage, balance float64) (pricesOut []float64)
- func CalcStopLossOut(pricesIn, sizes []float64, stopLossPercentage, balance float64) float64
- func TakeProfitStoploss(entry_price, take_profit_perc, stop_loss_perc float64, side Side) (take_profit, stop_loss float64)
- type BacktestPositions
- type Position
- type Positions
- type Side
- type State
Constants ¶
View Source
const ( Side_Buy = Side(1) Side_Sell = Side(-1) Side_DEFAULT = Side(0) )
View Source
const ( State_Win = State(1) State_Loss = State(-1) State_InTrade = State(2) State_CloseTs = State(3) // CloseTs: Max In Trade Time permitted from Entry State_CancelTs = State(4) // CancelTs: Max Excursion Time permitted from Trigger State_CancelPrice = State(5) // CancelPrice: Max Favorable Excursion permitted from Entry State_NotEntry = State(6) // NotEntry: Never reached Entry Price State_BrakeEven = State(7) // BrakeEven: Never reached Brake Even Price State_DEFAULT = State(0) )
Variables ¶
This section is empty.
Functions ¶
func CalcOrderPrices ¶
func CalcOrderPricesSizes ¶
func CalcOrderSizes ¶
func CalcOrderSizesStep ¶
func CalcOrderSizesWeighted ¶
func CalcProfitAndLoss ¶
func CalcProfitOut ¶
func CalcStopLossOut ¶
func TakeProfitStoploss ¶ added in v0.3.5
func TakeProfitStoploss(entry_price, take_profit_perc, stop_loss_perc float64, side Side) (take_profit, stop_loss float64)
TakeProfitStoploss: returns take_profit and stop_loss prices
Types ¶
type BacktestPositions ¶ added in v0.3.4
type BacktestPositions struct {
Positions Positions `bson:"positions" json:"positions"`
}
func (BacktestPositions) Export ¶ added in v0.3.4
func (bp BacktestPositions) Export(file_path string) error
The file_path is the path to the file where the positions will be exported. The file will be deleted if it exists.
type Position ¶ added in v0.3.4
type Position struct { Side int `bson:"type" json:"type"` // 0 - Long / 1 - Short EntryPrice float64 `bson:"entryPrice" json:"entryPrice"` EntryTs int64 `bson:"entryTS" json:"entryTS"` ExitTs int64 `bson:"exitTS" json:"exitTS"` TakeProfit float64 `bson:"tp" json:"tp"` StopLoss float64 `bson:"sl" json:"sl"` }
type Side ¶ added in v0.3.4
type Side int
func (Side) LogPosition ¶ added in v0.3.4
func (Side) PositionSide ¶ added in v0.3.5
Click to show internal directories.
Click to hide internal directories.