Skip to content

Commit

Permalink
feat: Fix up update
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMcL committed Jan 11, 2024
1 parent 4485971 commit 2da63c1
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 48 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VEGA_SIM_VEGA_TAG=5ef4d15b610ae6c10ab0bfa86355c4d35d54bd2d
VEGA_SIM_VEGA_TAG=mark_price
VEGA_SIM_CONSOLE_TAG=develop
VEGA_DEFAULT_KEY_NAME='Key 1'
VEGA_SIM_NETWORKS_INTERNAL_TAG=main
Expand Down
5 changes: 0 additions & 5 deletions vega_sim/api/governance.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,7 @@ def __propose_market(
max_fraction_consumed="0.5",
),
mark_price_configuration=vega_protos.markets.CompositePriceConfiguration(
decay_weight="0",
composite_price_type=vega_protos.markets.COMPOSITE_PRICE_TYPE_LAST_TRADE,
source_staleness_tolerance=["100h"],
decay_power=1,
cash_amount="0",
source_weights=["1"],
),
),
)
Expand Down
38 changes: 25 additions & 13 deletions vega_sim/api/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,12 @@ def build(self):
class MarkPriceConfiguration(Config):
OPTS = {
"default": {
"decay_weight": 0,
"decay_weight": None,
"composite_price_type": vega_protos.markets.COMPOSITE_PRICE_TYPE_LAST_TRADE,
"source_staleness_tolerance": ["100h"],
"decay_power": 1,
"cash_amount": 0,
"source_weights": [1],
"source_staleness_tolerance": None,
"decay_power": None,
"cash_amount": None,
"source_weights": None,
}
}

Expand All @@ -415,18 +415,30 @@ def load(self, opt: Optional[str] = None):
self.composite_price_type = config["composite_price_type"]
self.source_staleness_tolerance = config["source_staleness_tolerance"]
self.decay_power = config["decay_power"]
self.cash_amount = str(config["cash_amount"])
self.source_weights = [str(w) for w in config["source_weights"]]
self.cash_amount = (
str(config["cash_amount"]) if config["cash_amount"] is not None else None
)
self.source_weights = (
[str(w) for w in config["source_weights"]]
if config["source_weights"] is not None
else None
)

def build(self):
return vega_protos.markets.CompositePriceConfiguration(
decay_weight=self.decay_weight,
composite_price_type=self.composite_price_type,
price_config = vega_protos.markets.CompositePriceConfiguration(
source_staleness_tolerance=self.source_staleness_tolerance,
decay_power=self.decay_power,
cash_amount=self.cash_amount,
source_weights=self.source_weights,
)
if self.source_weights is not None:
price_config.source_weights = self.source_weights
if self.cash_amount is not None:
price_config.cash_amount = self.cash_amount
if self.decay_power is not None:
price_config.decay_power = self.decay_power
if self.source_staleness_tolerance is not None:
price_config.source_staleness_tolerance = self.source_staleness_tolerance
if self.decay_weight is not None:
price_config.decay_weight = self.decay_weight
return price_config


class LiquidationStrategy(Config):
Expand Down
52 changes: 27 additions & 25 deletions vega_sim/proto/vega/data_source_pb2.py

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions vega_sim/proto/vega/data_source_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ class DataSourceDefinition(_message.Message):
external: _Optional[_Union[DataSourceDefinitionExternal, _Mapping]] = ...,
) -> None: ...

class SpecBindingForCompositePrice(_message.Message):
__slots__ = ("price_source_property",)
PRICE_SOURCE_PROPERTY_FIELD_NUMBER: _ClassVar[int]
price_source_property: str
def __init__(self, price_source_property: _Optional[str] = ...) -> None: ...

class DataSourceSpecConfigurationTime(_message.Message):
__slots__ = ("conditions",)
CONDITIONS_FIELD_NUMBER: _ClassVar[int]
Expand Down
Loading

0 comments on commit 2da63c1

Please sign in to comment.