本文整理汇总了Golang中github.com/thetruetrade/gotrade.DOHLCV类的典型用法代码示例。如果您正苦于以下问题:Golang DOHLCV类的具体用法?Golang DOHLCV怎么用?Golang DOHLCV使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DOHLCV类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *PlusDiWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
// forward to the true range indicator first using previous data
ind.trueRange.ReceiveDOHLCVTick(tickData, streamBarIndex)
ind.periodCounter += 1
high := tickData.H()
low := tickData.L()
diffP := high - ind.previousHigh
diffM := ind.previousLow - low
if ind.lookbackPeriod == 1 {
if ind.periodCounter > 0 {
// forward to the true range indicator first using previous data
ind.trueRange.ReceiveDOHLCVTick(tickData, streamBarIndex)
var result float64
if (diffP > 0) && (diffP > diffM) && ind.currentTrueRange != 0.0 {
result = diffP / ind.currentTrueRange
} else {
result = 0
}
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
} else {
if ind.periodCounter > 0 {
if ind.periodCounter < ind.timePeriod {
if (diffP > 0) && (diffP > diffM) {
ind.previousPlusDM += diffP
}
ind.previousTrueRange += ind.currentTrueRange
} else {
var result float64
ind.previousTrueRange = ind.previousTrueRange - (ind.previousTrueRange / float64(ind.timePeriod)) + ind.currentTrueRange
if (diffP > 0) && (diffP > diffM) {
ind.previousPlusDM = ind.previousPlusDM - (ind.previousPlusDM / float64(ind.timePeriod)) + diffP
} else {
ind.previousPlusDM = ind.previousPlusDM - (ind.previousPlusDM / float64(ind.timePeriod))
}
if ind.previousTrueRange != 0.0 {
result = float64(100.0) * ind.previousPlusDM / ind.previousTrueRange
} else {
result = 0.0
}
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
}
}
ind.previousHigh = high
ind.previousLow = low
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:57,代码来源:plusdi.go
示例2: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *AdlWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
moneyFlowMultiplier := ((tickData.C() - tickData.L()) - (tickData.H() - tickData.C())) / (tickData.H() - tickData.L())
moneyFlowVolume := moneyFlowMultiplier * tickData.V()
result := ind.previousAdl + moneyFlowVolume
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
ind.previousAdl = result
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:11,代码来源:adl.go
示例3: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *PlusDmWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
high := tickData.H()
low := tickData.L()
diffP := high - ind.previousHigh
diffM := ind.previousLow - low
if ind.lookbackPeriod == 1 {
if ind.periodCounter > 0 {
var result float64
if (diffP > 0) && (diffP > diffM) {
result = diffP
} else {
result = 0
}
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
} else {
if ind.periodCounter > 0 {
if ind.periodCounter < ind.timePeriod {
if (diffP > 0) && (diffP > diffM) {
ind.previousPlusDm += diffP
}
if ind.periodCounter == ind.timePeriod-1 {
result := ind.previousPlusDm
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
} else {
var result float64
if (diffP > 0) && (diffP > diffM) {
result = ind.previousPlusDm - (ind.previousPlusDm / float64(ind.timePeriod)) + diffP
} else {
result = ind.previousPlusDm - (ind.previousPlusDm / float64(ind.timePeriod))
}
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
ind.previousPlusDm = result
}
}
}
ind.previousHigh = high
ind.previousLow = low
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:52,代码来源:plusdm.go
示例4: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *AroonWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
ind.periodHighHistory.PushBack(tickData.H())
ind.periodLowHistory.PushBack(tickData.L())
if ind.periodHighHistory.Len() > (1 + ind.GetLookbackPeriod()) {
var first = ind.periodHighHistory.Front()
ind.periodHighHistory.Remove(first)
first = ind.periodLowHistory.Front()
ind.periodLowHistory.Remove(first)
}
if ind.periodCounter >= 0 {
var aroonUp float64
var aroonDwn float64
var highValue float64 = math.SmallestNonzeroFloat64
var highIdx int = -1
var i int = (1 + ind.GetLookbackPeriod())
for e := ind.periodHighHistory.Front(); e != nil; e = e.Next() {
i--
var value float64 = e.Value.(float64)
if highValue <= value {
highValue = value
highIdx = i
}
}
var daysSinceHigh = highIdx
var lowValue float64 = math.MaxFloat64
var lowIdx int = -1
i = (1 + ind.GetLookbackPeriod())
for e := ind.periodLowHistory.Front(); e != nil; e = e.Next() {
i--
var value float64 = e.Value.(float64)
if lowValue >= value {
lowValue = value
lowIdx = i
}
}
var daysSinceLow = lowIdx
aroonUp = ind.aroonFactor * float64(ind.GetLookbackPeriod()-daysSinceHigh)
aroonDwn = ind.aroonFactor * float64(ind.GetLookbackPeriod()-daysSinceLow)
ind.UpdateIndicatorWithNewValue(aroonUp, aroonDwn, streamBarIndex)
}
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:50,代码来源:aroon.go
示例5: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *StochOscWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
ind.hhv.ReceiveTick(tickData.H(), streamBarIndex)
ind.llv.ReceiveTick(tickData.L(), streamBarIndex)
if ind.periodCounter >= 0 {
ind.currentFastK = 100.0 * ((tickData.C() - ind.currentPeriodLow) / (ind.currentPeriodHigh - ind.currentPeriodLow))
ind.slowKMA.ReceiveTick(ind.currentFastK, streamBarIndex)
}
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:11,代码来源:stochosc.go
示例6: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *TrueRangeWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
if ind.periodCounter > 0 {
high := math.Max(tickData.H(), ind.previousClose)
low := math.Min(tickData.L(), ind.previousClose)
result := high - low
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
ind.previousClose = tickData.C()
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:15,代码来源:truerange.go
示例7: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *Cci) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
// calculate the typical price
typicalPrice := (tickData.H() + tickData.L() + tickData.C()) / 3.0
ind.currentTypicalPrice = typicalPrice
// push it to the history
ind.typicalPriceHistory.PushBack(typicalPrice)
// trim the history
if ind.typicalPriceHistory.Len() > ind.timePeriod {
var first = ind.typicalPriceHistory.Front()
ind.typicalPriceHistory.Remove(first)
}
// add it to the average
ind.typicalPriceAvg.ReceiveTick(typicalPrice, streamBarIndex)
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:20,代码来源:cci.go
示例8: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *SarWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
if ind.hasInitialDirection == false {
ind.minusDM.ReceiveDOHLCVTick(tickData, streamBarIndex)
}
if ind.hasInitialDirection == true {
if ind.periodCounter == 0 {
if ind.isLong {
ind.extremePoint = tickData.H()
ind.previousSar = ind.previousLow
} else {
ind.extremePoint = tickData.L()
ind.previousSar = ind.previousHigh
}
// this is a trick for the first iteration only,
// the high low of the first bar will be used as the sar for the
// second bar. According tyo TALib this is the closest to Wilders
// originla idea of having the first entry day use the previous
// extreme, except now that extreme is solely derived from the first
// bar, supposedly Meta stock uses the same method.
ind.previousHigh = tickData.H()
ind.previousLow = tickData.L()
}
if ind.periodCounter >= 0 {
var result float64 = 0.0
if ind.isLong {
if tickData.L() <= ind.previousSar {
// switch to short if the low penetrates the Sar value
ind.isLong = false
ind.previousSar = ind.extremePoint
// make sure the overridden Sar is within yesterdays and todays range
if ind.previousSar < ind.previousHigh {
ind.previousSar = ind.previousHigh
}
if ind.previousSar < tickData.H() {
ind.previousSar = tickData.H()
}
result = ind.previousSar
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
// adjust af and extremePoint
ind.acceleration = ind.accelerationFactor
ind.extremePoint = tickData.L()
// calculate the new Sar
var diff float64 = ind.extremePoint - ind.previousSar
ind.previousSar = ind.previousSar + ind.acceleration*(diff)
// make sure the overridden Sar is within yesterdays and todays range
if ind.previousSar < ind.previousHigh {
ind.previousSar = ind.previousHigh
}
if ind.previousSar < tickData.H() {
ind.previousSar = tickData.H()
}
} else {
// no switch
// just output the current Sar
result = ind.previousSar
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
if tickData.H() > ind.extremePoint {
// adjust af and extremePoint
ind.extremePoint = tickData.H()
ind.acceleration += ind.accelerationFactor
if ind.acceleration > ind.accelerationFactorMax {
ind.acceleration = ind.accelerationFactorMax
}
}
// calculate the new Sar
var diff float64 = ind.extremePoint - ind.previousSar
ind.previousSar = ind.previousSar + ind.acceleration*(diff)
// make sure the overridden Sar is within yesterdays and todays range
if ind.previousSar > ind.previousLow {
ind.previousSar = ind.previousLow
}
if ind.previousSar > tickData.L() {
ind.previousSar = tickData.L()
}
}
} else {
// short
// switch to long if the high penetrates the Sar value
if tickData.H() >= ind.previousSar {
ind.isLong = true
ind.previousSar = ind.extremePoint
// make sure the overridden Sar is within yesterdays and todays range
//.........这里部分代码省略.........
开发者ID:jmptrader,项目名称:gotrade,代码行数:101,代码来源:sar.go
示例9: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *MedPriceWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
result := (tickData.H() + tickData.L()) / float64(2.0)
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:7,代码来源:medprice.go
示例10: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *MfiWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.currentVolume = tickData.V()
ind.typicalPrice.ReceiveDOHLCVTick(tickData, streamBarIndex)
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:5,代码来源:mfi.go
示例11: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *ObvWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.periodCounter += 1
if ind.periodCounter <= 0 {
ind.previousObv = tickData.V()
ind.previousClose = tickData.C()
result := ind.previousObv
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
}
if ind.periodCounter > 0 {
closePrice := tickData.C()
if closePrice > ind.previousClose {
ind.previousObv += tickData.V()
} else if closePrice < ind.previousClose {
ind.previousObv -= tickData.V()
}
result := ind.previousObv
ind.UpdateIndicatorWithNewValue(result, streamBarIndex)
ind.previousClose = tickData.C()
}
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:28,代码来源:obv.go
示例12: ReceiveDOHLCVTick
// ReceiveDOHLCVTick consumes a source data DOHLCV price tick
func (ind *StochRsiWithoutStorage) ReceiveDOHLCVTick(tickData gotrade.DOHLCV, streamBarIndex int) {
ind.rsi.ReceiveTick(tickData.C(), streamBarIndex)
}
开发者ID:jmptrader,项目名称:gotrade,代码行数:5,代码来源:stochrsi.go
注:本文中的github.com/thetruetrade/gotrade.DOHLCV类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论