Skip to content

Commit

Permalink
Volume Weighted Average Price Strategy added.
Browse files Browse the repository at this point in the history
  • Loading branch information
cinar committed Oct 19, 2024
1 parent 0ea963f commit a9983c5
Show file tree
Hide file tree
Showing 6 changed files with 490 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ The following list of strategies are currently supported by this package:
- [Force Index Strategy](strategy/volume/README.md#type-forceindexstrategy)
- [Money Flow Index Strategy](strategy/volume/README.md#type-moneyflowindexstrategy)
- [Negative Volume Index Strategy](strategy/volume/README.md#type-negativevolumeindexstrategy)
- Volume Weighted Average Price Strategy
- [Volume Weighted Average Price Strategy](strategy/volume/README.md#type-volumeweightedaveragepricestrategy)

### 🧪 Compound Strategies

Expand Down
63 changes: 63 additions & 0 deletions strategy/volume/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ The information provided on this project is strictly for informational purposes
- [func \(n \*NegativeVolumeIndexStrategy\) Compute\(snapshots \<\-chan \*asset.Snapshot\) \<\-chan strategy.Action](<#NegativeVolumeIndexStrategy.Compute>)
- [func \(n \*NegativeVolumeIndexStrategy\) Name\(\) string](<#NegativeVolumeIndexStrategy.Name>)
- [func \(n \*NegativeVolumeIndexStrategy\) Report\(c \<\-chan \*asset.Snapshot\) \*helper.Report](<#NegativeVolumeIndexStrategy.Report>)
- [type VolumeWeightedAveragePriceStrategy](<#VolumeWeightedAveragePriceStrategy>)
- [func NewVolumeWeightedAveragePriceStrategy\(\) \*VolumeWeightedAveragePriceStrategy](<#NewVolumeWeightedAveragePriceStrategy>)
- [func NewVolumeWeightedAveragePriceStrategyWith\(period int\) \*VolumeWeightedAveragePriceStrategy](<#NewVolumeWeightedAveragePriceStrategyWith>)
- [func \(v \*VolumeWeightedAveragePriceStrategy\) Compute\(snapshots \<\-chan \*asset.Snapshot\) \<\-chan strategy.Action](<#VolumeWeightedAveragePriceStrategy.Compute>)
- [func \(v \*VolumeWeightedAveragePriceStrategy\) Name\(\) string](<#VolumeWeightedAveragePriceStrategy.Name>)
- [func \(v \*VolumeWeightedAveragePriceStrategy\) Report\(c \<\-chan \*asset.Snapshot\) \*helper.Report](<#VolumeWeightedAveragePriceStrategy.Report>)


## Constants
Expand Down Expand Up @@ -321,4 +327,61 @@ func (n *NegativeVolumeIndexStrategy) Report(c <-chan *asset.Snapshot) *helper.R

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

<a name="VolumeWeightedAveragePriceStrategy"></a>
## type [VolumeWeightedAveragePriceStrategy](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L19-L22>)

VolumeWeightedAveragePriceStrategy represents the configuration parameters for calculating the Volume Weighted Average Price strategy. Recommends a Buy action when the closing crosses below the VWAP, recommends a Sell action when the closing crosses above the VWAP, and recommends a Hold action otherwise.

```go
type VolumeWeightedAveragePriceStrategy struct {
// VolumeWeightedAveragePrice is the Volume Weighted Average Price indicator instance.
VolumeWeightedAveragePrice *volume.Vwap[float64]
}
```

<a name="NewVolumeWeightedAveragePriceStrategy"></a>
### func [NewVolumeWeightedAveragePriceStrategy](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L26>)

```go
func NewVolumeWeightedAveragePriceStrategy() *VolumeWeightedAveragePriceStrategy
```

NewVolumeWeightedAveragePriceStrategy function initializes a new Volume Weighted Average Price strategy instance with the default parameters.

<a name="NewVolumeWeightedAveragePriceStrategyWith"></a>
### func [NewVolumeWeightedAveragePriceStrategyWith](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L34>)

```go
func NewVolumeWeightedAveragePriceStrategyWith(period int) *VolumeWeightedAveragePriceStrategy
```

NewVolumeWeightedAveragePriceStrategyWith function initializes a new Volume Weighted Average Price strategy instance with the given parameters.

<a name="VolumeWeightedAveragePriceStrategy.Compute"></a>
### func \(\*VolumeWeightedAveragePriceStrategy\) [Compute](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L46>)

```go
func (v *VolumeWeightedAveragePriceStrategy) Compute(snapshots <-chan *asset.Snapshot) <-chan strategy.Action
```

Compute processes the provided asset snapshots and generates a stream of actionable recommendations.

<a name="VolumeWeightedAveragePriceStrategy.Name"></a>
### func \(\*VolumeWeightedAveragePriceStrategy\) [Name](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L41>)

```go
func (v *VolumeWeightedAveragePriceStrategy) Name() string
```

Name returns the name of the strategy.

<a name="VolumeWeightedAveragePriceStrategy.Report"></a>
### func \(\*VolumeWeightedAveragePriceStrategy\) [Report](<https://github.com/cinar/indicator/blob/master/strategy/volume/volume_weighted_average_price_strategy.go#L78>)

```go
func (v *VolumeWeightedAveragePriceStrategy) Report(c <-chan *asset.Snapshot) *helper.Report
```

Report processes the provided asset snapshots and generates a report annotated with the recommended actions.

Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
252 changes: 252 additions & 0 deletions strategy/volume/testdata/volume_weighted_average_price_strategy.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,252 @@
Action
0
0
0
0
0
0
0
0
0
0
0
0
0
1
1
-1
1
-1
-1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
-1
1
1
-1
1
1
1
-1
-1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
-1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
-1
-1
1
1
1
1
1
-1
-1
-1
-1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1 change: 1 addition & 0 deletions strategy/volume/volume.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@ func AllStrategies() []strategy.Strategy {
NewForceIndexStrategy(),
NewMoneyFlowIndexStrategy(),
NewNegativeVolumeIndexStrategy(),
NewVolumeWeightedAveragePriceStrategy(),
}
}
Loading

0 comments on commit a9983c5

Please sign in to comment.