Search in sources :

Example 1 with Watchlist

use of com.cassandrawebtrader.domain.Watchlist in project microservices by pwillhan.

the class YahooFeedJob method runYahooFeedService.

@Scheduled(fixedDelayString = "${com.cassandrawebtrader.fixedrate}")
public void runYahooFeedService() throws InterruptedException {
    Boolean isRun = Boolean.valueOf(env.getProperty("com.cassandrawebtrader.runYahooFeedService").toUpperCase());
    if (isRun) {
        Integer sometime = Integer.valueOf(env.getProperty("com.cassandrawebtrader.sleep"));
        String watchlistcode = env.getProperty("com.cassandrawebtrader.watchlistcode");
        List<Watchlist> watchlists = (List<Watchlist>) watchlistRepository.findByWatchlistCode(watchlistcode);
        for (Watchlist watchlist : watchlists) {
            logger.info("Start getting " + watchlist.getSymbol() + " data.");
            yahooFeedService.getData(watchlist.getSymbol());
            logger.info("Finish getting " + watchlist.getSymbol() + " data.");
            logger.info("Start scanning " + watchlist.getSymbol() + " data.");
            scannerService.scan(watchlist.getSymbol());
            logger.info("Finish scanning " + watchlist.getSymbol() + " data.");
            Thread.sleep(sometime);
        }
    }
}
Also used : List(java.util.List) Watchlist(com.cassandrawebtrader.domain.Watchlist) Scheduled(org.springframework.scheduling.annotation.Scheduled)

Example 2 with Watchlist

use of com.cassandrawebtrader.domain.Watchlist in project microservices by pwillhan.

the class WatchlistController method postWatchlistForm.

@RequestMapping(value = "/create", method = RequestMethod.POST)
public String postWatchlistForm(@ModelAttribute("watchlistForm") @Valid WatchlistForm watchlistForm, BindingResult result) {
    if (result.hasErrors())
        return "watchlist";
    Watchlist watchlist = mapper.map(watchlistForm);
    watchlistRepository.save(watchlist);
    return "redirect:/admin/watchlist";
}
Also used : Watchlist(com.cassandrawebtrader.domain.Watchlist) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Watchlist

use of com.cassandrawebtrader.domain.Watchlist in project microservices by pwillhan.

the class WatchlistMapper method map.

public Watchlist map(WatchlistForm model) {
    Watchlist domain = new Watchlist();
    domain.setWatchlistcode(model.getWatchlistcode());
    domain.setSymbol(model.getSymbol());
    domain.setActive(model.getActive());
    return domain;
}
Also used : Watchlist(com.cassandrawebtrader.domain.Watchlist)

Example 4 with Watchlist

use of com.cassandrawebtrader.domain.Watchlist in project microservices by pwillhan.

the class WatchlistController method showWatchlistPage.

@RequestMapping(method = RequestMethod.GET)
public String showWatchlistPage(Model model) {
    List<Watchlist> watchlists = (List<Watchlist>) watchlistRepository.findAll();
    model.addAttribute("watchlists", watchlists);
    WatchlistForm watchlistForm = new WatchlistForm();
    model.addAttribute("watchlistForm", watchlistForm);
    return "watchlist";
}
Also used : List(java.util.List) WatchlistForm(com.cassandrawebtrader.dto.WatchlistForm) Watchlist(com.cassandrawebtrader.domain.Watchlist) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with Watchlist

use of com.cassandrawebtrader.domain.Watchlist in project microservices by pwillhan.

the class WatchlistController method deleteWatchlistPage.

@RequestMapping(value = "/delete", method = RequestMethod.GET)
public String deleteWatchlistPage(@RequestParam(value = "symbol", required = true) String symbol) {
    Watchlist watchlist = new Watchlist();
    watchlist.setSymbol(symbol);
    watchlistRepository.delete(watchlist);
    return "redirect:/admin/watchlist";
}
Also used : Watchlist(com.cassandrawebtrader.domain.Watchlist) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

Watchlist (com.cassandrawebtrader.domain.Watchlist)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 WatchlistForm (com.cassandrawebtrader.dto.WatchlistForm)2 List (java.util.List)2 Scheduled (org.springframework.scheduling.annotation.Scheduled)1 ModelAndView (org.springframework.web.servlet.ModelAndView)1