mirror of
https://github.com/SHOGGOTH-SECTOR/sica-fondt.git
synced 2026-11-29 08:25:10 +00:00
M3a: wire typed and DEX-pool feed queries through stomach
This commit is contained in:
@@ -59,12 +59,22 @@ oo::class create ::stomach::Economy {
|
|||||||
method feed_history {feed_type} { return [$feeds history $feed_type] }
|
method feed_history {feed_type} { return [$feeds history $feed_type] }
|
||||||
method sim_publish {sim_type prediction} { return [$sims publish $sim_type $prediction] }
|
method sim_publish {sim_type prediction} { return [$sims publish $sim_type $prediction] }
|
||||||
method statistical_runner_available {} { return [$statistical_runner available] }
|
method statistical_runner_available {} { return [$statistical_runner available] }
|
||||||
method statistical_query {prices ticker horizon {paths 4000} {seed 1} {dt 0.0027397260273972603}} {
|
method statistical_query_type {
|
||||||
set p [$statistical_runner query $prices $ticker $horizon $paths $seed $dt]
|
prices ticker prediction_type horizon
|
||||||
|
{paths 4000} {seed 1} {dt 0.0027397260273972603}
|
||||||
|
{pool_prices {}} {pool_liquidity {}}
|
||||||
|
} {
|
||||||
|
set p [$statistical_runner query_typed $prices $ticker $prediction_type $horizon $paths $seed $dt $pool_prices $pool_liquidity]
|
||||||
$sims publish statistical $p
|
$sims publish statistical $p
|
||||||
return $p
|
return $p
|
||||||
}
|
}
|
||||||
method statistical_from_feed {ticker horizon {paths 4000} {seed 1} {dt 0.0027397260273972603}} {
|
method statistical_query {prices ticker horizon {paths 4000} {seed 1} {dt 0.0027397260273972603}} {
|
||||||
|
return [my statistical_query_type $prices $ticker price_forecast $horizon $paths $seed $dt {} {}]
|
||||||
|
}
|
||||||
|
method statistical_from_feed_type {
|
||||||
|
ticker prediction_type horizon
|
||||||
|
{paths 4000} {seed 1} {dt 0.0027397260273972603}
|
||||||
|
} {
|
||||||
set prices {}
|
set prices {}
|
||||||
foreach datum [$feeds history price_tick] {
|
foreach datum [$feeds history price_tick] {
|
||||||
if {![dict exists $datum payload]} { continue }
|
if {![dict exists $datum payload]} { continue }
|
||||||
@@ -76,7 +86,29 @@ oo::class create ::stomach::Economy {
|
|||||||
lappend prices $price
|
lappend prices $price
|
||||||
}
|
}
|
||||||
if {[llength $prices] < 80} { error "insufficient_price_history" }
|
if {[llength $prices] < 80} { error "insufficient_price_history" }
|
||||||
return [my statistical_query $prices $ticker $horizon $paths $seed $dt]
|
|
||||||
|
set pool_prices {}
|
||||||
|
set pool_liquidity {}
|
||||||
|
foreach datum [$feeds history dex_pool_state] {
|
||||||
|
if {![dict exists $datum payload]} { continue }
|
||||||
|
set payload [dict get $datum payload]
|
||||||
|
if {[catch {dict get $payload token_ticker} token]} { continue }
|
||||||
|
if {$token ne $ticker} { continue }
|
||||||
|
if {[catch {dict get $payload price} price]} { continue }
|
||||||
|
if {![string is double -strict $price] || $price <= 0} { continue }
|
||||||
|
set liquidity 1.0
|
||||||
|
if {![catch {dict get $payload liquidity} raw_liquidity] &&
|
||||||
|
[string is double -strict $raw_liquidity] && $raw_liquidity >= 0} {
|
||||||
|
set liquidity $raw_liquidity
|
||||||
|
}
|
||||||
|
lappend pool_prices $price
|
||||||
|
lappend pool_liquidity $liquidity
|
||||||
|
}
|
||||||
|
|
||||||
|
return [my statistical_query_type $prices $ticker $prediction_type $horizon $paths $seed $dt $pool_prices $pool_liquidity]
|
||||||
|
}
|
||||||
|
method statistical_from_feed {ticker horizon {paths 4000} {seed 1} {dt 0.0027397260273972603}} {
|
||||||
|
return [my statistical_from_feed_type $ticker price_forecast $horizon $paths $seed $dt]
|
||||||
}
|
}
|
||||||
method query_predictions {trader_id sim_type} { return [$market predictions $trader_id $sim_type] }
|
method query_predictions {trader_id sim_type} { return [$market predictions $trader_id $sim_type] }
|
||||||
method sim_engines {} { return [$registry names] }
|
method sim_engines {} { return [$registry names] }
|
||||||
|
|||||||
Reference in New Issue
Block a user