Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

an exp with many variables can be put in load script???? need help please???

Hi all,

Please can someone help me to solve the below issue?????????????please????

I have attached a file in which I have a table with the last column called as 'net',this expression consists of many variables in it.

I want to put this expression in the main script/load script and rename it as a field A''so that my future calculations involving this field A would be much easier.Can we do this???????

please can someone help??

the variables are updated in a macro .if you check in the edit module the function is 'Black 76'

I think we need to call macro and then put this exp below renaming it as required.Is this the process??else please guide me.

1 Solution

Accepted Solutions
tresesco
MVP
MVP

Hi

Your asoff_payoff field is not associated to any other tables. Rewrite the last part of your code as :

black_76:

load

     *,

     if(buy_sell='BUY',new_option_fuction-premium1,premium1-new_option_fuction) as asoff_payoff

;

load *,

[Trade ID] as trade,

Position_ID as pos,

strike_price as markt,

strike_price1 as strik,

Volatility_Amended as vol_amd,

xoptiontype_ as cp,

call_put as call_put1,

premium as premium1,

Expiry_ as exp,

time_to_expiry as time_to_expiry1,

Black76(call_put,strike_price1,strike_price,time_to_expiry,0.105,Volatility_Amended) as new_option_fuction

Resident data_;

// **********Following section should be commented out like

//as_off:

//load

//if(buy_sell='BUY',new_option_fuction-premium1,premium1-new_option_fuction) as asoff_payoff

//Resident black_76;

View solution in original post

19 Replies
Not applicable
Author

Hi all ,

after searching in the community,I got a solution of how we pass the macro function in load script ,I did the same in my script,the function has no error but the exp which I try to rename after that shows invalid expression message while running.

my function in macro that is used in script is Black 76:its  used in last tab,at the end in script.

Please can anyone help me out??

tresesco
MVP
MVP

It is expecting the parameters that have been declared in the function definition.

Not applicable
Author

hi tresesco

.. I have actually commented the msg box in edit module so that it doesnt ask for the parameters.but still I get below error as 'invalid expression.' for the exp that I have given below the macro function in script.

Don understand where its going wrong .What ever I am doing is it the right way ?? or another way is present???

Please can you guide me?

tresesco
MVP
MVP

See, when you write macro like:

function Black76(CallPutFlag,F,X,T,r,v)

.....

That means the function calculates on six input values(for CallPutFlag,F,X,T,r,v) and returns one. When you want to get some output from the function, it should actually been called in the script like:

LET Black76 = Black76(Value1, Value2,.....Value6);

You are missing those. Hope this helps.

Not applicable
Author

ok understood, thanks for the response,

but it should not just take 1 single line of value,there are several rows that will be have to taken and calculated .like the column called option_chk in my table is the same as this exp in script below the function.Here each row has its own values getting calculated.Hence in such a scenerio how can we do this??

tresesco
MVP
MVP

You can do that by using the function in the Load script like I have shown here :StrCmp Function

Not applicable
Author

Hi,

I couldn't end up with the result as I wanted ,but thanks a lot for your help and time.

Will see how it works out,will do some more trials  .

Not applicable
Author

Hi Tresesco,

I tried the strcmp() function you had attached but I am getting one error as shown in the file attached.

Can you please check my script ones if possible and let me know if I am following the correct steps ,please????

I have attached my qvw as well,and my function script is in the tab called funct

tresesco
MVP
MVP

You are passing a parameter called call_put which is not there the source.