{"action":"created","comment":{"url":"https://api.github.com/repos/ta4j/ta4j/pulls/comments/211067888","pull_request_review_id":147422638,"id":211067888,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxMTA2Nzg4OA==","diff_hunk":"@@ -0,0 +1,44 @@\n+package org.ta4j.core.analysis.criteria;\n+\n+import org.ta4j.core.PriceType;\n+import org.ta4j.core.TimeSeries;\n+import org.ta4j.core.Trade;\n+import org.ta4j.core.TradingRecord;\n+import org.ta4j.core.num.Num;\n+import org.ta4j.core.num.PrecisionNum;\n+\n+/**\n+ * Number of losing trades criterion.\n+ */\n+public class NumberOfLosingTradesCriterion extends AbstractBacktestingCriterion {\n+\n+    public NumberOfLosingTradesCriterion(PriceType priceType) {\n+        super(priceType);\n+    }\n+\n+    @Override\n+    public Num calculate(TimeSeries series, TradingRecord tradingRecord) {\n+         long numberOfLosingTrades = tradingRecord.getTrades().stream()\n+                .filter(trade -> trade.isClosed())\n+                .filter(trade -> isLosingTrade(series, trade)).count();\n+         return PrecisionNum.valueOf(numberOfLosingTrades);\n+    }\n+\n+    private boolean isLosingTrade(TimeSeries series, Trade trade) {\n+        Num exitPrice = getPrice(series, trade.getExit());\n+        Num entryPrice = getPrice(series, trade.getEntry());\n+\n+        Num profit = exitPrice.minus(entryPrice).multipliedBy(trade.getExit().getAmount());\n+        return profit.isLessThan(PrecisionNum.valueOf(0));\n+    }\n+\n+    @Override\n+    public Num calculate(TimeSeries series, Trade trade) {\n+        return series.numOf(1);","path":"ta4j-core/src/main/java/org/ta4j/core/analysis/criteria/NumberOfLosingTradesCriterion.java","position":37,"original_position":37,"commit_id":"86a7fddf751f2535b0601bf95500ceb7e0834cda","original_commit_id":"da27face77b337db9b18a6b399fd6859f55772be","user":{"login":"jansoren","id":1298854,"node_id":"MDQ6VXNlcjEyOTg4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1298854?v=4","gravatar_id":"","url":"https://api.github.com/users/jansoren","html_url":"https://github.com/jansoren","followers_url":"https://api.github.com/users/jansoren/followers","following_url":"https://api.github.com/users/jansoren/following{/other_user}","gists_url":"https://api.github.com/users/jansoren/gists{/gist_id}","starred_url":"https://api.github.com/users/jansoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansoren/subscriptions","organizations_url":"https://api.github.com/users/jansoren/orgs","repos_url":"https://api.github.com/users/jansoren/repos","events_url":"https://api.github.com/users/jansoren/events{/privacy}","received_events_url":"https://api.github.com/users/jansoren/received_events","type":"User","site_admin":false},"body":"I do not quite understand why it is better to cast an exception? The input parameter series and trade have value","created_at":"2018-08-18T07:25:16Z","updated_at":"2018-08-18T07:25:17Z","html_url":"https://github.com/ta4j/ta4j/pull/294#discussion_r211067888","pull_request_url":"https://api.github.com/repos/ta4j/ta4j/pulls/294","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/comments/211067888"},"html":{"href":"https://github.com/ta4j/ta4j/pull/294#discussion_r211067888"},"pull_request":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/294"}},"in_reply_to_id":210987435},"pull_request":{"url":"https://api.github.com/repos/ta4j/ta4j/pulls/294","id":200802375,"node_id":"MDExOlB1bGxSZXF1ZXN0MjAwODAyMzc1","html_url":"https://github.com/ta4j/ta4j/pull/294","diff_url":"https://github.com/ta4j/ta4j/pull/294.diff","patch_url":"https://github.com/ta4j/ta4j/pull/294.patch","issue_url":"https://api.github.com/repos/ta4j/ta4j/issues/294","number":294,"state":"open","locked":false,"title":"Fixes #287 Implemented a way to find the best result for multiple strategies by submitting a range of numbers while backtesting","user":{"login":"jansoren","id":1298854,"node_id":"MDQ6VXNlcjEyOTg4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1298854?v=4","gravatar_id":"","url":"https://api.github.com/users/jansoren","html_url":"https://github.com/jansoren","followers_url":"https://api.github.com/users/jansoren/followers","following_url":"https://api.github.com/users/jansoren/following{/other_user}","gists_url":"https://api.github.com/users/jansoren/gists{/gist_id}","starred_url":"https://api.github.com/users/jansoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansoren/subscriptions","organizations_url":"https://api.github.com/users/jansoren/orgs","repos_url":"https://api.github.com/users/jansoren/repos","events_url":"https://api.github.com/users/jansoren/events{/privacy}","received_events_url":"https://api.github.com/users/jansoren/received_events","type":"User","site_admin":false},"body":"Fixes #287 Implemented a way to find the best result for multiple strategies by submitting a range of numbers while backtesting\r\n\r\n- [x] added an entry to the unreleased section of `CHANGES.md` \r\n","created_at":"2018-07-11T19:27:49Z","updated_at":"2018-08-18T07:25:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cba3621ea55b4ab5548b37f0f7114b07b2edf5f6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/ta4j/ta4j/pulls/294/commits","review_comments_url":"https://api.github.com/repos/ta4j/ta4j/pulls/294/comments","review_comment_url":"https://api.github.com/repos/ta4j/ta4j/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ta4j/ta4j/issues/294/comments","statuses_url":"https://api.github.com/repos/ta4j/ta4j/statuses/86a7fddf751f2535b0601bf95500ceb7e0834cda","head":{"label":"jansoren:287-backtesting-parameter-range","ref":"287-backtesting-parameter-range","sha":"86a7fddf751f2535b0601bf95500ceb7e0834cda","user":{"login":"jansoren","id":1298854,"node_id":"MDQ6VXNlcjEyOTg4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1298854?v=4","gravatar_id":"","url":"https://api.github.com/users/jansoren","html_url":"https://github.com/jansoren","followers_url":"https://api.github.com/users/jansoren/followers","following_url":"https://api.github.com/users/jansoren/following{/other_user}","gists_url":"https://api.github.com/users/jansoren/gists{/gist_id}","starred_url":"https://api.github.com/users/jansoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansoren/subscriptions","organizations_url":"https://api.github.com/users/jansoren/orgs","repos_url":"https://api.github.com/users/jansoren/repos","events_url":"https://api.github.com/users/jansoren/events{/privacy}","received_events_url":"https://api.github.com/users/jansoren/received_events","type":"User","site_admin":false},"repo":{"id":140465828,"node_id":"MDEwOlJlcG9zaXRvcnkxNDA0NjU4Mjg=","name":"ta4j","full_name":"jansoren/ta4j","owner":{"login":"jansoren","id":1298854,"node_id":"MDQ6VXNlcjEyOTg4NTQ=","avatar_url":"https://avatars0.githubusercontent.com/u/1298854?v=4","gravatar_id":"","url":"https://api.github.com/users/jansoren","html_url":"https://github.com/jansoren","followers_url":"https://api.github.com/users/jansoren/followers","following_url":"https://api.github.com/users/jansoren/following{/other_user}","gists_url":"https://api.github.com/users/jansoren/gists{/gist_id}","starred_url":"https://api.github.com/users/jansoren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jansoren/subscriptions","organizations_url":"https://api.github.com/users/jansoren/orgs","repos_url":"https://api.github.com/users/jansoren/repos","events_url":"https://api.github.com/users/jansoren/events{/privacy}","received_events_url":"https://api.github.com/users/jansoren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jansoren/ta4j","description":"A Java library for technical analysis.","fork":true,"url":"https://api.github.com/repos/jansoren/ta4j","forks_url":"https://api.github.com/repos/jansoren/ta4j/forks","keys_url":"https://api.github.com/repos/jansoren/ta4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jansoren/ta4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jansoren/ta4j/teams","hooks_url":"https://api.github.com/repos/jansoren/ta4j/hooks","issue_events_url":"https://api.github.com/repos/jansoren/ta4j/issues/events{/number}","events_url":"https://api.github.com/repos/jansoren/ta4j/events","assignees_url":"https://api.github.com/repos/jansoren/ta4j/assignees{/user}","branches_url":"https://api.github.com/repos/jansoren/ta4j/branches{/branch}","tags_url":"https://api.github.com/repos/jansoren/ta4j/tags","blobs_url":"https://api.github.com/repos/jansoren/ta4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jansoren/ta4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jansoren/ta4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/jansoren/ta4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jansoren/ta4j/statuses/{sha}","languages_url":"https://api.github.com/repos/jansoren/ta4j/languages","stargazers_url":"https://api.github.com/repos/jansoren/ta4j/stargazers","contributors_url":"https://api.github.com/repos/jansoren/ta4j/contributors","subscribers_url":"https://api.github.com/repos/jansoren/ta4j/subscribers","subscription_url":"https://api.github.com/repos/jansoren/ta4j/subscription","commits_url":"https://api.github.com/repos/jansoren/ta4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/jansoren/ta4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/jansoren/ta4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/jansoren/ta4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/jansoren/ta4j/contents/{+path}","compare_url":"https://api.github.com/repos/jansoren/ta4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jansoren/ta4j/merges","archive_url":"https://api.github.com/repos/jansoren/ta4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jansoren/ta4j/downloads","issues_url":"https://api.github.com/repos/jansoren/ta4j/issues{/number}","pulls_url":"https://api.github.com/repos/jansoren/ta4j/pulls{/number}","milestones_url":"https://api.github.com/repos/jansoren/ta4j/milestones{/number}","notifications_url":"https://api.github.com/repos/jansoren/ta4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jansoren/ta4j/labels{/name}","releases_url":"https://api.github.com/repos/jansoren/ta4j/releases{/id}","deployments_url":"https://api.github.com/repos/jansoren/ta4j/deployments","created_at":"2018-07-10T17:22:45Z","updated_at":"2018-07-10T17:22:48Z","pushed_at":"2018-08-18T07:17:48Z","git_url":"git://github.com/jansoren/ta4j.git","ssh_url":"git@github.com:jansoren/ta4j.git","clone_url":"https://github.com/jansoren/ta4j.git","svn_url":"https://github.com/jansoren/ta4j","homepage":"http://www.ta4j.org","size":5352,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ta4j:develop","ref":"develop","sha":"60259195df160d664945d71d5676b68d4aa53d03","user":{"login":"ta4j","id":31952695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxOTUyNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/31952695?v=4","gravatar_id":"","url":"https://api.github.com/users/ta4j","html_url":"https://github.com/ta4j","followers_url":"https://api.github.com/users/ta4j/followers","following_url":"https://api.github.com/users/ta4j/following{/other_user}","gists_url":"https://api.github.com/users/ta4j/gists{/gist_id}","starred_url":"https://api.github.com/users/ta4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ta4j/subscriptions","organizations_url":"https://api.github.com/users/ta4j/orgs","repos_url":"https://api.github.com/users/ta4j/repos","events_url":"https://api.github.com/users/ta4j/events{/privacy}","received_events_url":"https://api.github.com/users/ta4j/received_events","type":"Organization","site_admin":false},"repo":{"id":103560333,"node_id":"MDEwOlJlcG9zaXRvcnkxMDM1NjAzMzM=","name":"ta4j","full_name":"ta4j/ta4j","owner":{"login":"ta4j","id":31952695,"node_id":"MDEyOk9yZ2FuaXphdGlvbjMxOTUyNjk1","avatar_url":"https://avatars2.githubusercontent.com/u/31952695?v=4","gravatar_id":"","url":"https://api.github.com/users/ta4j","html_url":"https://github.com/ta4j","followers_url":"https://api.github.com/users/ta4j/followers","following_url":"https://api.github.com/users/ta4j/following{/other_user}","gists_url":"https://api.github.com/users/ta4j/gists{/gist_id}","starred_url":"https://api.github.com/users/ta4j/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ta4j/subscriptions","organizations_url":"https://api.github.com/users/ta4j/orgs","repos_url":"https://api.github.com/users/ta4j/repos","events_url":"https://api.github.com/users/ta4j/events{/privacy}","received_events_url":"https://api.github.com/users/ta4j/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ta4j/ta4j","description":"A Java library for technical analysis.","fork":false,"url":"https://api.github.com/repos/ta4j/ta4j","forks_url":"https://api.github.com/repos/ta4j/ta4j/forks","keys_url":"https://api.github.com/repos/ta4j/ta4j/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ta4j/ta4j/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ta4j/ta4j/teams","hooks_url":"https://api.github.com/repos/ta4j/ta4j/hooks","issue_events_url":"https://api.github.com/repos/ta4j/ta4j/issues/events{/number}","events_url":"https://api.github.com/repos/ta4j/ta4j/events","assignees_url":"https://api.github.com/repos/ta4j/ta4j/assignees{/user}","branches_url":"https://api.github.com/repos/ta4j/ta4j/branches{/branch}","tags_url":"https://api.github.com/repos/ta4j/ta4j/tags","blobs_url":"https://api.github.com/repos/ta4j/ta4j/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ta4j/ta4j/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ta4j/ta4j/git/refs{/sha}","trees_url":"https://api.github.com/repos/ta4j/ta4j/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ta4j/ta4j/statuses/{sha}","languages_url":"https://api.github.com/repos/ta4j/ta4j/languages","stargazers_url":"https://api.github.com/repos/ta4j/ta4j/stargazers","contributors_url":"https://api.github.com/repos/ta4j/ta4j/contributors","subscribers_url":"https://api.github.com/repos/ta4j/ta4j/subscribers","subscription_url":"https://api.github.com/repos/ta4j/ta4j/subscription","commits_url":"https://api.github.com/repos/ta4j/ta4j/commits{/sha}","git_commits_url":"https://api.github.com/repos/ta4j/ta4j/git/commits{/sha}","comments_url":"https://api.github.com/repos/ta4j/ta4j/comments{/number}","issue_comment_url":"https://api.github.com/repos/ta4j/ta4j/issues/comments{/number}","contents_url":"https://api.github.com/repos/ta4j/ta4j/contents/{+path}","compare_url":"https://api.github.com/repos/ta4j/ta4j/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ta4j/ta4j/merges","archive_url":"https://api.github.com/repos/ta4j/ta4j/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ta4j/ta4j/downloads","issues_url":"https://api.github.com/repos/ta4j/ta4j/issues{/number}","pulls_url":"https://api.github.com/repos/ta4j/ta4j/pulls{/number}","milestones_url":"https://api.github.com/repos/ta4j/ta4j/milestones{/number}","notifications_url":"https://api.github.com/repos/ta4j/ta4j/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ta4j/ta4j/labels{/name}","releases_url":"https://api.github.com/repos/ta4j/ta4j/releases{/id}","deployments_url":"https://api.github.com/repos/ta4j/ta4j/deployments","created_at":"2017-09-14T17:14:32Z","updated_at":"2018-08-17T20:23:42Z","pushed_at":"2018-08-18T07:17:49Z","git_url":"git://github.com/ta4j/ta4j.git","ssh_url":"git@github.com:ta4j/ta4j.git","clone_url":"https://github.com/ta4j/ta4j.git","svn_url":"https://github.com/ta4j/ta4j","homepage":"http://www.ta4j.org","size":5303,"stargazers_count":299,"watchers_count":299,"language":"Java","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":121,"mirror_url":null,"archived":false,"open_issues_count":29,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":121,"open_issues":29,"watchers":299,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/294"},"html":{"href":"https://github.com/ta4j/ta4j/pull/294"},"issue":{"href":"https://api.github.com/repos/ta4j/ta4j/issues/294"},"comments":{"href":"https://api.github.com/repos/ta4j/ta4j/issues/294/comments"},"review_comments":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/294/comments"},"review_comment":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ta4j/ta4j/pulls/294/commits"},"statuses":{"href":"https://api.github.com/repos/ta4j/ta4j/statuses/86a7fddf751f2535b0601bf95500ceb7e0834cda"}},"author_association":"NONE"}}
{"actor":{"display_login":"jansoren"}}