mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
types: Add TradeWith helper
This commit is contained in:
parent
b90564be90
commit
9f5ef21dda
|
@ -627,6 +627,16 @@ func (k *KLineSeries) Length() int {
|
||||||
|
|
||||||
var _ Series = &KLineSeries{}
|
var _ Series = &KLineSeries{}
|
||||||
|
|
||||||
|
func TradeWith(symbol string, f func(trade Trade)) func(trade Trade) {
|
||||||
|
return func(trade Trade) {
|
||||||
|
if symbol != "" && trade.Symbol != symbol {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
f(trade)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func KLineWith(symbol string, interval Interval, callback KLineCallback) KLineCallback {
|
func KLineWith(symbol string, interval Interval, callback KLineCallback) KLineCallback {
|
||||||
return func(k KLine) {
|
return func(k KLine) {
|
||||||
if k.Symbol != symbol || (k.Interval != "" && k.Interval != interval) {
|
if k.Symbol != symbol || (k.Interval != "" && k.Interval != interval) {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user