Skip to content

Commit

Permalink
[Community] update position keys
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeDSM committed Dec 16, 2024
1 parent c3da578 commit 713625f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion octobot/community/models/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,13 @@ def _format_trade(trade: dict, exchange_name: str, bot_id: str):
def format_positions(positions: list, exchange_name: str) -> list:
return [
{
# local changes
backend_enums.PositionKeys.EXCHANGE.value: exchange_name,
backend_enums.PositionKeys.TIME.value: position[trading_enums.ExchangeConstantsPositionColumns.TIMESTAMP.value],
backend_enums.PositionKeys.POSITION_ID.value: position[trading_enums.ExchangeConstantsPositionColumns.ID.value],
# from trading positions
backend_enums.PositionKeys.SYMBOL.value: position[trading_enums.ExchangeConstantsPositionColumns.SYMBOL.value],
backend_enums.PositionKeys.STATUS.value: position[trading_enums.ExchangeConstantsPositionColumns.STATUS.value],
backend_enums.PositionKeys.TIMESTAMP.value: position[trading_enums.ExchangeConstantsPositionColumns.TIMESTAMP.value],
backend_enums.PositionKeys.SIDE.value: position[trading_enums.ExchangeConstantsPositionColumns.SIDE.value],
backend_enums.PositionKeys.QUANTITY.value: float(position[trading_enums.ExchangeConstantsPositionColumns.QUANTITY.value])
if position[trading_enums.ExchangeConstantsPositionColumns.QUANTITY.value] else 0,
Expand Down
3 changes: 2 additions & 1 deletion octobot/community/supabase_backend/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ class OrderKeys(enum.Enum):

class PositionKeys(enum.Enum):
EXCHANGE = "exchange"
TIME = "time"
POSITION_ID = "position_id"
# subset of octobot_trading.enums.ExchangeConstantsPositionColumns
TIMESTAMP = "timestamp"
SYMBOL = "symbol"
ENTRY_PRICE = "entry_price"
MARK_PRICE = "mark_price"
Expand Down

0 comments on commit 713625f

Please sign in to comment.