certis.core module¶
-
class
certis.core.
Account
(margin: float, market_info: certis.core.MarketInfo)[source]¶ Bases:
object
Certis Account Object
-
property
info
¶ gives position info as dictionary
- Returns
position info as dictionary
-
property
margin
¶ current margin left
- Returns
self._margin
-
property
position
¶ current position object
- Returns
self._position
-
property
-
class
certis.core.
Broker
(market_info: certis.core.MarketInfo, initial_margin: float)[source]¶ Bases:
object
Virtual Broker object for Certis
-
property
account_info
¶ account information
- Returns
self._account.info
-
apply_actions
(actions: List[certis.base.Action], price: float) → None[source]¶ applies actions, which is List of Order / OrderCancellation Objects
- Parameters
actions – list of actions (Order / OrderCancellation Objects)
price – current price
- Returns
None
-
property
-
class
certis.core.
Engine
(data: pandas.core.frame.DataFrame, initial_margin: float, market_info: certis.core.MarketInfo, strategy_cls: type, strategy_config: Dict[str, Any])[source]¶ Bases:
object
Engine Object
-
property
logger
¶
-
property
-
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: str = None, order_price: Optional[numpy.float64] = None, reduce_only: bool = False)[source]¶ Bases:
certis.base.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
¶ order’s id
- Returns
self._id
-
is_fillable_at
(account_info: Dict[str, Any], market_info: certis.core.MarketInfo, open_price: float, high_price: float, low_price: float) → bool[source]¶
-
property
price
¶ order’s price required in LIMIT, STOP_MARKET (stop price) orders
- Returns
self._price
-
property
quantity
¶ order’s quantity
- Returns
self._quantity
-
property
reduce_only
¶ if order is reduce-only order or not
- Returns
self._reduce_only
-
property
side
¶ 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: certis.core.MarketInfo) → certis.base.Action[source]¶ trims order itself
- Parameters
market_info – market info Object for this backtest
- Returns
self
-
property
type
¶ order’s type defined in certis.constants.OrderType
- Returns
-
-
class
certis.core.
OrderCancellation
(id)[source]¶ Bases:
certis.base.Action
order cancellation object
-
property
id
¶ id for order to cancel if id == “all”: cancels all order
- Returns
-
property
-
class
certis.core.
Position
[source]¶ Bases:
object
-
property
avg_price
¶ average entry price for this position
- Returns
self._avg_price
-
property
info
¶ position as dict object
- Returns
-
update
(price: float, size: float, side: int, market_info: certis.core.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)
-
property