otp.corp_actions#

corp_actions(source, adjustment_date=None, adjustment_date_tz=default, fields=None, adjust_rule='PRICE', apply_split=True, apply_spinoff=False, apply_cash_dividend=False, apply_stock_dividend=False, apply_security_splice=False, apply_others='', apply_all=False)[source]#

Adjusts values using corporate actions information loaded into OneTick from the reference data file. To use it, location of reference database must be specified via OneTick configuration.

Parameters
  • source (onetick.py.Source) – Source object adjusted by corporate actions information.

  • adjustment_date (otp.date, int, str, None, optional) – The date as of which the values are adjusted. int format is YYYYMMDD. If it is not set, the values are adjusted as of the end date in the query. All corporate actions of the types specified in the parameters that lie between the tick timestamp and the adjustment date will be applied to each tick. Notice that the adjustment date is not affected neither by _SYMBOL_PARAM._PARAM_END_TIME nor by the apply_times_daily setting. By default None

  • adjustment_date_tz (str, optional) – Timezone for adjustment date, by default global otp.config.tz value used. Local timezone can’t be used so in this case parameter is set to ‘GMT’.

  • fields (str, optional) –

    A comma-separated list of fields to be adjusted. If this parameter is not set, some default adjustments will take place if appropriately named fields exist in the tick:

    • If the ADJUST_RULE parameter is set to PRICE, and the PRICE field is present, it will get adjusted. If the fields ASK_PRICE or BID_PRICE are present, they will get adjusted. If fields ASK_VALUE or BID_VALUE are present, they will get adjusted

    • If the ADJUST_RULE parameter is set to SIZE, and the SIZE field is present, it will get adjusted. If the fields ASK_SIZE or BID_SIZE are present, they will get adjusted. If fields ASK_VALUE or BID_VALUE are present, they will get adjusted.

    By default None

  • adjust_rule (str, optional) – When set to PRICE, adjustments are applied under the assumption that fields to be adjusted contain prices (adjustment direction is determined appropriately). When set to SIZE, adjustments are applied under the assumption that fields contain sizes (adjustment direction is opposite to that when the parameter’s value is PRICE). By default “PRICE”

  • apply_split (bool, optional) – If true, adjustments for splits are applied, by default True

  • apply_spinoff (bool, optional) – If true, adjustments for spin-offs are applied, by default False

  • apply_cash_dividend (bool, optional) – If true, adjustments for cash dividends are applied, by default False

  • apply_stock_dividend (bool, optional) – If true, adjustments for stock dividends are applied, by default False

  • apply_security_splice (bool, optional) – If true, adjustments for security splices are applied, by default False

  • apply_others (str, optional) – A comma-separated list of names of custom adjustment types to apply, by default “”

  • apply_all (bool, optional) – If true, applies all types of adjustments, both built-in and custom, by default False

Returns

A new source object with applied adjustments.

Return type

onetick.py.Source

Examples

>>> src = otp.DataSource('NYSE_TAQ',
...                      tick_type='TRD',
...                      start=otp.dt(2022, 5, 20, 9, 30),
...                      end=otp.dt(2022, 5, 26, 16))
>>> df = otp.run(src, symbols='MKD', symbol_date=otp.date(2022, 5, 22))
>>> df["PRICE"][0]
0.0911
>>> src = otp.functions.corp_actions(src,
...                                  adjustment_date=otp.date(2022, 5, 22),
...                                  fields="PRICE",)
>>> df = otp.run(src, symbols='MKD', symbol_date=otp.date(2022, 5, 22))
>>> df["PRICE"][0]
1.36649931675