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
Changes from 1 commit
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
Prev Previous commit
Next Next commit
feat: Tweaks to scenario
TomMcL committed Oct 25, 2023
commit 7e5b19251fe92950b8cce84da7aabcb1b0da092c
18 changes: 9 additions & 9 deletions vega_sim/local_data_cache.py
Original file line number Diff line number Diff line change
@@ -416,15 +416,15 @@ def initialise_market_data(
]
with self.market_data_lock:
for market_id in market_ids:
self.market_data_from_feed_store[market_id] = (
data.get_latest_market_data(
market_id,
data_client=self._trading_data_client,
market_price_decimals_map=self._market_price_decimals,
market_position_decimals_map=self._market_pos_decimals,
asset_decimals_map=self._asset_decimals,
market_to_asset_map=self._market_to_asset,
)
self.market_data_from_feed_store[
market_id
] = data.get_latest_market_data(
market_id,
data_client=self._trading_data_client,
market_price_decimals_map=self._market_price_decimals,
market_position_decimals_map=self._market_pos_decimals,
asset_decimals_map=self._asset_decimals,
market_to_asset_map=self._market_to_asset,
)

def initialise_transfer_monitoring(
2 changes: 0 additions & 2 deletions vega_sim/proto/vega/events/v1/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
from . import __pycache__
from . import events_pb2 as events
from . import events_pb2_grpc as events_grpc

__all__ = [
"__pycache__",
"events",
"events_grpc",
]
4 changes: 3 additions & 1 deletion vega_sim/scenario/common/agents.py
Original file line number Diff line number Diff line change
@@ -1097,7 +1097,9 @@ def __init__(
self.initial_mint = (
initial_mint
if initial_mint is not None
else (2 * commitment_amount) if commitment_amount is not None else 100
else (2 * commitment_amount)
if commitment_amount is not None
else 100
)

self.market_name = market_name
25 changes: 13 additions & 12 deletions vega_sim/scenario/constant_function_market/agents.py
Original file line number Diff line number Diff line change
@@ -18,12 +18,7 @@ def _price_for_size(
k_scaling_large: float,
k_scaling_small: float,
trade_size: float,
# pool_size: float,
) -> float:
# sell_pool = pool_size / (last_trade + 1)
# buy_pool = pool_size - sell_pool
# mid = buy_pool / sell_pool

if side == vega_protos.Side.SIDE_SELL:
k_scaling = k_scaling_small if position >= 0 else k_scaling_large

@@ -245,7 +240,8 @@ def __init__(
initial_price: float = 100,
price_width_below: float = 0.05,
price_width_above: float = 0.05,
margin_usage_at_bounds: float = 0.8,
margin_usage_at_bound_above: float = 0.8,
margin_usage_at_bound_below: float = 0.8,
initial_asset_mint: float = 1000000,
market_name: str = None,
asset_name: str = None,
@@ -294,7 +290,8 @@ def __init__(
self.lower_liq_factor = 1 / (self.base_price_sqrt - self.lower_price_sqrt)
self.upper_liq_factor = 1 / (self.upper_price_sqrt - self.base_price_sqrt)

self.margin_usage_at_bounds = margin_usage_at_bounds
self.margin_usage_at_bound_above = margin_usage_at_bound_above
self.margin_usage_at_bound_below = margin_usage_at_bound_below

self.tick_spacing = tick_spacing
self.num_levels = num_levels
@@ -333,7 +330,9 @@ def _quantity_for_move(
end_price_sqrt,
range_upper_price_sqrt,
liquidity_factor,
) -> float:
) -> Optional[float]:
if liquidity_factor == 0:
return None
start_fut_pos = (
liquidity_factor
* (range_upper_price_sqrt - start_price_sqrt)
@@ -365,12 +364,12 @@ def _calculate_price_levels(
self, ref_price: float, balance: float
) -> Tuple[List[MMOrder], List[MMOrder]]:
upper_L = (
self.margin_usage_at_bounds
self.margin_usage_at_bound_above
* (balance / self.short_factor)
* self.upper_liq_factor
)
lower_L = (
self.margin_usage_at_bounds
self.margin_usage_at_bound_below
* (balance / self.long_factor)
* self.lower_liq_factor
)
@@ -394,7 +393,8 @@ def _calculate_price_levels(
self.upper_price_sqrt,
upper_L if price > self.base_price else lower_L,
)
agg_asks.append(MMOrder(volume, price))
if volume is not None:
agg_asks.append(MMOrder(volume, price))

for i in range(1, self.num_levels):
pre_price_sqrt = (ref_price - (i - 1) * self.tick_spacing) ** 0.5
@@ -409,7 +409,8 @@ def _calculate_price_levels(
self.upper_price_sqrt,
upper_L if price > self.base_price else lower_L,
)
agg_bids.append(MMOrder(volume, price))
if volume is not None:
agg_bids.append(MMOrder(volume, price))

self.curr_bids = agg_bids
self.curr_asks = agg_asks
15 changes: 9 additions & 6 deletions vega_sim/scenario/constant_function_market/scenario.py
Copy link
Collaborator

Choose a reason for hiding this comment

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

Lots of commented out blocks of code in this file?

Is to switch up the scenario quickly or not intentional?

Original file line number Diff line number Diff line change
@@ -247,14 +247,17 @@ def configure_agents(
commitment_amount=1_000,
market_decimal_places=market_config.decimal_places,
fee_amount=0.001,
initial_price=price_process[0],
initial_price=max(price_process),
# initial_price=price_process[0],
num_levels=200,
tick_spacing=0.1,
price_width_above=0.2,
price_width_below=0.2,
margin_usage_at_bound_above=0,
margin_usage_at_bound_below=0.8,
asset_decimal_places=asset_dp,
tag="MARKET_CFM",
price_process_generator=iter(price_process),
tag="MARKET_CFM",
)
]

@@ -283,12 +286,12 @@ def configure_agents(
asset_name=asset_name,
price_process_generator=iter(price_process),
initial_asset_mint=self.initial_asset_mint,
buy_intensity=20,
sell_intensity=20,
buy_intensity=1,
sell_intensity=1,
spread_offset=0.0001,
tag=f"ARB_AGENT_{str(i_agent).zfill(3)}",
random_state=random_state,
base_order_size=0.1,
base_order_size=0.001,
wallet_name="ARB_TRADERS",
)
for i_agent in range(2)
@@ -379,7 +382,7 @@ def configure_environment(

with VegaServiceNull(
warn_on_raw_data_access=False,
run_with_console=True,
run_with_console=False,
use_full_vega_wallet=False,
retain_log_files=True,
launch_graphql=False,