Skip to content

Commit

Permalink
revert wrong missguided change on interface to struct on exposed api
Browse files Browse the repository at this point in the history
  • Loading branch information
victorl2 committed Apr 20, 2021
1 parent 67d3338 commit 9ed1ca6
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func main() {
}

//OpenNewPosition process the next data point and checks if a position should be opened
func (stg *SimpleStrategy) OpenNewPosition(latestPrices []kate.OHLCV) *kate.OpenPositionEvt {
func (stg *SimpleStrategy) OpenNewPosition(latestPrices []kate.DataPoint) *kate.OpenPositionEvt {
latest := len(latestPrices) - 1

if latestPrices[latest].Close() > latestPrices[latest-1].Close() {
Expand All @@ -81,7 +81,7 @@ func (stg *SimpleStrategy) SetTakeProfit(openPosition kate.Position) *kate.TakeP
}

//PreProcessIndicators allows the pre processing of indicators
func (strategy *SimpleStrategy) PreProcessIndicators(latestPrices []kate.OHLCV, isPositionOpen bool) {
func (strategy *SimpleStrategy) PreProcessIndicators(latestPrices []kate.DataPoint, isPositionOpen bool) {
//No indicators to process
}
```
4 changes: 2 additions & 2 deletions examples/basic/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ func main() {
}

//PreProcessIndicators allows the pre processing of indicators
func (strategy *SimpleStrategy) PreProcessIndicators(latestPrices []kate.OHLCV, isPositionOpen bool) {
func (strategy *SimpleStrategy) PreProcessIndicators(latestPrices []kate.DataPoint, isPositionOpen bool) {
//No indicators to process
}

//OpenNewPosition process the next data point and checks if a position should be opened
func (stg *SimpleStrategy) OpenNewPosition(latestPrices []kate.OHLCV) *kate.OpenPositionEvt {
func (stg *SimpleStrategy) OpenNewPosition(latestPrices []kate.DataPoint) *kate.OpenPositionEvt {
latest := len(latestPrices) - 1

if latestPrices[latest].Close() > latestPrices[latest-1].Close() {
Expand Down
4 changes: 2 additions & 2 deletions kate/backtester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ func newSimpleStrategy() *simpleStrategy {
}

//PreProcessIndicators nothing to do
func (strategy *simpleStrategy) PreProcessIndicators(latestPrices []OHLCV, isPositionOpen bool) {}
func (strategy *simpleStrategy) PreProcessIndicators(latestPrices []DataPoint, isPositionOpen bool) {}

//OpenNewPosition process the next data point and checks if a position should be opened
func (strategy *simpleStrategy) OpenNewPosition(latestPrices []OHLCV) *OpenPositionEvt {
func (strategy *simpleStrategy) OpenNewPosition(latestPrices []DataPoint) *OpenPositionEvt {
latest := len(latestPrices) - 1

if latestPrices[latest].Close() > latestPrices[latest-1].Close() {
Expand Down
10 changes: 5 additions & 5 deletions kate/data_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
//DataHandler is a wrapper that packages the required data for running backtesting simulation.
type DataHandler struct {
counter, windowSize int
prices []OHLCV
prices []DataPoint
}

//Position is the representation of a traded position
Expand All @@ -34,14 +34,14 @@ type Position struct {
//AggregatedDataPoints is a group datapoints
type AggregatedDataPoints struct {
Event
datapoints []OHLCV
datapoints []DataPoint
}

//Required columns in the CSV file
var csvColumns = []string{"open", "high", "low", "close", "volume"}

//newDataHandler creates and initializes a DataHandler with pricing data and executes the required setup
func newDataHandler(prices []OHLCV, windowSize int) *DataHandler {
func newDataHandler(prices []DataPoint, windowSize int) *DataHandler {
return &DataHandler{
windowSize: windowSize,
prices: prices,
Expand Down Expand Up @@ -73,7 +73,7 @@ func PricesFromCSV(csvFilePath string) (*DataHandler, error) {
Make sure the CSV has the columns Open, High, Low, Close, Volume`)
}

var prices []OHLCV
var prices []DataPoint
for {
line, error := reader.Read()
if error == io.EOF {
Expand All @@ -93,7 +93,7 @@ func PricesFromCSV(csvFilePath string) (*DataHandler, error) {

}

prices = append(prices, &DataPoint{
prices = append(prices, DataPoint{
open: numbers[0],
high: numbers[1],
low: numbers[2],
Expand Down
4 changes: 2 additions & 2 deletions kate/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ type Strategy interface {

//PreProcessIndicators is the first function called when a new price data is avaliable allowing the strategy
//to precalculate indicators and make them available for reuse
PreProcessIndicators(latestPrices []OHLCV, isPositionOpen bool)
PreProcessIndicators(latestPrices []DataPoint, isPositionOpen bool)

//OpenNewPosition check if a position should be open
//the latestPrices represent the most recent price data as defined in the window of the backtest
OpenNewPosition(latestPrices []OHLCV) *OpenPositionEvt
OpenNewPosition(latestPrices []DataPoint) *OpenPositionEvt

//SetStoploss [Optional] defines a price where a stoploss will be triggered closing the position in loss
//The SetStoploss is called with updated unrealizedPnl everytime new price data is available
Expand Down

0 comments on commit 9ed1ca6

Please sign in to comment.