Skip to content

Commit

Permalink
Remove NewOrder method, use struct initializer
Browse files Browse the repository at this point in the history
  • Loading branch information
sdcoffey committed Apr 6, 2018
1 parent 8a1879f commit c34ee3c
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 346 deletions.
20 changes: 11 additions & 9 deletions analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,17 @@ func (baha BuyAndHoldAnalysis) Analyze(record *TradingRecord) float64 {
return 0
}

openOrder := NewOrder(BUY)
openOrder.Amount = big.NewDecimal(baha.StartingMoney).Div(baha.TimeSeries.Candles[0].ClosePrice)
openOrder.Price = baha.TimeSeries.Candles[0].ClosePrice
openOrder.FeePercentage = big.ZERO

closeOrder := NewOrder(SELL)
closeOrder.Amount = openOrder.Amount
closeOrder.Price = baha.TimeSeries.Candles[len(baha.TimeSeries.Candles)-1].ClosePrice
closeOrder.FeePercentage = big.ZERO
openOrder := Order{
Side: BUY,
Amount: big.NewDecimal(baha.StartingMoney).Div(baha.TimeSeries.Candles[0].ClosePrice),
Price: baha.TimeSeries.Candles[0].ClosePrice,
}

closeOrder := Order{
Side: SELL,
Amount: openOrder.Amount,
Price: baha.TimeSeries.Candles[len(baha.TimeSeries.Candles)-1].ClosePrice,
}

pos := NewPosition(openOrder)
pos.Exit(closeOrder)
Expand Down
Loading

0 comments on commit c34ee3c

Please sign in to comment.