OlympusTrader.utils package¶
Submodules¶
OlympusTrader.utils.timeframe module¶
- class OlympusTrader.utils.timeframe.ITimeFrame(amount, unit)¶
Bases:
objectA time interval specified in multiples of defined units (minute, day, etc)
- Attributes:
amount_value (int): The number of multiples of the ITimeFrameUnit interval unit_value (ITimeFrameUnit): The base unit of time interval that is used to measure the TimeFrame
- Raises:
ValueError: Raised if the amount_value and unit_value are not consistent with each other
- add_time_increment(time: datetime, periods: int) datetime¶
Add the time increment to the current time
- property amount: int¶
Returns the amount_value field
- Returns:
int: amount_value field
- amount_value: int¶
- get_next_time_increment(time: datetime) datetime¶
Get the next time frame increment
- get_time_increment(time: datetime) datetime¶
Get the current time frame
- is_time_increment(time: datetime) bool¶
return true if the current date time is in the frequency of the time of X min increments Args:
time (datetime): current time resolution (TimeFrame): TimeFrame object frequency (int, optional): frequency of the time. Defaults to 5.
- Returns:
bool: True if the current date time is in the frequency of the time of X Time Unit increments
Note: This will just match the Time Unit, not the exact time of the day. so will pass if the time is 12:00:00 or 12:00:59 same with dates and months Note: if your using this to execute a trade, you should check if the market is open first before executing a trade
- resample_bars_from_timeframe(df: DataFrame, base_timeframe: Self) tuple[bool, DataFrame]¶
Resample the bars from a dataframe to the specified timeframe
- to_timeDelta() timedelta¶
Return the TimeDelta object of the TimeFrame
- property unit: ITimeFrameUnit¶
Returns the ITimeFrameUnit field value of this TimeFrame object
- Returns:
ITimeFrameUnit: unit_value field
- unit_value: ITimeFrameUnit¶
- static validate_timeframe(amount: int, unit: ITimeFrameUnit)¶
Validates the amount value against the ITimeFrameUnit value for consistency
- Args:
amount (int): The number of multiples of unit unit (ITimeFrameUnit): The base unit of time interval the TimeFrame is measured by
- Raises:
ValueError: Raised if the values of amount and unit are not consistent with each other
- property value: str¶
Returns a string representation of this TimeFrame object for API consumption
- Returns:
str: string representation of this timeframe
OlympusTrader.utils.tools module¶
- class OlympusTrader.utils.tools.ITradingTools(strategy)¶
Bases:
object- STRATEGY = None¶
- calculateTimeToLive(price: float, entry: float, ATR: float, additional: int = 2) int¶
Calculate the time to live for a given price and entry based on the ATR
- dynamic_round(v: float, symbol: str) float¶
Round float depending on log10 decimal places
- get_all_unrealized_pnl() float¶
Calculate unrealized PnL for a given symbol
- get_filled_insights() list¶
Get all filled insights
- get_unrealized_pnl(symbol: str) float¶
Calculate unrealized PnL for a given symbol
- quantity_round(v: float, symbol: str) float¶
Round float depending on log10 decimal places
- OlympusTrader.utils.tools.dynamic_round(v: float) float¶
Round float depending on log10 decimal places
OlympusTrader.utils.types module¶
- class OlympusTrader.utils.types.AttributeDict¶
Bases:
dictThis is adds functions to the dictionary class, no other modifications. This gives dictionaries abilities like: print(account.BTC) -> {‘available’: 1, ‘hold’: 0} account.BTC = “cool” print(account.BTC) -> cool Basically you can get and set attributes with a dot instead of [] - like dict.available rather than
dict[‘available’]