Persist trader V4 P0 decision trace
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
package com.quantai.trader.persistence;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.quantai.trader.domain.TraderException;
|
||||
import com.quantai.trader.enums.TraderErrorCode;
|
||||
|
||||
public class TraderJsonCodec {
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public TraderJsonCodec(ObjectMapper objectMapper) {
|
||||
this.objectMapper = objectMapper;
|
||||
}
|
||||
|
||||
public String toJson(Object value) {
|
||||
try {
|
||||
return objectMapper.writeValueAsString(value);
|
||||
} catch (JsonProcessingException exception) {
|
||||
throw new TraderException(TraderErrorCode.TRADER_PERSISTENCE_FAILED,
|
||||
"failed to serialize trader persistence payload");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user