Having developed a trading platform in Kotlin, I was interested what ChatGPT would come up when asking for a trading strategy in Kotlin. This is the result:
Copy code
class SimpleMovingAverageStrategy {
private val period = 14
private val sma = SimpleMovingAverage()
fun calculateSignal(prices: List<Double>): String {
sma.setPeriod(period)
sma.setValues(prices.toDoubleArray())
val currentSMA = sma.getMean()
return if (prices.last() > currentSMA) {
"BUY"
} else {
"SELL"
}
}
}
🙂 1
âž– 1
l
Luke Armitage
01/17/2023, 10:07 AM
you were right about one thing, master. the [strategy] was [simple]
p
Peter
01/17/2023, 10:10 AM
Indeed, it generated a very simple example. But to its credit, I wasn’t able to find this code with a google search. So at least it is generated and not cut&paste (or I couldn’t find it).