forked from hummingbot/hummingbot
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request hummingbot#6915 from cardosofede/feat/twap_executor
Feat/twap executor
- Loading branch information
Showing
22 changed files
with
902 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
51 changes: 51 additions & 0 deletions
51
hummingbot/smart_components/executors/twap_executor/data_types.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from decimal import Decimal | ||
from enum import Enum | ||
from typing import Optional | ||
|
||
from pydantic import validator | ||
|
||
from hummingbot.core.data_type.common import OrderType, TradeType | ||
from hummingbot.smart_components.executors.data_types import ExecutorConfigBase | ||
|
||
|
||
class TWAPMode(Enum): | ||
MAKER = "MAKER" | ||
TAKER = "TAKER" | ||
|
||
|
||
class TWAPExecutorConfig(ExecutorConfigBase): | ||
type: str = "twap_executor" | ||
connector_name: str | ||
trading_pair: str | ||
side: TradeType | ||
leverage: int = 1 | ||
total_amount_quote: Decimal | ||
total_duration: int | ||
order_interval: int | ||
mode: TWAPMode = TWAPMode.TAKER | ||
|
||
# MAKER mode specific parameters | ||
limit_order_buffer: Optional[Decimal] = None | ||
order_resubmission_time: Optional[int] = None | ||
|
||
@validator('limit_order_buffer', pre=True, always=True) | ||
def validate_limit_order_buffer(cls, v, values): | ||
if v is None and values["mode"] == TWAPMode.MAKER: | ||
raise ValueError("limit_order_buffer is required for MAKER mode") | ||
return v | ||
|
||
@property | ||
def is_maker(self) -> bool: | ||
return self.mode == TWAPMode.MAKER | ||
|
||
@property | ||
def number_of_orders(self) -> int: | ||
return (self.total_duration // self.order_interval) + 1 | ||
|
||
@property | ||
def order_amount_quote(self) -> Decimal: | ||
return self.total_amount_quote / self.number_of_orders | ||
|
||
@property | ||
def order_type(self) -> OrderType: | ||
return OrderType.LIMIT if self.is_maker else OrderType.MARKET |
Oops, something went wrong.