OlympusTrader.insight package

Subpackages

Submodules

OlympusTrader.insight.insight module

class OlympusTrader.insight.insight.IInsight(insight: 'Insight')

Bases: object

RRR: float
TTL_filled: float
TTL_unfilled: float
cancelling: bool
children: dict[UUID, Self]
close_order_id: str | None
close_price: float | None
closed_at: datetime | None
closing: bool
confidence: float
contracts: float | None
created_at: datetime
execution_dependency: str
filled_at: datetime | None
first_on_fill: bool
insight_id: str
legs: IOrderLegs
limit_price: float
marketChanged: bool
order_id: str
parent: str | None
partial_closes: list[PartialCloseResult]
partial_filled_quantity: float
quantity: float
side: str
state: str
stop_loss: float | None
strategy: str | None
submited: bool
symbol: str
take_profit: float | None
type: str
updated_at: datetime
useContractSize: bool
class OlympusTrader.insight.insight.Insight(side: IOrderSide, symbol: str, strategyType: StrategyTypes | str, tf: ITimeFrame, quantity: float | None = 1, limit_price: float | None = None, TP: List[float] | None = None, SL: float | None = None, confidence: float = 0.1, executionDepends: List[StrategyDependantConfirmation] = [StrategyDependantConfirmation.NONE], periodUnfilled: int = 2, periodTillTp: int = 10, parent: UUID | None = None, stop_price: float | None = None)

Bases: object

ASSET: IAsset = None
BROKER: BaseBroker = None
CHILDREN: dict[UUID, Self]
INSIGHT_ID: UUID

Unique Insight ID

MODE: IStrategyMode = 'Live'
PARENT: UUID | None = None

Parent Insight ID

SL: float | None = None

Stop loss level

TP: List[float] | None = None

Take profit levels - The last index is the final take profit level

addChildInsight(side: IOrderSide, quantity: float | None = None, limit_price: float | None = None, TP: List[float] | None = None, SL: float | None = None, executionDepends: List[StrategyDependantConfirmation] = [StrategyDependantConfirmation.NONE], periodUnfilled: int = None, periodTillTp: int = None) Self

Add a child insight to the parent insight. The child insight will be executed after the parent insight is filled.

cancel()
cancelStopLossLeg()
cancelTakeProfitLeg()
cancel_order_by_id(order_id: str)
checkIfCanShort(shouldUpdateState: bool = False)

Check if the asset is shortable. If the asset is not shortable, the insight will be rejected.

checkValidEntryInsight(limit_price: float = None, bypassCheck: bool = False)

Check if the insight is valid. limitprice needs to be beween the take profit and stop loss.

checkValidQuantity(shouldUpdateState: bool = False)
classType: IOrderClass = None
close(price: float | None = None, quantity: float | None = None, retry: bool = True, bypassStateCheck: bool = False)

Used to close a Insight (position) or to partially close a position (if you have multiple take profit levels)

close_order_id = None

Close Order ID for the Insight that closed the position

close_price: float | None = None
closedAt: datetime | None = None
confidence: float = None
contracts: float | None = None
convert_quantity_to_contracts()
createAt: datetime = datetime.datetime(2025, 12, 16, 12, 9, 34, 422313)
property dataclass
executionDepends: List[StrategyDependantConfirmation] = [StrategyDependantConfirmation.NONE]
filledAt: datetime | None = None
getPL(includePartialCloses: bool = True)
getPnLRatio()
hasExhaustedTTL(shouldUpdateState: bool = False)
hasExpired(shouldUpdateState: bool = False) bool | None

Check if the insight has expired. If the insight is not filled within the time to live period, it will be canceled. If the insight is filled, it will be closed after the time to live till take profit has expired.

legs: IOrderLegs = {'stop_loss': None, 'take_profit': None, 'trailing_stop': None}
limit_price: float | None = None

Entry Price or the stop limit price if the order is a stop limit

logPnL()
marketChanged: bool = False
opposite_side: IOrderSide = None
order_id: str = None

Main Order ID for the Insight that entered the position

partialFilled(qty: float)
partial_closes: list[PartialCloseResult] = []
periodTillTp: int | None = None
periodUnfilled: int | None = None
positionClosed(price: float, close_order_id: str, qty: float = None)
positionFilled(price: float, qty: float, order_id: str = None)
quantity: float | None = None
set_mode(broker: get_BaseBroker, asset: IAsset, mode: IStrategyMode = IStrategyMode.LIVE)
side: IOrderSide = None
state: InsightState = 'NEW'

State of the Insight

property stopLossOrderLeg
stop_price: float | None = None

Stop Price

strategyType: StrategyTypes | str | None = None
submit(rejectInvalid: bool = True, partialCloseInsight: Self | None = None, closeInsight: Self | None = None)
symbol: str = None
property takeProfitOrderLeg
tf: ITimeFrame = None
property trailingStopOrderLeg
type: IOrderType = None
updateCloseOrderID(close_order_id: str)
updateLegs(legs: IOrderLegs)

Update the order legs for the insight.

updateOrderID(order_id: str)
updateState(state: InsightState | None = None, message: str = None)
updateStopLoss(SL: float, bypassCheck: bool = False)
updateStopLossLegs(leg: IOrderLeg)
updateSubmited(submited: bool)
updateTakeProfit(takeProfitLevels: list[float] | float, bypassCheck: bool = False)
updateTakeProfitLegs(leg: IOrderLeg)
updateTrailingStopLegs(leg: IOrderLeg)
update_contracts(contracts: float)
update_limit_price(price: float, updateToLimit: bool = False)
update_market_changed(marketChanged: bool, shouldCloseOrCancel: bool = False)
update_quantity(quantity: float)
updatedAt: datetime = datetime.datetime(2025, 12, 16, 12, 9, 34, 422316)
property uses_contract_size
validate() tuple[bool, str | None]

Validate the insight before submitting it to the broker.

class OlympusTrader.insight.insight.InsightState(*values)

Bases: Enum

CANCELED = 'CANCELED'
CLOSED = 'CLOSED'
EXECUTED = 'EXECUTED'
FILLED = 'FILLED'
NEW = 'NEW'
REJECTED = 'REJECTED'
class OlympusTrader.insight.insight.PartialCloseResult(order_id: str, side: IOrderSide, quantity: float, price: float)

Bases: object

entry_price: float
filled_price: float
getPL()
order_id: str
quantity: float
set_filled_price(filled_price: float)
side: IOrderSide
class OlympusTrader.insight.insight.StrategyDependantConfirmation(*values)

Bases: Enum

DOWNSTATE = 'Down State Confirmation Model'
FLATSTATE = 'Flat State Confirmation Model'
HCCM = 'High Confidence Confirmation Model'
HRVCM = 'High Relative Volume Confirmation Model'
HTFCM = 'High Time Frame Confirmation Model'
LCCM = 'Low Confidence Confirmation Model'
LRVCM = 'Low Relative Volume Confirmation Model'
LTFCM = 'Low Time Frame Confirmation Model'
NONE = 'NONE'
UPSTATE = 'Up State Confirmation Model'
class OlympusTrader.insight.insight.StrategyTypes(*values)

Bases: Enum

MANUAL = 'MANUAL'
TEST = 'TESTING'
OlympusTrader.insight.insight.get_BaseBroker()

Module contents