-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4997572
commit b901534
Showing
7 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,12 +24,24 @@ import kotlin.math.sqrt | |
* @author wangyiqian E-mail: [email protected] | ||
* @version 创建时间: 2021/2/16 | ||
*/ | ||
object BollCalculator: ICalculator { | ||
object BollCalculator : ICalculator { | ||
|
||
override fun calculate(param: String, input: List<IKEntity>): List<List<Float?>> { | ||
val paramList = param.split(",") | ||
val n = paramList[0].toInt() | ||
val k = paramList[1].toInt() | ||
val n = try { | ||
paramList[0].toInt() | ||
} catch (tr: Throwable) { | ||
null | ||
} | ||
val k = try { | ||
paramList[1].toInt() | ||
} catch (tr: Throwable) { | ||
null | ||
} | ||
|
||
if (n == null || k == null) { | ||
return emptyList() | ||
} | ||
|
||
// 1. MB 2.UP 3.DN | ||
val result = MutableList(3) { MutableList<Float?>(input.size) { 0f } } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,13 +24,29 @@ import kotlin.math.min | |
* @author wangyiqian E-mail: [email protected] | ||
* @version 创建时间: 2021/2/18 | ||
*/ | ||
object KDJCalculator: ICalculator { | ||
object KDJCalculator : ICalculator { | ||
|
||
override fun calculate(param: String, input: List<IKEntity>): List<List<Float?>> { | ||
val paramList = param.split(",") | ||
val n = paramList[0].toInt() | ||
val kn = paramList[1].toInt() | ||
val dn = paramList[2].toInt() | ||
val n = try { | ||
paramList[0].toInt() | ||
} catch (tr: Throwable) { | ||
null | ||
} | ||
val kn = try { | ||
paramList[1].toInt() | ||
} catch (tr: Throwable) { | ||
null | ||
} | ||
val dn = try { | ||
paramList[2].toInt() | ||
} catch (tr: Throwable) { | ||
null | ||
} | ||
|
||
if (n == null || kn == null || dn == null) { | ||
return emptyList() | ||
} | ||
|
||
val result = MutableList(3) { MutableList<Float?>(input.size) { 0f } } | ||
val kIdx = 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,11 +23,15 @@ import com.github.wangyiqian.stockchart.entities.containFlag | |
* @author wangyiqian E-mail: [email protected] | ||
* @version 创建时间: 2021/2/14 | ||
*/ | ||
object MACalculator: ICalculator { | ||
object MACalculator : ICalculator { | ||
|
||
override fun calculate(param: String, input: List<IKEntity>): List<List<Float?>> { | ||
val paramList = param.split(",") | ||
val periodList = paramList.map { it.toInt() } | ||
val periodList = try { | ||
paramList.map { it.toInt() } | ||
} catch (tr: Throwable) { | ||
emptyList<Int>() | ||
} | ||
|
||
val result = MutableList(periodList.size) { MutableList<Float?>(input.size) { 0f } } | ||
val pFromList = MutableList(periodList.size) { 0 } | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters