StockFetcher Forums · Filter Exchange · No logical 'AND' plus trying to get sectors and watch lists to work with 'set' command<< >>Post Follow-up
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
Fetcher[
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
]



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
653 posts
msg #148295
Ignore snappyfrog
6/27/2019 11:05:06 PM

Fetcher[
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
]



StockFetcher Forums · Filter Exchange · No logical 'AND' plus trying to get sectors and watch lists to work with 'set' command<< >>Post Follow-up

*** Disclaimer *** StockFetcher.com does not endorse or suggest any of the securities which are returned in any of the searches or filters. They are provided purely for informational and research purposes. StockFetcher.com does not recommend particular securities. StockFetcher.com, Vestyl Software, L.L.C. and involved content providers shall not be liable for any errors or delays in the content, or for any actions taken based on the content.


Copyright 2022 - Vestyl Software L.L.C.Terms of Service | License | Questions or comments? Contact Us
EOD Data sources: DDFPlus & CSI Data Quotes delayed during active market hours. Delay times are at least 15 mins for NASDAQ, 20 mins for NYSE and Amex. Delayed intraday data provided by DDFPlus


This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.