Implemented stop and limit orders

This commit is contained in:
Luke I. Wilson
2023-05-19 13:17:08 -05:00
parent 56740b5a00
commit d851061d1f
5 changed files with 218 additions and 82 deletions

View File

@@ -165,14 +165,14 @@ func (t *Trader) fetchData() {
func (t *Trader) Buy(units float64) {
t.closeOrdersAndPositions()
t.Log.Printf("Buy %f units", units)
t.Broker.MarketOrder(t.Symbol, units, 0.0, 0.0)
t.Broker.Order(Market, t.Symbol, units, 0, 0, 0)
t.stats.tradesThisCandle = append(t.stats.tradesThisCandle, TradeStat{units, false})
}
func (t *Trader) Sell(units float64) {
t.closeOrdersAndPositions()
t.Log.Printf("Sell %f units", units)
t.Broker.MarketOrder(t.Symbol, -units, 0.0, 0.0)
t.Broker.Order(Market, t.Symbol, -units, 0, 0, 0)
t.stats.tradesThisCandle = append(t.stats.tradesThisCandle, TradeStat{-units, false})
}