Having developed a trading platform in Kotlin, I w...
# feed
p
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
you were right about one thing, master. the [strategy] was [simple]
p
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).