Skip to content

Use Reactive to solve this problem #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
milktrader opened this issue Mar 21, 2015 · 5 comments
Open

Use Reactive to solve this problem #2

milktrader opened this issue Mar 21, 2015 · 5 comments

Comments

@milktrader
Copy link
Member

For convenience, the dev/tenblotters.jl file will be exported while this is being solved. It brings in the MarketData package and two variables, res and vals.

julia> res
10-element Array{Timestamps.Timestamp{T},1}:
 2000-01-03 |  100      Stock         111.94  $    AAPL
 2000-03-15 | -100      Stock         116.25  $    AAPL
 2000-05-25 |  100      Stock          87.27  $    AAPL
 2000-08-07 | -100      Stock          47.94  $    AAPL
 2000-10-17 |  100      Stock          20.12  $    AAPL
 2000-12-28 | -100      Stock          14.81  $    AAPL
 2001-03-13 |  100      Stock          19.56  $    AAPL
 2001-05-23 | -100      Stock          23.23  $    AAPL
 2001-08-03 |  100      Stock           19.5  $    AAPL
 2001-10-19 | -100      Stock           18.3  $    AAPL

julia> vals
10-element Array{Float64,1}:
  11194.0
 -11625.0
   8727.0
  -4794.0
   2012.0
  -1481.0
   1956.0
  -2323.0
   1950.0
  -1830.0

The problem to solve is to keep track of the account value everyday for two years, given these trades.

The daily closing prices can be found in the cl const provided by MarketData.

julia> using MarketData

julia> cl
500x1 TimeSeries.TimeArray{Float64,1,DataType} 2000-01-03 to 2001-12-31

             Close     
2000-01-03 | 111.94    
2000-01-04 | 102.5     
2000-01-05 | 104.0     
2000-01-06 | 95.0      

2001-12-26 | 21.49     
2001-12-27 | 22.07     
2001-12-28 | 22.43     
2001-12-31 | 21.9     
@multidis
Copy link

What is the context for keeping track of the account value? Could something like this be helpful?

@milktrader
Copy link
Member Author

From what I gather about the Reactive.jl package, it supports signals whose value changes over time.

I haven't grokked yet how to implement an account (type?) as a signal.

@multidis
Copy link

A signal can be of any custom type. The starting point is to map out the scheme of what signals are related and how they update. For example, even with a single signal, theme may be a need for another signal to e.g. keep a cumulative sum logic (PnL) etc.

@milktrader
Copy link
Member Author

Ok, good lead. I'll sketch this out and then implement from there.

@milktrader
Copy link
Member Author

I've got Cash Balance being updated in the dev/updates.jl file. Here is a dependency chart that I'm keying off of:

reactive_grist

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants