...
This commit is contained in:
@@ -5,6 +5,7 @@ import kotlinx.coroutines.SupervisorJob
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.Serializable
|
||||
import model.AppConfig
|
||||
import model.KisSession
|
||||
import model.TradingDecision
|
||||
import network.NewsService
|
||||
import org.jetbrains.exposed.sql.*
|
||||
@@ -490,7 +491,18 @@ object TradingLogStore {
|
||||
decision = decision.decision ?: "HOLD",
|
||||
confidence = decision.confidence,
|
||||
reason = decision.reason ?: ""
|
||||
))
|
||||
).apply {
|
||||
if (KisSession.tradeConfig.useTagsShare.contains(this.decision) && KisSession.tradeConfig.useLogKeywordsShare.any {
|
||||
reason.contains(
|
||||
it
|
||||
)
|
||||
}) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
NewsService.sendTelegramMessage("${this@apply.decision}$stockName ${reason}")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -504,11 +516,25 @@ object TradingLogStore {
|
||||
decision = decision,
|
||||
confidence = 100.0,
|
||||
reason = log
|
||||
)
|
||||
).apply {
|
||||
if (KisSession.tradeConfig.useTagsShare.contains(decision) && KisSession.tradeConfig.useLogKeywordsShare.any {
|
||||
log.contains(
|
||||
it
|
||||
)
|
||||
}) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
println("CALLED sendTelegramMessage")
|
||||
NewsService.sendTelegramMessage("${this@apply.decision}$stockName ${log}")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
fun addLog(tradingDecision: TradingDecision, decision: String, log: String) {
|
||||
synchronized(this) {
|
||||
if (decisionLogs.size > 1000) decisionLogs.removeAt(0)
|
||||
@@ -521,11 +547,8 @@ object TradingLogStore {
|
||||
reason = log
|
||||
).apply {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
println("CALLED sendTelegramMessage -1")
|
||||
if (decision.contains("WATCH") || ((tradingDecision.investmentGrade?.ordinal
|
||||
?: 0) < 2)
|
||||
if (((tradingDecision.investmentGrade?.name?.length ?: 0) > 0 && KisSession.tradeConfig.useGradeShare.contains(tradingDecision.investmentGrade?.name))
|
||||
) {
|
||||
println("CALLED sendTelegramMessage OK")
|
||||
NewsService.sendTelegramMessage("${this@apply.decision} ${tradingDecision.stockName}[${tradingDecision.currentPrice}] ${log}")
|
||||
}
|
||||
}
|
||||
@@ -534,6 +557,32 @@ object TradingLogStore {
|
||||
}
|
||||
}
|
||||
|
||||
fun addWatchLog(tradingDecision: TradingDecision, decision: String, log: String) {
|
||||
synchronized(this) {
|
||||
if (decisionLogs.size > 1000) decisionLogs.removeAt(0)
|
||||
decisionLogs.add(
|
||||
LogEntry(
|
||||
time = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss")),
|
||||
stockName = "${tradingDecision.stockName}[${tradingDecision.currentPrice}]",
|
||||
decision = decision,
|
||||
confidence = tradingDecision.confidence,
|
||||
reason = log
|
||||
).apply {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
if (KisSession.tradeConfig.useTagsShare.contains(decision) && KisSession.tradeConfig.useLogKeywordsShare.any {
|
||||
log.contains(
|
||||
it
|
||||
)
|
||||
}) {
|
||||
NewsService.sendTelegramMessage("${this@apply.decision} ${tradingDecision.stockName}[${tradingDecision.currentPrice}] ${log}")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun addAnalyzer(name : String, code : String, log: String, positive : Boolean = false) {
|
||||
synchronized(this) {
|
||||
if (decisionLogs.size > 1000) decisionLogs.removeAt(0)
|
||||
@@ -545,7 +594,17 @@ object TradingLogStore {
|
||||
decision = if (positive) "ANALYZER" else "PASS",
|
||||
confidence = 100.0,
|
||||
reason = log
|
||||
)
|
||||
).apply {
|
||||
if (KisSession.tradeConfig.useTagsShare.contains(decision) && KisSession.tradeConfig.useLogKeywordsShare.any {
|
||||
log.contains(
|
||||
it
|
||||
)
|
||||
}) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
NewsService.sendTelegramMessage("${this@apply.decision}$name[$code] ${log}")
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -562,9 +621,19 @@ object TradingLogStore {
|
||||
confidence = 100.0,
|
||||
reason = log
|
||||
).apply {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
println("CALLED sendTelegramMessage")
|
||||
NewsService.sendTelegramMessage("${this@apply.decision}$name[$code] ${log}")
|
||||
if (KisSession.tradeConfig.useTagsShare.contains(decision) && KisSession.tradeConfig.useLogKeywordsShare.any {
|
||||
log.contains(
|
||||
it
|
||||
)
|
||||
}) {
|
||||
var current = System.currentTimeMillis()
|
||||
var sendable = noticeFilter.filter { it.key.equals(code, true) && ((current - it.value) > 1000 * 60 * 30L)}.isNotEmpty()
|
||||
if (sendable) {
|
||||
CoroutineScope(Dispatchers.Default).launch {
|
||||
NewsService.sendTelegramMessage("${this@apply.decision}$name[$code] ${log}")
|
||||
|
||||
}}
|
||||
noticeFilter[code] = current
|
||||
}
|
||||
}
|
||||
)
|
||||
@@ -572,6 +641,8 @@ object TradingLogStore {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var noticeFilter = hashMapOf<String, Long>()
|
||||
fun addNotice(name : String, code : String, log: String, qty: Int? = null) {
|
||||
synchronized(this) {
|
||||
if (decisionLogs.size > 1000) decisionLogs.removeAt(0)
|
||||
|
||||
Reference in New Issue
Block a user