ClockDrift 3 posts msg #148220 - Ignore ClockDrift |
6/21/2019 1:52:20 PM
Hello, I am a brand new subscriber trying to get my first query running, the text is below. It results in a logical OR, not a logical AND. After reviewing docs I see that with stockfetcher I should use the set command. I re-wrote the script being careful to avoid reserved words in the set names. The script is below. It has several issues, using sectors and watchlists doesn't work, but even after commenting those out, the sort doesn't work either. Is it possible to get a logical AND (in the C#, Python, SQL, etc., meaning of the term) using sets? Getting a sort to work on an added column? My overall intent is to get a logical AND of a volume, beta, watchlist, and sector. Thanks in advance for any tips.
ORIGINAL
Average Volume(10) is above 500000
and Beta is above 1.2
and apply to sector(Medical, Consumer Discretionary, Consumer Staples)
and apply to watchlist(WeeklyOptions)
and add column separator
and Add column Beta
and Add column sector()
and add column industry
sort column 5 descending
REWRITE USING SETS (ALSO NOT WORKING)
set {vol1, Average Volume(10) is above 500000}
set (beta1, Beta is above 1.2}
set {sector1, sector(Medical, Consumer Staples)}
set {watch1, watchlist(WeeklyOptions)}
set {finalAND, vol1*beta1*sector1*watch1}
show stocks in finalAND
and add column separator
and add column beta
and Add column sector()
and add column industry
sort column 5 ascending
|
graftonian 1,089 posts msg #148221 - Ignore graftonian modified |
6/21/2019 4:02:38 PM
You do not need the "ands" & your column 5 is a separator (they ccount too)
Average Volume(10) is above 500000
Beta is above 1.2
apply to sector(Medical, Consumer Discretionary, Consumer Staples)
apply to watchlist(WeeklyOptions)
add column separator
Add column Beta
Add column sector()
add column industry
sort column 5 descending /*column 5 is a separator*/
will work on an examp;e of logical and
|
graftonian 1,089 posts msg #148222 - Ignore graftonian modified |
6/21/2019 4:16:53 PM
logical statements are really wordy in SF, good luck
also add fetcher-bracket and end bracket to make your script clickable
Graf
|
ClockDrift 3 posts msg #148292 - Ignore ClockDrift |
6/27/2019 5:39:17 PM
Hi Graf, thanks, much appreciated. My final version below.
set{vol1, count(Average Volume(10) is above 500000, 1)} /*will return a 1 or 0*/
set{beta1, count(Beta is above 1.2, 1)} /*will return a 1 or 0*/
set{x, vol1 * beta1} /* multiply for and; add for or */
x > 0
apply to sector(Healthcare, Consumer Discretionary, Consumer Staples)
apply to watchlist(WeeklyOptions)
add column separator /* separator counts as a column */
add column Beta
add column sector column sector()
add column industry
sort column 6 descending
|
snappyfrog 731 posts msg #148295 - Ignore snappyfrog |
6/27/2019 11:05:06 PM
|