certis.core module
- class certis.core.Account(margin: float, market_info: MarketInfo)[source]
Bases:
object
Certis Account Object
- property info: Dict[str, Any]
gives position info as dictionary
- Returns
position info as dictionary
- property margin: float
current margin left
- Returns
self._margin
- class certis.core.Broker(market_info: MarketInfo, initial_margin: float)[source]
Bases:
object
Virtual Broker object for Certis
- property account_info
account information
- Returns
self._account.info
- class certis.core.Engine(data: DataFrame, initial_margin: float, market_info: MarketInfo, strategy_cls: type, strategy_config: Dict[str, Any])[source]
Bases:
object
Engine Object
- property logger
- class certis.core.MarketInfo(maker_fee: float, taker_fee: float, slippage: float, tick_size: float, minimum_order_size: float, **kwargs)[source]
Bases:
object
takes & contains all these market information we need
- apply_slippage(price: float, side: int) float [source]
applies slippage for given price and side for side: long -> higher price for side: short -> lower price
- Parameters
price – order price
side – order side
- Returns
slippage-applied order price
- property maker_fee
- Returns
maker fee, fee for market orders. 1% = 0.01
- property minimum_order_size
minimum order size for this data.
- Returns
self._minimum_order_size
- property slippage
slippage for market orders. 1% = 0.01
- Returns
self._slippage
- property taker_fee
- Returns
taker fee, fee for limit orders. 1% = 0.01
- property tick_size
tick size for this data. in other words, minimum change unit. like (123.123, 12.124, 12.122 … ), tick size is 0.001
- Returns
self._tick_size
- class certis.core.Order(order_side=None, order_quantity=None, order_type: Optional[str] = None, order_price: Optional[float64] = None, reduce_only: bool = False)[source]
Bases:
Action
Order object in Certis
- check_order_price_validity(market_price: float) None [source]
checks order price’s validity for certain cases that could raise “Order Could Execute Immediately” Error in live trading.
- Parameters
market_price – market price (newest close price in this case)
- Returns
None
- property id: str
order’s id
- Returns
self._id
- is_fillable_at(account_info: Dict[str, Any], market_info: MarketInfo, open_price: float, high_price: float, low_price: float) bool [source]
- property price: float
order’s price required in LIMIT, STOP_MARKET (stop price) orders
- Returns
self._price
- property quantity: float
order’s quantity
- Returns
self._quantity
- property reduce_only: bool
if order is reduce-only order or not
- Returns
self._reduce_only
- property side: int
order side defined in certis.core.OrderSide required in every orders except for STOP_LOSS_MARKET & TAKE_PROFIT_MARKET orders
- Returns
self._side
- trim(market_info: MarketInfo) Action [source]
trims order itself
- Parameters
market_info – market info Object for this backtest
- Returns
self
- property type: str
order’s type defined in certis.constants.OrderType
- Returns
- class certis.core.OrderCancellation(id)[source]
Bases:
Action
order cancellation object
- property id: str
id for order to cancel if id == “all”: cancels all order
- Returns
- class certis.core.Position[source]
Bases:
object
- property avg_price: float
average entry price for this position
- Returns
self._avg_price
- property info: Dict[str, Any]
position as dict object
- Returns
- update(price: float, size: float, side: int, market_info: MarketInfo) float [source]
updates position with new transaction
- Parameters
price – price of transaction
size – quantity of transaction
side – side of transaction
market_info – MarketInfo object
- Returns
realized profit and loss (p&L)