Skip to content

Commit

Permalink
Add --ltb and --gts support to filter the stocks whose current pr…
Browse files Browse the repository at this point in the history
…ice is lower than buy price or greater than sell price.Resolve:#19
  • Loading branch information
topdna committed Jul 21, 2015
1 parent ad27d54 commit f4b2d4f
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions history.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Make `star -wo` or `star -w -o` to watch held stocks.
- Use moment 'zh-cn' locale instead of const days to format dayOfWeek output in finance cal.
- Update nodejs modules:async@~1.4.0,blessed@~0.1.14,blessed-contrib@~2.3.1.
- Add `--ltb` and `--gts` support to filter the stocks whose current price is lower than buy price or greater than sell price.

### v0.2.5

Expand Down
5 changes: 5 additions & 0 deletions lib/trace.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ let printResults = function(){
if(cmd.lte||cmd.lte === 0){ results = _.filter(results, s => s.pct <= cmd.lte); }
if(cmd.gte||cmd.gte === 0){ results = _.filter(results, s => s.pct >= cmd.gte); }

// 筛选当前价小于等于适合买入的便宜价格的股票
if(cmd.lteb){ results = _.filter(results, s => s.price <= s.cheap); }
// 筛选当前价大于等于适合卖出的昂贵价格的股票
if(cmd.gtes){ results = _.filter(results, s => s.price >= s.expensive); }

let ascending = cmd.reverse ? 1:-1;
// Default sort by percent
let sort = conf.sort[cmd.sort]|| conf.defaultSort;
Expand Down
2 changes: 2 additions & 0 deletions star.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ cmd
.option('-G, --gte <pct> ' , 'filter the symbols whose upside potential is greater than or equal to the specified percentage.', parseInt)
.option('-U, --under <star>' , 'filter the symbols whose star is under or equal to the specified star value.', parseInt)
.option('-A, --above <star>' , 'filter the symbols whose star is above or equal to the specified star value.', parseInt)
.option('--lteb' , "filter the symbols whose current price is lower than or equal to it's buy/cheap price")
.option('--gtes' , "filter the symbols whose current price is greater than or equal to it's sell/expensive price")
.option('-g, --grep <kw> ' , 'specify the keyword to grep in name or comment, multiple keywords should be separated by ",".')
.option('-e, --exclude <pre>', 'exclude stocks whose code number begin with: 300,600,002 or 000, etc. multiple prefixs can be\n' + ' '.repeat(20) +
' used and should be separated by "," or ",". ')
Expand Down

0 comments on commit f4b2d4f

Please sign in to comment.