Skip to content

Commit

Permalink
ocassionally create a closed position
Browse files Browse the repository at this point in the history
  • Loading branch information
mpisanko committed Sep 18, 2024
1 parent 7770e99 commit 1063915
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions reference-service/src/reference_service/data/loader.clj
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@
(let [id (str (UUID/randomUUID))
buy-date (+ start (* offset day))
sell-date (+ buy-date week)
half-buy-quantity (int (/ (inc quantity) 2))]
half-buy-quantity (int (/ (inc quantity) 2))
sell-quantity (if (> (rand-int 10) 8)
quantity
(+ half-buy-quantity
(rand-int half-buy-quantity)))]
[{:created buy-date
:updated (+ buy-date hour hour)
:id id
Expand All @@ -171,7 +175,7 @@
:accountId account
:security stock
:unitPrice (stock-price-for-date jdbc-ds stock sell-date)
:quantity (+ half-buy-quantity (rand-int half-buy-quantity))
:quantity sell-quantity
:side "Sell"}]))
stock-quantities))
account-stocks))]
Expand Down

0 comments on commit 1063915

Please sign in to comment.