Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add new properties to market [OTE-296] #335

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions src/commonMain/kotlin/exchange.dydx.abacus/output/Market.kt
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,8 @@ data class MarketPerpetual(
val nextFundingAtMilliseconds: Double? = null,
val openInterest: Double,
val openInterestUSDC: Double,
val openInterestLowerCap: Double? = null,
val openInterestUpperCap: Double? = null,
prashanDYDX marked this conversation as resolved.
Show resolved Hide resolved
val line: IList<Double>?,
) {
companion object {
Expand All @@ -303,6 +305,8 @@ data class MarketPerpetual(
val nextFundingRate = parser.asDouble(data["nextFundingRate"])
val nextFundingAtMilliseconds =
parser.asDatetime(data["nextFundingAt"])?.toEpochMilliseconds()?.toDouble()
val openInterestLowerCap = parser.asDouble(data["openInterestLowerCap"])
val openInterestUpperCap = parser.asDouble(data["openInterestUpperCap"])
val openInterest = parser.asDouble(data["openInterest"])
val openInterestUSDC = parser.asDouble(data["openInterestUSDC"])

Expand All @@ -317,14 +321,16 @@ data class MarketPerpetual(
existing.line != line
) {
MarketPerpetual(
volume24H,
trades24H,
null,
nextFundingRate,
nextFundingAtMilliseconds,
openInterest,
openInterestUSDC ?: 0.0,
line,
volume24H = volume24H,
trades24H = trades24H,
volume24HUSDC = null,
nextFundingRate = nextFundingRate,
nextFundingAtMilliseconds = nextFundingAtMilliseconds,
openInterest = openInterest,
openInterestUSDC = openInterestUSDC ?: 0.0,
openInterestLowerCap = openInterestLowerCap,
openInterestUpperCap = openInterestUpperCap,
line = line,
)
} else {
existing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ internal class MarketProcessor(parser: ParserProtocol, private val calculateSpar
"double" to mapOf(
"volume24H" to "volume24H",
"openInterest" to "openInterest",
"openInterestLowerCap" to "openInterestLowerCap",
"openInterestUpperCap" to "openInterestUpperCap",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly have no idea what this is for. don't even know if i need this

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This map is used for parsing fields from the API to fields in the abacus state. So adding the keys here lets abacus know to look for these fields

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah yeah i see now, in private fun perpetual it's used as an input to the transform method. makes sense

"nextFundingRate" to "nextFundingRate",
),
"datetime" to mapOf(
Expand Down
Loading