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: CFM bots #528

Open
wants to merge 37 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
d545acb
feat: Adding CFM scenario
TomMcL Oct 11, 2023
cfd6440
feat: CFM investigation
TomMcL Oct 14, 2023
7f1e7ee
feat: Adding to market trader sensitivity
TomMcL Oct 16, 2023
af54db8
feat: v3 wip
TomMcL Oct 24, 2023
36bab6a
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Oct 24, 2023
e27dec9
feat: Latest CFM
TomMcL Oct 25, 2023
7e5b192
feat: Tweaks to scenario
TomMcL Oct 25, 2023
3f3962f
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Oct 26, 2023
5da409c
feat: Volume CFM
TomMcL Oct 27, 2023
40771a1
feat: Working trade v3
TomMcL Oct 27, 2023
f68015c
fix: Fix broken extraction func
TomMcL Oct 31, 2023
337fc43
fix: Fix broken extraction func
TomMcL Oct 31, 2023
dffb920
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Oct 31, 2023
44110d1
feat: Fix up ledger transfers filter
TomMcL Oct 31, 2023
d514a66
feat: Remove unwanted changes
TomMcL Oct 31, 2023
cf838a6
feat: Extracting function call
TomMcL Nov 2, 2023
1aabbda
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Nov 15, 2023
76884ea
feat: Adding real MMs
TomMcL Nov 16, 2023
c2a3669
feat: Adding notebook
TomMcL Dec 11, 2023
60de7d8
feat: CFM changes
TomMcL Dec 28, 2023
cd835fb
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Feb 6, 2024
5fc5d96
feat: Don't break on position empty dict
TomMcL Feb 6, 2024
040e9e8
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Feb 16, 2024
55ed4ef
feat: Running CFM bot
TomMcL Feb 22, 2024
d6820cb
feat: bots
TomMcL Mar 5, 2024
f59ea83
Merge remote-tracking branch 'origin/develop' into feat/cfm_bot
TomMcL Mar 6, 2024
8396f8d
feat: AMM config
TomMcL Mar 12, 2024
efd7f09
feat: Bounds check
TomMcL Mar 12, 2024
7a658b5
feat: Bounds check
TomMcL Mar 12, 2024
af3a049
feat: Bounds check
TomMcL Mar 12, 2024
0298453
feat: Bounds check
TomMcL Mar 12, 2024
9572d96
feat: Bounds check
TomMcL Mar 12, 2024
6927874
feat: Bounds check
TomMcL Mar 12, 2024
36b0bf6
feat: Bounds check
TomMcL Mar 12, 2024
5101355
feat: new market
TomMcL Mar 20, 2024
3b3b33f
feat: Fix eqs
TomMcL Mar 22, 2024
9662971
feat: Updates
TomMcL Apr 7, 2024
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
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=27fad9af4d7810d753b4adfc7a6553446be72402
VEGA_SIM_VEGA_TAG=d098780b8f64322aee9f5e0eafca5398cd974a18
VEGA_SIM_CONSOLE_TAG=develop
VEGA_DEFAULT_KEY_NAME='Key 1'
VEGA_SIM_NETWORKS_INTERNAL_TAG=main
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pipeline {
disableConcurrentBuilds(abortPrevious: true)
}
parameters {
string( name: 'VEGA_VERSION', defaultValue: '27fad9af4d7810d753b4adfc7a6553446be72402',
string( name: 'VEGA_VERSION', defaultValue: 'd098780b8f64322aee9f5e0eafca5398cd974a18',
description: 'Git branch, tag or hash of the vegaprotocol/vega repository')
string( name: 'VEGACAPSULE_VERSION', defaultValue: 'main',
description: 'Git branch, tag or hash of the vegaprotocol/vegacapsule repository')
Expand Down
48 changes: 30 additions & 18 deletions vega_sim/api/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -550,9 +550,11 @@ def _order_submission_from_proto(
size=num_from_padded_int(order_submission.size, decimal_spec.position_decimals),
side=order_submission.side,
time_in_force=order_submission.time_in_force,
expires_at=datetime.datetime.fromtimestamp(order_submission.expires_at / 1e9)
if order_submission.expires_at != 0
else None,
expires_at=(
datetime.datetime.fromtimestamp(order_submission.expires_at / 1e9)
if order_submission.expires_at != 0
else None
),
type=order_submission.type,
reference=order_submission.reference,
pegged_order=_pegged_order_from_proto(
Expand All @@ -572,28 +574,38 @@ def _stop_order_from_proto(
return StopOrder(
id=stop_order.id,
oco_link_id=stop_order.oco_link_id,
expires_at=datetime.datetime.fromtimestamp(stop_order.expires_at / 1e9)
if stop_order.expires_at != 0
else None,
expires_at=(
datetime.datetime.fromtimestamp(stop_order.expires_at / 1e9)
if stop_order.expires_at != 0
else None
),
expiry_strategy=stop_order.expiry_strategy,
trigger_direction=stop_order.trigger_direction,
status=stop_order.status,
created_at=datetime.datetime.fromtimestamp(stop_order.created_at / 1e9)
if stop_order.created_at != 0
else None,
updated_at=datetime.datetime.fromtimestamp(stop_order.updated_at / 1e9)
if stop_order.updated_at != 0
else None,
created_at=(
datetime.datetime.fromtimestamp(stop_order.created_at / 1e9)
if stop_order.created_at != 0
else None
),
updated_at=(
datetime.datetime.fromtimestamp(stop_order.updated_at / 1e9)
if stop_order.updated_at != 0
else None
),
order_id=stop_order.order_id,
party_id=stop_order.party_id,
market_id=stop_order.market_id,
rejection_reason=stop_order.rejection_reason,
price=num_from_padded_int(stop_order.price, decimal_spec.price_decimals)
if stop_order.price is not None
else None,
trailing_percent_offset=float(stop_order.trailing_percent_offset)
if stop_order.trailing_percent_offset != ""
else None,
price=(
num_from_padded_int(stop_order.price, decimal_spec.price_decimals)
if stop_order.price is not None
else None
),
trailing_percent_offset=(
float(stop_order.trailing_percent_offset)
if stop_order.trailing_percent_offset != ""
else None
),
)


Expand Down
12 changes: 7 additions & 5 deletions vega_sim/api/data_raw.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,9 @@ def get_trades(
party_ids=[party_id] if party_id is not None else None,
order_ids=[order_id] if order_id is not None else None,
date_range=data_node_protos_v2.trading_data.DateRange(
start_timestamp=int(start.timestamp() * 1e9)
if start is not None
else None,
start_timestamp=(
int(start.timestamp() * 1e9) if start is not None else None
),
end_timestamp=int(end.timestamp() * 1e9) if end is not None else None,
),
),
Expand Down Expand Up @@ -593,12 +593,14 @@ def list_ledger_entries(
base_request.date_range.CopyFrom(
data_node_protos_v2.trading_data.DateRange(
start_timestamp=(
from_datetime.timestamp() * 1e9
int(from_datetime.timestamp() * 1e9)
if from_datetime is not None
else None
),
end_timestamp=(
to_datetime.timestamp() * 1e9 if to_datetime is not None else None
int(to_datetime.timestamp() * 1e9)
if to_datetime is not None
else None
),
)
)
Expand Down
1 change: 0 additions & 1 deletion vega_sim/api/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@

"""

import copy
import functools
import logging
from typing import Optional, Union
Expand Down
2 changes: 0 additions & 2 deletions vega_sim/local_data_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,8 +641,6 @@ def get_accounts_from_stream(
and acct.type != vega_protos.vega.AccountType.ACCOUNT_TYPE_GENERAL
):
continue
if market_id is None and acct.market_id != "":
continue
if asset_id is not None and acct.asset != asset_id:
continue
results.append(acct)
Expand Down
4 changes: 2 additions & 2 deletions vega_sim/proto/blockexplorer/api/v1/blockexplorer_pb2.py

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

1,514 changes: 764 additions & 750 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.py

Large diffs are not rendered by default.

45 changes: 40 additions & 5 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,30 @@ class PageInfo(_message.Message):
end_cursor: _Optional[str] = ...,
) -> None: ...

class GetPartyVestingStatsRequest(_message.Message):
__slots__ = ["party_id"]
PARTY_ID_FIELD_NUMBER: _ClassVar[int]
party_id: str
def __init__(self, party_id: _Optional[str] = ...) -> None: ...

class GetPartyVestingStatsResponse(_message.Message):
__slots__ = ["party_id", "reward_bonus_multiplier", "epoch_seq", "quantum_balance"]
PARTY_ID_FIELD_NUMBER: _ClassVar[int]
REWARD_BONUS_MULTIPLIER_FIELD_NUMBER: _ClassVar[int]
EPOCH_SEQ_FIELD_NUMBER: _ClassVar[int]
QUANTUM_BALANCE_FIELD_NUMBER: _ClassVar[int]
party_id: str
reward_bonus_multiplier: str
epoch_seq: int
quantum_balance: str
def __init__(
self,
party_id: _Optional[str] = ...,
reward_bonus_multiplier: _Optional[str] = ...,
epoch_seq: _Optional[int] = ...,
quantum_balance: _Optional[str] = ...,
) -> None: ...

class GetVestingBalancesSummaryRequest(_message.Message):
__slots__ = ["party_id", "asset_id"]
PARTY_ID_FIELD_NUMBER: _ClassVar[int]
Expand Down Expand Up @@ -1093,18 +1117,21 @@ class MarketDataConnection(_message.Message):
) -> None: ...

class ListTransfersRequest(_message.Message):
__slots__ = ["pubkey", "direction", "pagination"]
__slots__ = ["pubkey", "direction", "pagination", "is_reward"]
PUBKEY_FIELD_NUMBER: _ClassVar[int]
DIRECTION_FIELD_NUMBER: _ClassVar[int]
PAGINATION_FIELD_NUMBER: _ClassVar[int]
IS_REWARD_FIELD_NUMBER: _ClassVar[int]
pubkey: str
direction: TransferDirection
pagination: Pagination
is_reward: bool
def __init__(
self,
pubkey: _Optional[str] = ...,
direction: _Optional[_Union[TransferDirection, str]] = ...,
pagination: _Optional[_Union[Pagination, _Mapping]] = ...,
is_reward: bool = ...,
) -> None: ...

class ListTransfersResponse(_message.Message):
Expand Down Expand Up @@ -4353,25 +4380,25 @@ class ListReferralSetRefereesRequest(_message.Message):
"pagination",
"referrer",
"referee",
"aggregation_days",
"aggregation_epochs",
]
REFERRAL_SET_ID_FIELD_NUMBER: _ClassVar[int]
PAGINATION_FIELD_NUMBER: _ClassVar[int]
REFERRER_FIELD_NUMBER: _ClassVar[int]
REFEREE_FIELD_NUMBER: _ClassVar[int]
AGGREGATION_DAYS_FIELD_NUMBER: _ClassVar[int]
AGGREGATION_EPOCHS_FIELD_NUMBER: _ClassVar[int]
referral_set_id: str
pagination: Pagination
referrer: str
referee: str
aggregation_days: int
aggregation_epochs: int
def __init__(
self,
referral_set_id: _Optional[str] = ...,
pagination: _Optional[_Union[Pagination, _Mapping]] = ...,
referrer: _Optional[str] = ...,
referee: _Optional[str] = ...,
aggregation_days: _Optional[int] = ...,
aggregation_epochs: _Optional[int] = ...,
) -> None: ...

class ListReferralSetRefereesResponse(_message.Message):
Expand Down Expand Up @@ -4445,6 +4472,8 @@ class ReferralSetStats(_message.Message):
"epoch_notional_taker_volume",
"rewards_multiplier",
"rewards_factor_multiplier",
"was_eligible",
"referrer_taker_volume",
]
AT_EPOCH_FIELD_NUMBER: _ClassVar[int]
REFERRAL_SET_RUNNING_NOTIONAL_TAKER_VOLUME_FIELD_NUMBER: _ClassVar[int]
Expand All @@ -4454,6 +4483,8 @@ class ReferralSetStats(_message.Message):
EPOCH_NOTIONAL_TAKER_VOLUME_FIELD_NUMBER: _ClassVar[int]
REWARDS_MULTIPLIER_FIELD_NUMBER: _ClassVar[int]
REWARDS_FACTOR_MULTIPLIER_FIELD_NUMBER: _ClassVar[int]
WAS_ELIGIBLE_FIELD_NUMBER: _ClassVar[int]
REFERRER_TAKER_VOLUME_FIELD_NUMBER: _ClassVar[int]
at_epoch: int
referral_set_running_notional_taker_volume: str
party_id: str
Expand All @@ -4462,6 +4493,8 @@ class ReferralSetStats(_message.Message):
epoch_notional_taker_volume: str
rewards_multiplier: str
rewards_factor_multiplier: str
was_eligible: bool
referrer_taker_volume: str
def __init__(
self,
at_epoch: _Optional[int] = ...,
Expand All @@ -4472,6 +4505,8 @@ class ReferralSetStats(_message.Message):
epoch_notional_taker_volume: _Optional[str] = ...,
rewards_multiplier: _Optional[str] = ...,
rewards_factor_multiplier: _Optional[str] = ...,
was_eligible: bool = ...,
referrer_taker_volume: _Optional[str] = ...,
) -> None: ...

class Team(_message.Message):
Expand Down
48 changes: 48 additions & 0 deletions vega_sim/proto/data_node/api/v2/trading_data_pb2_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,11 @@ def __init__(self, channel):
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetVestingBalancesSummaryRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetVestingBalancesSummaryResponse.FromString,
)
self.GetPartyVestingStats = channel.unary_unary(
"/datanode.api.v2.TradingDataService/GetPartyVestingStats",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsRequest.SerializeToString,
response_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsResponse.FromString,
)
self.ExportNetworkHistory = channel.unary_stream(
"/datanode.api.v2.TradingDataService/ExportNetworkHistory",
request_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ExportNetworkHistoryRequest.SerializeToString,
Expand Down Expand Up @@ -1612,6 +1617,15 @@ def GetVestingBalancesSummary(self, request, context):
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def GetPartyVestingStats(self, request, context):
"""Get vesting balance statistics

Get information about a party's vesting rewards
"""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
context.set_details("Method not implemented!")
raise NotImplementedError("Method not implemented!")

def ExportNetworkHistory(self, request, context):
"""Export network history as CSV

Expand Down Expand Up @@ -2236,6 +2250,11 @@ def add_TradingDataServiceServicer_to_server(servicer, server):
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetVestingBalancesSummaryRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetVestingBalancesSummaryResponse.SerializeToString,
),
"GetPartyVestingStats": grpc.unary_unary_rpc_method_handler(
servicer.GetPartyVestingStats,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsRequest.FromString,
response_serializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsResponse.SerializeToString,
),
"ExportNetworkHistory": grpc.unary_stream_rpc_method_handler(
servicer.ExportNetworkHistory,
request_deserializer=data__node_dot_api_dot_v2_dot_trading__data__pb2.ExportNetworkHistoryRequest.FromString,
Expand Down Expand Up @@ -5418,6 +5437,35 @@ def GetVestingBalancesSummary(
metadata,
)

@staticmethod
def GetPartyVestingStats(
request,
target,
options=(),
channel_credentials=None,
call_credentials=None,
insecure=False,
compression=None,
wait_for_ready=None,
timeout=None,
metadata=None,
):
return grpc.experimental.unary_unary(
request,
target,
"/datanode.api.v2.TradingDataService/GetPartyVestingStats",
data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsRequest.SerializeToString,
data__node_dot_api_dot_v2_dot_trading__data__pb2.GetPartyVestingStatsResponse.FromString,
options,
channel_credentials,
insecure,
call_credentials,
compression,
wait_for_ready,
timeout,
metadata,
)

@staticmethod
def ExportNetworkHistory(
request,
Expand Down
Loading
Loading