Parameter

This is the place for queries that don't fit in any of the other categories.

Parameter

Postby ChristopherL » Tue Sep 03, 2013 9:12 am

Hi there, I am having a parameter problem that I think I might have solved..
Since I don't have access to the data it's quite hard for me to test it.. (only my boss have the access to use the data)

But I was wonder if this looks like it could work? I don't know if you can mix or & and statements in the parameter..

Code: Select all
for row in dealList:
        marginInSEK = float(row['DEAL_MARGIN'])*float(fxRatesDict[row['COUNTER_CCY']])
        BPS = float(row['DEAL_MARGIN']) / float(row['COUNTER_AMT']) * 100
        if marginInSEK < float(NegativeMarginThreshold) or marginInSEK > float(ExcessiveMarginThreshold) and BPS > float(BPSThreshold):
            marginSEKDict[row['DEAL_NO']] = [row['MARGIN_BRANCH_ID'],
                                             float(row['DEAL_MARGIN'])*float(fxRatesDict[row['COUNTER_CCY']])]
            dealDict[row['DEAL_NO']] = row


I have setup these parameters:

Code: Select all
ExcessiveMarginThreshold = 50000 # is SEK
NegativeMarginThreshold  = -100 # is SEK
BPSThreshold = 30 # limit for BPS

row = dealDict[key]
ChristopherL
 
Posts: 13
Joined: Tue Jul 16, 2013 2:03 pm

Re: Parameter

Postby tnknepp » Tue Sep 03, 2013 3:36 pm

Writing code for data you can't see and you can't test? Does your boss hate you?

You can mix "and"/"or", but you must be careful in the order. By this I mean the two things being compared by "and" are always grouped, so they are compared, as a whole, to the following "or". e.g.

Code: Select all
a = 5
a < 10 and a == 5 or a == 10

# this is evaluated as
True or a == 10

# If you want <a> to be less than ten, and have a==5 OR a==10 you must write
a < 10 and (a==5 or a==10)


Make sense?
Python: 2.7 via Anaconda
Numpy: 1.7
Pandas: 0.11
OS: Windows 7
IDE: Spyder/IPython
User avatar
tnknepp
 
Posts: 133
Joined: Mon Mar 11, 2013 7:41 pm


Return to General Coding Help

Who is online

Users browsing this forum: stecarter93 and 4 guests