Skip to content

instrument

instrument

Instrument Class

Instrument

Instrument Class

__init__(self, segment, exchange, tradingsymbol, broker_token, tick_size, lot_size, expiry=None, strike_price=None) special

Init method that is used while creating an object of this class

Parameters:

Name Type Description Default
segment

segment

required
exchange

exchange

required
tradingsymbol

trading symbol

required
broker_token

alphnumeric token

required
tick_size

tick size

required
lot_size

lot size

required
expiry

expiry date

None
strike_price

strike amount / value

None
Source code in pyalgotrading/instrument/instrument.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
def __init__(self, segment, exchange, tradingsymbol, broker_token, tick_size, lot_size, expiry=None, strike_price=None):
    """
    Init method that is used while creating an object of this class
    Args:
        segment: segment
        exchange: exchange
        tradingsymbol: trading symbol
        broker_token: alphnumeric token
        tick_size: tick size
        lot_size: lot size
        expiry: expiry date
        strike_price: strike amount / value
    """
    self.segment = segment
    self.exchange = exchange
    self.tradingsymbol = tradingsymbol
    self.broker_token = broker_token
    self.tick_size = tick_size
    self.lot_size = lot_size
    self.expiry = expiry
    self.strike_price = strike_price

is_expired(self)

Returns whether expired or not

Returns:

Type Description
bool

True or False

Source code in pyalgotrading/instrument/instrument.py
42
43
44
45
46
47
48
def is_expired(self) -> bool:
    """
    Returns whether expired or not
    Returns:
        True or False
    """
    return date.today() > self.expiry if self.will_expire() else False

will_expire(self)

Returns expiry details

Returns:

Type Description
bool

a value containing the expiry date

Source code in pyalgotrading/instrument/instrument.py
34
35
36
37
38
39
40
def will_expire(self) -> bool:
    """
    Returns expiry details
    Returns:
        a value containing the expiry date
    """
    return (self.expiry is not None) and (self.expiry != '')

Last update:

Comments