Code Monkey home page Code Monkey logo

markettechnicals.jl's People

Contributors

alexandrebrilhante avatar arkoniak avatar astadmistry avatar femtocleaner[bot] avatar github-actions[bot] avatar iblislin avatar milktrader avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

markettechnicals.jl's Issues

Error on install: Package incompatible with fixed requirements

With a recent julia, I'm getting the following error on install:

julia> Pkg2.add("MarketTechnicals")
ERROR: The following packages are incompatible with fixed requirements: MarketTechnicals
 in anonymous at no file:162
 in cd at file.jl:25
 in cd at pkg2/dir.jl:28
 in resolve at pkg2.jl:147
 in resolve at no file (repeats 3 times)
 in anonymous at no file:31
 in cd at file.jl:25
 in cd at pkg2/dir.jl:28
 in edit at pkg2.jl:21
 in add at pkg2.jl:18

Bollinger Bands broke

**   test/volatility.jl
ERROR: key not found: "std_2.0"
at /Users/Administrator/.julia/MarketTechnicals/test/volatility.jl:4
at /Users/Administrator/.julia/MarketTechnicals/run_tests.jl:18

rsi returns one extra value

Hi,

I noticed that the rsi function returns arrays with one extra value.

E.g., if I have N periods, I get N-1 period differences and if I use EMAs averaging over n periods of these arrays with N-1 entries, I should get in the end N-1 - n + 1 which is equal to N-n.

Nevertheless, using the functionrsi I get N-n+1 elements.

I looked into the code, and it seems that you add an extra zero at the beginning of the arrays ups and dns, why is that?

Cheers

[PackageEvaluator.jl] Your package MarketTechnicals may have a testing issue.

This issue is being filed by a script, but if you reply, I will see it.

PackageEvaluator.jl is a script that runs nightly. It attempts to load all Julia packages and run their test (if available) on both the stable version of Julia (0.2) and the nightly build of the unstable version (0.3).

The results of this script are used to generate a package listing enhanced with testing results.

The status of this package, MarketTechnicals, on...

  • Julia 0.2 is 'Package doesn't load.' PackageEvaluator.jl
  • Julia 0.3 is 'Tests fail, but package loads.' PackageEvaluator.jl

'No tests, but package loads.' can be due to their being no tests (you should write some if you can!) but can also be due to PackageEvaluator not being able to find your tests. Consider adding a test/runtests.jl file.

'Package doesn't load.' is the worst-case scenario. Sometimes this arises because your package doesn't have BinDeps support, or needs something that can't be installed with BinDeps. If this is the case for your package, please file an issue and an exception can be made so your package will not be tested.

This automatically filed issue is a one-off message. Starting soon, issues will only be filed when the testing status of your package changes in a negative direction (gets worse). If you'd like to opt-out of these status-change messages, reply to this message.

assumed ordering is wrong

The indexing order seems to assume that the oldest data is at index n and the newest at index 1. But that is not how typical data are arranged. Typically, the oldest data is at index 1 and the newest at index n

In the typical ordering of the data, should the for loop be as follows?

for i in n:length(ta)
vals[i] = mean(ta.values[i-(n-1):i])
end

Dispatch on now

Add a TimeType argument to all the indicators that produces a scalar (or boolean) result.

For example, the sma method would look like this:

function sma{T,N}(ta::TimeArray{T,N}, n::Int, now::TimeType)
    t = find(ta.timestamp .== now)[1]
    mean(ta.values[t-n:t])
end

And it would function like this:

julia> dt = Date(2001,12,31)
2001-12-31

julia> sma(cl, 10, dt)
21.323636363636368

Make the package depend only on DataSeries

This is a goal aimed at the entire JuliaQuant organization. More than a technical issue, this goes to the point of thinking of market conditions as features rather than columns in a DataFrame.

consider suing DataArray with most indicators

Benefits:

  1. compared with using TimeArray, DataArray can be one column only, which is mostly needed with indicators, so more efficient
  2. compared with using Array, DataArray allows empty entries
  3. consistent with StatBase

Algorithms only work with single-column TimeArrays

Apply the algorithm to all the columns, where it makes sense. This only applies to algorithms that only require one column of data (i.e., levels, candlesticks and others require more than one feature to compute a value and these don't apply).

  • sma
  • ema
  • rsi
  • cci

cci method has divergent results from TTR's CCI function

First, the current algorithm was implemented based on some of these references:

stock charts

brames

wiki

Though the wiki article doesn't specify that mean absolute deviation is a moving value based on the moving average parameter. (TODO: correct the wiki)

The cci method in this package takes a moving window to calculate the current day's cci value. The method that evaluates cci is in the non-exported mean_abs_dev method.

function mean_abs_dev{T}(a::Array{T,1}, scale::Bool=false)
    scale ? c = 1 / (-sqrt(2) * erfcinv(3 * 1 / 2)) : c =1

    res = ones(length(a))
    for i in 1:length(a)
        @inbounds res[i] = abs(a[i] - mean(a))
    end

    mean(res) * c
end

Not sure why either this implementation is wrong or TTR is wrong.

Write methods and tests for DataSeries

For some technical analysis, such as Bollinger Bands, there are more than one output. So in this case, return all the values and make the API friendly to reason about what order the return objects will come.

True Range function broken

Fails in the tests (has been commented out for now), and fails in repl. Related the calling max (which should now be maximum)

strange characters in volume.jl

Just discovered today. Don't know why this happened. I wonder if it is just my display issue.


function vwap{T,N}(ohlc::TimeArray{T,N}, n::Int; price="Close", v="Volume")

p   = ohlc[price]
q   = ohlc[v]
∑PQ = moving(p.*q, sum, n)
∑Q  = moving(q, sum, n)
val = ∑PQ ./ ∑Q

TimeArray(val.timestamp, val.values, ["vwap"])

end

BollingerBands not working

The function is not working on the latest release:

julia> bollingerbands(AAPL)

WARNING: moving(ta::TimeArray, f, window; padding=false) is deprecated, use moving(f, ta, window; padding=padding) instead.
Stacktrace:
 [1] depwarn(::String, ::Symbol) at ./deprecated.jl:70
 [2] #moving#43(::Bool, ::Function, ::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Function, ::Int64) at ./deprecated.jl:57
 [3] moving(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Function, ::Int64) at ./deprecated.jl:57
 [4] bollingerbands(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Int64, ::Float64) at /home/juliohm/.julia/v0.6/MarketTechnicals/src/volatility.jl:3
 [5] bollingerbands(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}) at /home/juliohm/.julia/v0.6/MarketTechnicals/src/volatility.jl:9
 [6] include_string(::String, ::String) at ./loading.jl:515
 [7] include_string(::Module, ::String, ::String) at /home/juliohm/.julia/v0.6/Compat/src/Compat.jl:174
 [8] execute_request(::ZMQ.Socket, ::IJulia.Msg) at /home/juliohm/.julia/v0.6/IJulia/src/execute_request.jl:154
 [9] eventloop(::ZMQ.Socket) at /home/juliohm/.julia/v0.6/IJulia/src/eventloop.jl:8
 [10] (::IJulia.##14#17)() at ./task.jl:335
while loading In[62], in expression starting on line 9
colnames supplied is not correct size

Stacktrace:
 [1] setcolnames!(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Array{String,1}) at /home/juliohm/.julia/v0.6/TimeSeries/src/utilities.jl:56
 [2] #merge#22(::Array{String,1}, ::Type{T} where T, ::Function, ::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Symbol) at /home/juliohm/.julia/v0.6/TimeSeries/src/combine.jl:48
 [3] (::Base.#kw##merge)(::Array{Any,1}, ::Base.#merge, ::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Symbol) at ./<missing>:0
 [4] bollingerbands(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Int64, ::Float64) at /home/juliohm/.julia/v0.6/MarketTechnicals/src/volatility.jl:6
 [5] bollingerbands(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}) at /home/juliohm/.julia/v0.6/MarketTechnicals/src/volatility.jl:9
 [6] include_string(::String, ::String) at ./loading.jl:515

length of output should stay the same as the input

I see that the current output from functions like sma is of length N-n+1, where N is the original length of the timeseries. While that is reasonable, it is practically inconvenient. For further calculation between the output timeseries and the original timeseries, the end user may have to spend extra effort dealing with syncing and the omitted values.

I suggest that these functions keep the original length. As to the values at those indexes whose function values are not specifically defined, we can adopt one of three ways: 1) set them to NaN, 2) set them to 0, or more preferably 3), set them to a more meaningful value. In the case of sma, the more meaningful value in method 3) can be the average of the available values up to the index under calculation. For instance, when calculating a 10-bar sma, at index 3, the sma can be (v[1] + v[2] + v[3])/3.

Differences between MarketTechnicals.jl, Indicators.jl and TALib.jl / Differences between Timeseries.jl and Temporal.jl

Hello,

I wrote some months ago a Julia wrapper for TA-Lib : TALib.jl

So it's financial market technical analysis & indicators in Julia using TA-Lib library.

I think it's better to have a pure Julia Technical analysis package

but I wonder what are differences between and MarketTechnicals.jl from @JuliaQuant (@iblislin @milktrader ...) and Indicators.jl from @dysonance

Isn't there a way to merge our efforts to make Julia stronger in finance field?

(for technical analysis but also to build a better Julia backtester, paper trade, live trade application for stocks but also for cfd (with bracket orders, with trailing stop, ...)

Kind regards

Bikeshed name for kwarg that preserves dates consumed by computation

A 10-period moving average cannot be computed on a distance less than 10, so when performing this computation on a data structure, the first 9 values don't have any reasonable value. This package consumes these dates, throwing them into the black hole of time-space where they belong. The resulting data structure has 9 less rows than the original data structure. This is what happens when you do these sorts of things on data.

Alas, many researchers don't like this behavior. Similar packages in R and pandas don't do this, for example. They populate the value slot consumed by computation with NA in the case of R, or the sentinel NaN in the case of pandas.

The most compelling reason to allow this behavior is that there are times when you'd like to merge or combine different data structures, and if you cut short a transformed column, you're going to face losing meaningful data in the other data structure.

For example, suppose you have a need for a TimeArray that includes closing prices and their 10-period moving average.

julia> using MarketData, MarketTechnicals

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      

julia> sma(cl, 10)
491x1 TimeSeries.TimeArray{Float64,1,DataType} 2000-01-14 to 2001-12-31

             sma10     
2000-01-14 | 98.782    
2000-01-18 | 97.982    
2000-01-19 | 98.388    
2000-01-20 | 99.338    

2001-12-26 | 21.065    
2001-12-27 | 21.123    
2001-12-28 | 21.266    
2001-12-31 | 21.417    

julia> merge(ans, cl)
491x2 TimeSeries.TimeArray{Float64,2,DataType} 2000-01-14 to 2001-12-31

             sma10     Close     
2000-01-14 | 98.782    100.44    
2000-01-18 | 97.982    103.94    
2000-01-19 | 98.388    106.56    
2000-01-20 | 99.338    113.5     

2001-12-26 | 21.065    21.49     
2001-12-27 | 21.123    22.07     
2001-12-28 | 21.266    22.43     
2001-12-31 | 21.417    21.9      

The argument that the sma10 column shouldn't represent values where none make sense is reasonable, but this has now consumed meaningful values found in the Close column.

Solution with Nullable{Float64}

Now that Nullable{Float64} is available, we can allow consumed timestamps to put the Julian sentinel in this slot. This package (or probably TimeSeries should do this) can define a show method to represent this as NA when displaying. This is preferred because it's terse and everyone knows what NA means (not really, but we all think we do).

Bike shed

What should the name be for a kwarg that allows consumed dates to be represented with Julian sentinels?

consume = true
preserve_dates = false
sentinalize = false (is that even a word?)
NA = false

referencing of column names needs to be standardized

In both cci and keltnerbands, columns are referenced by the names such as "High", "Close" etc. This is based on the assumption that the data come with these names. How do we ensure about this assumption? Somewhere this needs to be addressed.

UndefVarError

Hi there,

Have been testing MarketTechnicals today. Calling some functions such as "sma" or "ema" works fine. However for most others, such as "roc", I get the following error: "UndefVarError: roc not defined."

I am definitely using the package, and without using, I also get this error when calling sma or ema as expected.

I have Julia 0.6.2 installed and everything else is up to date with Pkg.update().

I am also using MarketData and TimeSeries and cannot carry out the examples when copied exactly. Have tried removing, re-adding, rebuilding MarketTechnicals etc. Seems it's somehow only half functional.

Any idea what could be going on?

MACD doesn't work with more than one column

I am using the macd functions but it crashes with an error in case of a time-series with two stocks.

ERROR: MethodError: no method matching macd(::TimeSeries.TimeArray{Float64,2,Date,Array{Float64,2}}, ::Int64, ::Int64, ::Int64)
Closest candidates are:
  macd(::TimeSeries.TimeArray{T,1,D,A} where A<:AbstractArray where D<:Base.Dates.TimeType, ::Int64, ::Int64, ::Int64) where T at /home/admin/.julia/v0.6/MarketTechnicals/src/momentum.jl:45
  macd(::TimeSeries.TimeArray{T,1,D,A} where A<:AbstractArray where D<:Base.Dates.TimeType, ::Int64, ::Int64) where T at /home/admin/.julia/v0.6/MarketTechnicals/src/momentum.jl:45
  macd(::TimeSeries.TimeArray{T,1,D,A} where A<:AbstractArray where D<:Base.Dates.TimeType, ::Int64) where T at /home/admin/.julia/v0.6/MarketTechnicals/src/momentum.jl:45

TALib wrapper

Hello,

it will be nice to have a Julia TALib wrapper like https://github.com/mrjbq7/ta-lib for Python
Pinging @mrjbq7

Here is function supported by TALib http://ta-lib.org/

AD                  Chaikin A/D Line
ADOSC               Chaikin A/D Oscillator
ADX                 Average Directional Movement Index
ADXR                Average Directional Movement Index Rating
APO                 Absolute Price Oscillator
AROON               Aroon
AROONOSC            Aroon Oscillator
ATR                 Average True Range
AVGPRICE            Average Price
BBANDS              Bollinger Bands
BETA                Beta
BOP                 Balance Of Power
CCI                 Commodity Channel Index
CDL2CROWS           Two Crows
CDL3BLACKCROWS      Three Black Crows
CDL3INSIDE          Three Inside Up/Down
CDL3LINESTRIKE      Three-Line Strike 
CDL3OUTSIDE         Three Outside Up/Down
CDL3STARSINSOUTH    Three Stars In The South
CDL3WHITESOLDIERS   Three Advancing White Soldiers
CDLABANDONEDBABY    Abandoned Baby
CDLADVANCEBLOCK     Advance Block
CDLBELTHOLD         Belt-hold
CDLBREAKAWAY        Breakaway
CDLCLOSINGMARUBOZU  Closing Marubozu
CDLCONCEALBABYSWALL Concealing Baby Swallow
CDLCOUNTERATTACK    Counterattack
CDLDARKCLOUDCOVER   Dark Cloud Cover
CDLDOJI             Doji
CDLDOJISTAR         Doji Star
CDLDRAGONFLYDOJI    Dragonfly Doji
CDLENGULFING        Engulfing Pattern
CDLEVENINGDOJISTAR  Evening Doji Star
CDLEVENINGSTAR      Evening Star
CDLGAPSIDESIDEWHITE Up/Down-gap side-by-side white lines
CDLGRAVESTONEDOJI   Gravestone Doji
CDLHAMMER           Hammer
CDLHANGINGMAN       Hanging Man
CDLHARAMI           Harami Pattern
CDLHARAMICROSS      Harami Cross Pattern
CDLHIGHWAVE         High-Wave Candle
CDLHIKKAKE          Hikkake Pattern
CDLHIKKAKEMOD       Modified Hikkake Pattern
CDLHOMINGPIGEON     Homing Pigeon
CDLIDENTICAL3CROWS  Identical Three Crows
CDLINNECK           In-Neck Pattern
CDLINVERTEDHAMMER   Inverted Hammer
CDLKICKING          Kicking
CDLKICKINGBYLENGTH  Kicking - bull/bear determined by the longer marubozu
CDLLADDERBOTTOM     Ladder Bottom
CDLLONGLEGGEDDOJI   Long Legged Doji
CDLLONGLINE         Long Line Candle
CDLMARUBOZU         Marubozu
CDLMATCHINGLOW      Matching Low
CDLMATHOLD          Mat Hold
CDLMORNINGDOJISTAR  Morning Doji Star
CDLMORNINGSTAR      Morning Star
CDLONNECK           On-Neck Pattern
CDLPIERCING         Piercing Pattern
CDLRICKSHAWMAN      Rickshaw Man
CDLRISEFALL3METHODS Rising/Falling Three Methods
CDLSEPARATINGLINES  Separating Lines
CDLSHOOTINGSTAR     Shooting Star
CDLSHORTLINE        Short Line Candle
CDLSPINNINGTOP      Spinning Top
CDLSTALLEDPATTERN   Stalled Pattern
CDLSTICKSANDWICH    Stick Sandwich
CDLTAKURI           Takuri (Dragonfly Doji with very long lower shadow)
CDLTASUKIGAP        Tasuki Gap
CDLTHRUSTING        Thrusting Pattern
CDLTRISTAR          Tristar Pattern
CDLUNIQUE3RIVER     Unique 3 River
CDLUPSIDEGAP2CROWS  Upside Gap Two Crows
CDLXSIDEGAP3METHODS Upside/Downside Gap Three Methods
CMO                 Chande Momentum Oscillator
CORREL              Pearson's Correlation Coefficient (r)
DEMA                Double Exponential Moving Average
DX                  Directional Movement Index
EMA                 Exponential Moving Average
HT_DCPERIOD         Hilbert Transform - Dominant Cycle Period
HT_DCPHASE          Hilbert Transform - Dominant Cycle Phase
HT_PHASOR           Hilbert Transform - Phasor Components
HT_SINE             Hilbert Transform - SineWave
HT_TRENDLINE        Hilbert Transform - Instantaneous Trendline
HT_TRENDMODE        Hilbert Transform - Trend vs Cycle Mode
KAMA                Kaufman Adaptive Moving Average
LINEARREG           Linear Regression
LINEARREG_ANGLE     Linear Regression Angle
LINEARREG_INTERCEPT Linear Regression Intercept
LINEARREG_SLOPE     Linear Regression Slope
MA                  All Moving Average
MACD                Moving Average Convergence/Divergence
MACDEXT             MACD with controllable MA type
MACDFIX             Moving Average Convergence/Divergence Fix 12/26
MAMA                MESA Adaptive Moving Average
MAX                 Highest value over a specified period
MAXINDEX            Index of highest value over a specified period
MEDPRICE            Median Price
MFI                 Money Flow Index
MIDPOINT            MidPoint over period
MIDPRICE            Midpoint Price over period
MIN                 Lowest value over a specified period
MININDEX            Index of lowest value over a specified period
MINMAX              Lowest and highest values over a specified period
MINMAXINDEX         Indexes of lowest and highest values over a specified period
MINUS_DI            Minus Directional Indicator
MINUS_DM            Minus Directional Movement
MOM                 Momentum
NATR                Normalized Average True Range
OBV                 On Balance Volume
PLUS_DI             Plus Directional Indicator
PLUS_DM             Plus Directional Movement
PPO                 Percentage Price Oscillator
ROC                 Rate of change : ((price/prevPrice)-1)*100
ROCP                Rate of change Percentage: (price-prevPrice)/prevPrice
ROCR                Rate of change ratio: (price/prevPrice)
ROCR100             Rate of change ratio 100 scale: (price/prevPrice)*100
RSI                 Relative Strength Index
SAR                 Parabolic SAR
SAREXT              Parabolic SAR - Extended
SMA                 Simple Moving Average
STDDEV              Standard Deviation
STOCH               Stochastic
STOCHF              Stochastic Fast
STOCHRSI            Stochastic Relative Strength Index
SUM                 Summation
T3                  Triple Exponential Moving Average (T3)
TEMA                Triple Exponential Moving Average
TRANGE              True Range
TRIMA               Triangular Moving Average
TRIX                1-day Rate-Of-Change (ROC) of a Triple Smooth EMA
TSF                 Time Series Forecast
TYPPRICE            Typical Price
ULTOSC              Ultimate Oscillator
VAR                 Variance
WCLPRICE            Weighted Close Price
WILLR               Williams' %R
WMA                 Weighted Moving Average

Kind regards

Provide an option to return transformed TimeArrays with NaN values

NaN value would be a placeholder for missing values in this case, which is what the Pandas package does. Many methods lose the first several rows of data to computation and currently the returned object simply omits them. By providing a option inside methods along the lines of includeNaN = false, users could opt to include the NaN values that convey that there was an original value inside the specified timestamp, but it was lost to computation.

Document methods and API

There are a few ways that packages are being documented. The quick and dirty method is to include it in the README, but long-term a more accessible format needs to be implemented.

Interested in better understanding and contributing.

Hello, I am a student of Mathematics and Computing from India and I am quite interested in Quant, recently I read "Introduction to time series and forecasting" by Brockwell and Davis. I wanted to know about more resources to increase my knowledge and if there was some way to contribute to this project. Any reply would be greatly appreciated. Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.