Skip to content

Commit

Permalink
Refactor reducer to use redux toolkit
Browse files Browse the repository at this point in the history
This gets rid of multiple redux files, combining into one single redux "slice" file. Removes action creators and centralizes API calls.
  • Loading branch information
carkod committed Sep 28, 2024
1 parent 2d24df4 commit b4a4cfd
Show file tree
Hide file tree
Showing 15 changed files with 668 additions and 976 deletions.
5 changes: 2 additions & 3 deletions api/bots/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ class BotSchema(BaseModel):
created_at: float = time() * 1000
deal: DealModel = Field(default_factory=DealModel)
dynamic_trailling: bool = False
errors: list[str] = [] # Event logs
errors: list[str] = [] # Event logs
locked_so_funds: float = 0 # funds locked by Safety orders
mode: str = "manual" # Manual is triggered by the terminal dashboard, autotrade by research app
name: str = "Default bot"
orders: list[BinanceOrderModel] = [] # Internal
status: Status = Status.inactive
stop_loss: float = 0
margin_short_reversal: bool = False # If stop_loss > 0, allow for reversal
margin_short_reversal: bool = False # If stop_loss > 0, allow for reversal
take_profit: float = 0
trailling: bool = True
trailling_deviation: float = 0
Expand Down Expand Up @@ -93,7 +93,6 @@ class BotSchema(BaseModel):
}
}


@field_validator("pair", "base_order_size", "candlestick_interval")
@classmethod
def check_names_not_empty(cls, v):
Expand Down
3 changes: 2 additions & 1 deletion api/deals/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class DealModel(BaseModel):
sell_price: float = 0
sell_qty: float = 0
trailling_stop_loss_price: float = 0
trailling_profit_price: float = 0 # take_profit but for trailling, to avoid confusion, trailling_profit_price always be > trailling_stop_loss_price
trailling_profit_price: float = 0 # take_profit but for trailling, to avoid confusion, trailling_profit_price always be > trailling_stop_loss_price
stop_loss_price: float = 0
trailling_profit: float = 0
so_prices: float = 0
Expand Down Expand Up @@ -107,6 +107,7 @@ def check_prices(cls, v):
return float(v)
return v


class SafetyOrderModel(BaseModel):
buy_price: float
so_size: float
Expand Down
1 change: 1 addition & 0 deletions api/deals/schema.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from deals.models import BinanceOrderModel


class MarginOrderSchema(BinanceOrderModel):
margin_buy_borrow_amount: int = 0
margin_buy_borrow_asset: str = "USDC"
Expand Down
2 changes: 2 additions & 0 deletions api/tools/enum_definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ class DealType(str, Enum):
def __str__(self):
return str(self.str)


class BinanceKlineIntervals(str, Enum):
one_minute = "1m"
three_minutes = "3m"
Expand All @@ -154,6 +155,7 @@ class BinanceKlineIntervals(str, Enum):
def __str__(self):
return str(self.str)


class AutotradeSettingsDocument(str, Enum):
# Autotrade settings for test bots
test_autotrade_settings = "test_autotrade_settings"
Expand Down
8 changes: 8 additions & 0 deletions web/environment.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
NODE_ENV: 'development' | 'production';
PORT?: string;
}
}
}
2 changes: 1 addition & 1 deletion web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@testing-library/react": "^12.1.1",
"@testing-library/user-event": "^14.1.1",
"@types/jest": "^29.5.5",
"@types/node": "^20.8.6",
"@types/node": "^22.7.4",
"@types/react": "^18.2.28",
"@types/react-dom": "^18.2.13",
"@types/react-router-dom": "^5.3.3",
Expand Down
Loading

0 comments on commit b4a4cfd

Please sign in to comment.