mirror of
https://github.com/lukewilson2002/autotrader.git
synced 2025-06-15 08:23:51 +00:00
Remove unnecessary function
This commit is contained in:
parent
977296152c
commit
b467d03c73
@ -58,17 +58,9 @@ func (b *TestBroker) Advance() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *TestBroker) Candles(symbol string, frequency string, count int) (*DataFrame, error) {
|
func (b *TestBroker) Candles(symbol string, frequency string, count int) (*DataFrame, error) {
|
||||||
// Check if we reached the end of the existing data.
|
if b.Data != nil && b.candleCount > b.Data.Len() { // We have data and we are at the end of it.
|
||||||
if b.Data != nil && b.candleCount > b.Data.Len() {
|
|
||||||
return b.Data.Copy(0, -1).(*DataFrame), ErrEOF
|
return b.Data.Copy(0, -1).(*DataFrame), ErrEOF
|
||||||
}
|
} else if b.DataBroker != nil && b.Data == nil { // We have a data broker but no data.
|
||||||
|
|
||||||
data, err := b.candles(symbol, frequency, count)
|
|
||||||
return data, err
|
|
||||||
}
|
|
||||||
|
|
||||||
func (b *TestBroker) candles(symbol string, frequency string, count int) (*DataFrame, error) {
|
|
||||||
if b.DataBroker != nil && b.Data == nil {
|
|
||||||
// Fetch a lot of candles from the broker so we don't keep asking.
|
// Fetch a lot of candles from the broker so we don't keep asking.
|
||||||
candles, err := b.DataBroker.Candles(symbol, frequency, Max(count, 1000))
|
candles, err := b.DataBroker.Candles(symbol, frequency, Max(count, 1000))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -88,11 +80,11 @@ func (b *TestBroker) candles(symbol string, frequency string, count int) (*DataF
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (b *TestBroker) MarketOrder(symbol string, units float64, stopLoss, takeProfit float64) (Order, error) {
|
func (b *TestBroker) MarketOrder(symbol string, units float64, stopLoss, takeProfit float64) (Order, error) {
|
||||||
if b.Data == nil { // The dataBroker could have data but nobody has called Candles, yet.
|
if b.Data == nil { // The DataBroker could have data but nobody has fetched it, yet.
|
||||||
if b.DataBroker == nil {
|
if b.DataBroker == nil {
|
||||||
return nil, ErrNoData
|
return nil, ErrNoData
|
||||||
}
|
}
|
||||||
_, err := b.candles("", "", 1) // Fetch 1 candle.
|
_, err := b.Candles("", "", 1) // Fetch data from the DataBroker.
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user