forked from jjttjj/trateg
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awb99
committed
Apr 24, 2024
1 parent
dda3a24
commit d97585d
Showing
8 changed files
with
70 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
(ns quanta.notebook.trade-entry-exit | ||
(:require | ||
[tick.core :as t] | ||
[tablecloth.api :as tc] | ||
[ta.trade.signal.core :refer [create-positions]] | ||
[ta.trade.metrics :refer [metrics]] | ||
[ta.viz.ds.metrics :refer [metrics-render-spec-impl]])) | ||
|
||
(def ds (tc/dataset {:date (repeatedly 6 #(t/instant)) | ||
:close [100.0 104.0 106.0 103.0 102.0 108.0] | ||
:high [100.0 104.0 106.0 103.0 102.0 108.0] | ||
:low [100.0 104.0 106.0 103.0 102.0 108.0] | ||
:entry [:long :nil nil :short :nil :nil]})) | ||
|
||
ds | ||
|
||
(def rts (-> (create-positions {:asset "QQQ" | ||
:entry [:fixed-qty 3.1] | ||
:exit [:time 2 | ||
:loss-percent 2.5 | ||
:profit-percent 5.0]} | ||
ds) | ||
:roundtrips)) | ||
|
||
rts | ||
|
||
(-> (metrics rts) | ||
(metrics-render-spec-impl) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(ns quanta.notebook.trade-position | ||
(:require | ||
[tick.core :as t] | ||
[tablecloth.api :as tc] | ||
[ta.trade.position :refer [signal->roundtrips]] | ||
[ta.trade.metrics :refer [metrics]] | ||
[ta.viz.ds.metrics :refer [metrics-render-spec-impl]])) | ||
|
||
(def signal-ds (tc/dataset {:date [(t/instant "2020-01-01T00:00:00Z") | ||
(t/instant "2020-01-02T00:00:00Z") | ||
(t/instant "2020-01-03T00:00:00Z") | ||
(t/instant "2020-02-04T00:00:00Z") | ||
(t/instant "2020-03-05T00:00:00Z") | ||
(t/instant "2020-04-06T00:00:00Z") | ||
(t/instant "2020-05-07T00:00:00Z")] | ||
:close [1.0 2.0 3.0 4.0 5.0 6.0 7.0] | ||
:signal [:long :hold :flat ;rt1 | ||
:short :hold :hold :flat ; rt2 | ||
]})) | ||
signal-ds | ||
|
||
(def rts (signal->roundtrips signal-ds)) | ||
|
||
(def r (metrics rts)) | ||
|
||
(:roundtrip-ds r) | ||
(:metrics r) | ||
(:nav-ds r) | ||
|
||
(metrics-render-spec-impl r) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters