API for MCX: profit/loss for every 1rs movement

charuvindatre
Does zerodha have any api which can return profit/loss for every 1rs movement for commodities?
Tagged:
  • charuvindatre
    @vivek Thanks! That would work.


    on a side note, I tried to comment with a python function of the same but for some reason my messages aren't getting posted. I'll try to post it again.
  • Vivek
    @charuvindatre Please use services like gist.github.com to post codes.
  • charuvindatre
    @vivek That looks great. Thanks! I was asking if kiteconnect has an api access for the same. Never mind though, I made the function myself.


    rpl = {
    'ALUMINI':1000,
    'ALUMINIUM':5000,
    'BRENTCRUDE':100,
    'COPPER':1000,
    'COPPERM':250,
    'CRUDEOIL':00,
    'CRUDEOILMINI':10,
    'GOLD':100,
    'GOLDGUINEA':1,
    'GOLDM':10,
    'GOLDGLOBAL':20,
    'GOLDPETAL':1,
    'GOLDPTLDEL':1,
    'LEAD':5000,
    'LEADMINI':1000,
    'NATURALGAS':1250,
    'NICKEL':250,
    'NICKELM':100,
    'SILVER':30,
    'SILVER1000':1,
    'SILVERM':5,
    'SILVERMIC':1,
    'ZINC':5000,
    'ZINCMINI':1000,
    'CARDAMOM':100,
    'COTTON':25,
    'CPO':1000,
    'KAPAS':200,
    'MENTHAOIL':360,
    }

    rpl_ = {
    'CPO':1000,
    'LEM':1000,
    'NTG':1250,
    'ALM':1000,
    'LED':5000,
    'ZIM':1000,
    'ZIN':5000,
    'COT':25,
    'NIC':250,
    'CPP':1000,
    'NIM':100
    }

    def rs_per_lot(script):
    global rpl
    global rpl_
    year = script[-8:-6]
    if year+year in script:
    #for scripts of pattern ALUJANFE1717JANFUT
    return rpl_[script[:3]]
    else:
    #for scripts of pattern GOLD17FEBFUT
    return rpl[script[:-8]]
  • charuvindatre
    @vivek
    thanks! I was hoping if kiteconnect had the some api for the same. Never mind though, I wrote a code for the same in python.


    rpl = {
    'ALUMINI':1000,
    'ALUMINIUM':5000,
    'BRENTCRUDE':100,
    'COPPER':1000,
    'COPPERM':250,
    'CRUDEOIL':00,
    'CRUDEOILMINI':10,
    'GOLD':100,
    'GOLDGUINEA':1,
    'GOLDM':10,
    'GOLDGLOBAL':20,
    'GOLDPETAL':1,
    'GOLDPTLDEL':1,
    'LEAD':5000,
    'LEADMINI':1000,
    'NATURALGAS':1250,
    'NICKEL':250,
    'NICKELM':100,
    'SILVER':30,
    'SILVER1000':1,
    'SILVERM':5,
    'SILVERMIC':1,
    'ZINC':5000,
    'ZINCMINI':1000,
    'CARDAMOM':100,
    'COTTON':25,
    'CPO':1000,
    'KAPAS':200,
    'MENTHAOIL':360,
    }

    rpl_ = {
    'CPO':1000,
    'LEM':1000,
    'NTG':1250,
    'ALM':1000,
    'LED':5000,
    'ZIM':1000,
    'ZIN':5000,
    'COT':25,
    'NIC':250,
    'CPP':1000,
    'NIM':100
    }

    def rs_per_lot(script):
    global rpl
    global rpl_
    year = script[-8:-6]
    if year+year in script:
    #for scripts of pattern ALUJANFE1717JANFUT
    return rpl_[script[:3]]
    else:
    #for scripts of pattern GOLD17FEBFUT
    return rpl[script[:-8]]
  • charuvindatre
    Here's the code in python for the link in case anyone is interested.

    rpl = {
    'ALUMINI':1000,
    'ALUMINIUM':5000,
    'BRENTCRUDE':100,
    'COPPER':1000,
    'COPPERM':250,
    'CRUDEOIL':00,
    'CRUDEOILMINI':10,
    'GOLD':100,
    'GOLDGUINEA':1,
    'GOLDM':10,
    'GOLDGLOBAL':20,
    'GOLDPETAL':1,
    'GOLDPTLDEL':1,
    'LEAD':5000,
    'LEADMINI':1000,
    'NATURALGAS':1250,
    'NICKEL':250,
    'NICKELM':100,
    'SILVER':30,
    'SILVER1000':1,
    'SILVERM':5,
    'SILVERMIC':1,
    'ZINC':5000,
    'ZINCMINI':1000,
    'CARDAMOM':100,
    'COTTON':25,
    'CPO':1000,
    'KAPAS':200,
    'MENTHAOIL':360,
    }

    rpl_ = {
    'CPO':1000,
    'LEM':1000,
    'NTG':1250,
    'ALM':1000,
    'LED':5000,
    'ZIM':1000,
    'ZIN':5000,
    'COT':25,
    'NIC':250,
    'CPP':1000,
    'NIM':100
    }

    def rs_per_lot(script):
    global rpl
    global rpl_
    year = script[-8:-6]
    if year+year in script:
    #for scripts of pattern ALUJANFE1717JANFUT
    return rpl_[script[:3]]
    else:
    #for scripts of pattern GOLD17FEBFUT
    return rpl[script[:-8]]
  • charuvindatre
    Here's a working function for getting profit/loss for every 1rs movement in case anyone is interested.

    rpl = {
    'ALUMINI':1000,
    'ALUMINIUM':5000,
    'BRENTCRUDE':100,
    'COPPER':1000,
    'COPPERM':250,
    'CRUDEOIL':00,
    'CRUDEOILMINI':10,
    'GOLD':100,
    'GOLDGUINEA':1,
    'GOLDM':10,
    'GOLDGLOBAL':20,
    'GOLDPETAL':1,
    'GOLDPTLDEL':1,
    'LEAD':5000,
    'LEADMINI':1000,
    'NATURALGAS':1250,
    'NICKEL':250,
    'NICKELM':100,
    'SILVER':30,
    'SILVER1000':1,
    'SILVERM':5,
    'SILVERMIC':1,
    'ZINC':5000,
    'ZINCMINI':1000,
    'CARDAMOM':100,
    'COTTON':25,
    'CPO':1000,
    'KAPAS':200,
    'MENTHAOIL':360,
    }

    rpl_ = {
    'CPO':1000,
    'LEM':1000,
    'NTG':1250,
    'ALM':1000,
    'LED':5000,
    'ZIM':1000,
    'ZIN':5000,
    'COT':25,
    'NIC':250,
    'CPP':1000,
    'NIM':100
    }

    def rs_per_lot(script):
    global rpl
    global rpl_
    year = script[-8:-6]
    if year+year in script:
    #for scripts of pattern ALUJANFE1717JANFUT
    return rpl_[script[:3]]
    else:
    #for scripts of pattern GOLD17FEBFUT
    return rpl[script[:-8]]
  • charuvindatre
    Here's a working function for getting profit/loss for every 1rs movement in case anyone is interested.

    rpl = {
    'ALUMINI':1000,
    'ALUMINIUM':5000,
    'BRENTCRUDE':100,
    'COPPER':1000,
    'COPPERM':250,
    'CRUDEOIL':00,
    'CRUDEOILMINI':10,
    'GOLD':100,
    'GOLDGUINEA':1,
    'GOLDM':10,
    'GOLDGLOBAL':20,
    'GOLDPETAL':1,
    'GOLDPTLDEL':1,
    'LEAD':5000,
    'LEADMINI':1000,
    'NATURALGAS':1250,
    'NICKEL':250,
    'NICKELM':100,
    'SILVER':30,
    'SILVER1000':1,
    'SILVERM':5,
    'SILVERMIC':1,
    'ZINC':5000,
    'ZINCMINI':1000,
    'CARDAMOM':100,
    'COTTON':25,
    'CPO':1000,
    'KAPAS':200,
    'MENTHAOIL':360,
    }

    rpl_ = {
    'CPO':1000,
    'LEM':1000,
    'NTG':1250,
    'ALM':1000,
    'LED':5000,
    'ZIM':1000,
    'ZIN':5000,
    'COT':25,
    'NIC':250,
    'CPP':1000,
    'NIM':100
    }

    def rs_per_lot(script):
    global rpl
    global rpl_
    year = script[-8:-6]
    if year+year in script:
    #for scripts of pattern ALUJANFE1717JANFUT
    return rpl_[script[:3]]
    else:
    #for scripts of pattern GOLD17FEBFUT
    return rpl[script[:-8]]
This discussion has been closed.