Skip to content

Commit

Permalink
Renamed strategy to avellaneda_market_making_
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasbaum committed Apr 1, 2021
1 parent f7460c1 commit f68d76b
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 40 deletions.
6 changes: 6 additions & 0 deletions hummingbot/strategy/avellaneda_market_making/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env python

from .avellaneda_market_making import AvellanedaMarketMakingStrategy
__all__ = [
AvellanedaMarketMakingStrategy,
]
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ from libc.stdint cimport int64_t
from hummingbot.strategy.strategy_base cimport StrategyBase


cdef class FieldfareMarketMakingStrategy(StrategyBase):
cdef class AvellanedaMarketMakingStrategy(StrategyBase):
cdef:
object _market_info
object _minimum_spread
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ s_decimal_one = Decimal(1)
pmm_logger = None


cdef class FieldfareMarketMakingStrategy(StrategyBase):
cdef class AvellanedaMarketMakingStrategy(StrategyBase):
OPTION_LOG_CREATE_ORDER = 1 << 3
OPTION_LOG_MAKER_ORDER_FILLED = 1 << 4
OPTION_LOG_STATUS_REPORT = 1 << 5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,44 +22,44 @@


def maker_trading_pair_prompt():
exchange = fieldfare_market_making_config_map.get("exchange").value
exchange = avellaneda_market_making_config_map.get("exchange").value
example = EXAMPLE_PAIRS.get(exchange)
return "Enter the token trading pair you would like to trade on %s%s >>> " \
% (exchange, f" (e.g. {example})" if example else "")


# strategy specific validators
def validate_exchange_trading_pair(value: str) -> Optional[str]:
exchange = fieldfare_market_making_config_map.get("exchange").value
exchange = avellaneda_market_making_config_map.get("exchange").value
return validate_market_trading_pair(exchange, value)


def validate_max_spread(value: str) -> Optional[str]:
validate_decimal(value, 0, 100, inclusive=False)
if fieldfare_market_making_config_map["min_spread"].value is not None:
min_spread = Decimal(fieldfare_market_making_config_map["min_spread"].value)
if avellaneda_market_making_config_map["min_spread"].value is not None:
min_spread = Decimal(avellaneda_market_making_config_map["min_spread"].value)
max_spread = Decimal(value)
if min_spread >= max_spread:
return f"Max spread cannot be lesser or equal to min spread {max_spread}%<={min_spread}%"


def onvalidated_min_spread(value: str):
# If entered valid min_spread, max_spread is invalidated so user sets it up again
fieldfare_market_making_config_map["max_spread"].value = None
avellaneda_market_making_config_map["max_spread"].value = None


async def order_amount_prompt() -> str:
exchange = fieldfare_market_making_config_map["exchange"].value
trading_pair = fieldfare_market_making_config_map["market"].value
exchange = avellaneda_market_making_config_map["exchange"].value
trading_pair = avellaneda_market_making_config_map["market"].value
base_asset, quote_asset = trading_pair.split("-")
min_amount = await minimum_order_amount(exchange, trading_pair)
return f"What is the amount of {base_asset} per order? (minimum {min_amount}) >>> "


async def validate_order_amount(value: str) -> Optional[str]:
try:
exchange = fieldfare_market_making_config_map["exchange"].value
trading_pair = fieldfare_market_making_config_map["market"].value
exchange = avellaneda_market_making_config_map["exchange"].value
trading_pair = avellaneda_market_making_config_map["market"].value
min_amount = await minimum_order_amount(exchange, trading_pair)
if Decimal(value) < min_amount:
return f"Order amount must be at least {min_amount}."
Expand All @@ -69,7 +69,7 @@ async def validate_order_amount(value: str) -> Optional[str]:

def on_validated_price_source_exchange(value: str):
if value is None:
fieldfare_market_making_config_map["price_source_market"].value = None
avellaneda_market_making_config_map["price_source_market"].value = None


def exchange_on_validated(value: str):
Expand All @@ -78,21 +78,21 @@ def exchange_on_validated(value: str):

def on_validated_parameters_based_on_spread(value: str):
if value == 'True':
fieldfare_market_making_config_map.get("risk_factor").value = None
fieldfare_market_making_config_map.get("order_book_depth_factor").value = None
fieldfare_market_making_config_map.get("order_amount_shape_factor").value = None
avellaneda_market_making_config_map.get("risk_factor").value = None
avellaneda_market_making_config_map.get("order_book_depth_factor").value = None
avellaneda_market_making_config_map.get("order_amount_shape_factor").value = None
else:
fieldfare_market_making_config_map.get("max_spread").value = None
fieldfare_market_making_config_map.get("min_spread").value = None
fieldfare_market_making_config_map.get("vol_to_spread_multiplier").value = None
fieldfare_market_making_config_map.get("inventory_risk_aversion").value = None
avellaneda_market_making_config_map.get("max_spread").value = None
avellaneda_market_making_config_map.get("min_spread").value = None
avellaneda_market_making_config_map.get("vol_to_spread_multiplier").value = None
avellaneda_market_making_config_map.get("inventory_risk_aversion").value = None


fieldfare_market_making_config_map = {
avellaneda_market_making_config_map = {
"strategy":
ConfigVar(key="strategy",
prompt=None,
default="fieldfare_market_making"),
default="avellaneda_market_making"),
"exchange":
ConfigVar(key="exchange",
prompt="Enter your maker spot connector >>> ",
Expand Down Expand Up @@ -129,7 +129,7 @@ def on_validated_parameters_based_on_spread(value: str):
prompt="Enter the minimum spread allowed from mid-price in percentage "
"(Enter 1 to indicate 1%) >>> ",
type_str="decimal",
required_if=lambda: fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 0, 100, inclusive=False),
prompt_on_new=True,
on_validated=onvalidated_min_spread),
Expand All @@ -138,15 +138,15 @@ def on_validated_parameters_based_on_spread(value: str):
prompt="Enter the maximum spread allowed from mid-price in percentage "
"(Enter 1 to indicate 1%) >>> ",
type_str="decimal",
required_if=lambda: fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_max_spread(v),
prompt_on_new=True),
"vol_to_spread_multiplier":
ConfigVar(key="vol_to_spread_multiplier",
prompt="Enter the Volatility threshold multiplier (Should be greater than 1.0): "
"(If market volatility multiplied by this value is above the maximum spread, it will increase the maximum spread value) >>>",
type_str="decimal",
required_if=lambda: fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 1, 10, inclusive=False),
prompt_on_new=True),
"inventory_risk_aversion":
Expand All @@ -155,31 +155,31 @@ def on_validated_parameters_based_on_spread(value: str):
"skewed to meet the inventory target, while close to 0.001 spreads will be close to symmetrical, "
"increasing profitability but also increasing inventory risk)>>>",
type_str="decimal",
required_if=lambda: fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 0, 1, inclusive=False),
prompt_on_new=True),
"order_book_depth_factor":
ConfigVar(key="order_book_depth_factor",
printable_key="order_book_depth_factor(\u03BA)",
prompt="Enter order book depth factor (\u03BA) >>> ",
type_str="decimal",
required_if=lambda: not fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: not avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 0, 1e10, inclusive=False),
prompt_on_new=True),
"risk_factor":
ConfigVar(key="risk_factor",
printable_key="risk_factor(\u03B3)",
prompt="Enter risk factor (\u03B3) >>> ",
type_str="decimal",
required_if=lambda: not fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: not avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 0, 1e10, inclusive=False),
prompt_on_new=True),
"order_amount_shape_factor":
ConfigVar(key="order_amount_shape_factor",
printable_key="order_amount_shape_factor(\u03B7)",
prompt="Enter order amount shape factor (\u03B7) >>> ",
type_str="decimal",
required_if=lambda: not fieldfare_market_making_config_map.get("parameters_based_on_spread").value,
required_if=lambda: not avellaneda_market_making_config_map.get("parameters_based_on_spread").value,
validator=lambda v: validate_decimal(v, 0, 1, inclusive=True),
prompt_on_new=True),
"closing_time":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
import os.path
from hummingbot.client.hummingbot_application import HummingbotApplication
from hummingbot.strategy.market_trading_pair_tuple import MarketTradingPairTuple
from hummingbot.strategy.fieldfare_market_making import (
FieldfareMarketMakingStrategy,
from hummingbot.strategy.avellaneda_market_making import (
AvellanedaMarketMakingStrategy,
)
from hummingbot.strategy.fieldfare_market_making.fieldfare_market_making_config_map import fieldfare_market_making_config_map as c_map
from hummingbot.strategy.avellaneda_market_making.avellaneda_market_making_config_map import avellaneda_market_making_config_map as c_map
from decimal import Decimal
import pandas as pd

Expand All @@ -37,7 +37,7 @@ def start(self):
maker_data = [self.markets[exchange], trading_pair] + list(maker_assets)
self.market_trading_pair_tuples = [MarketTradingPairTuple(*maker_data)]

strategy_logging_options = FieldfareMarketMakingStrategy.OPTION_LOG_ALL
strategy_logging_options = AvellanedaMarketMakingStrategy.OPTION_LOG_ALL
parameters_based_on_spread = c_map.get("parameters_based_on_spread").value
if parameters_based_on_spread:
risk_factor = order_book_depth_factor = order_amount_shape_factor = None
Expand All @@ -56,7 +56,7 @@ def start(self):
HummingbotApplication.main_application().strategy_file_name.rsplit('.', 1)[0] +
f"_{pd.Timestamp.now().strftime('%Y-%m-%d_%H-%M-%S')}.csv")

self.strategy = FieldfareMarketMakingStrategy(
self.strategy = AvellanedaMarketMakingStrategy(
market_info=MarketTradingPairTuple(*maker_data),
order_amount=order_amount,
order_optimization_enabled=order_optimization_enabled,
Expand Down
6 changes: 0 additions & 6 deletions hummingbot/strategy/fieldfare_market_making/__init__.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
########################################################
### Fieldfare market making strategy config ###
### Avellaneda market making strategy config ###
########################################################

template_version: 1
Expand Down

0 comments on commit f68d76b

Please sign in to comment.