sqa 0.0.24 → 0.0.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.goose/memory/development.txt +3 -0
- data/.semver +6 -0
- data/ARCHITECTURE.md +648 -0
- data/CHANGELOG.md +95 -0
- data/CLAUDE.md +674 -0
- data/COMMITS.md +196 -0
- data/DATAFRAME_ARCHITECTURE_REVIEW.md +421 -0
- data/NEXT-STEPS.md +154 -0
- data/README.md +839 -265
- data/TASKS.md +358 -0
- data/TEST_RESULTS.md +140 -0
- data/TODO.md +42 -0
- data/_notes.txt +25 -0
- data/bin/sqa-console +11 -0
- data/data/talk_talk.json +103284 -0
- data/develop_summary.md +313 -0
- data/docs/advanced/backtesting.md +206 -0
- data/docs/advanced/ensemble.md +68 -0
- data/docs/advanced/fpop.md +153 -0
- data/docs/advanced/index.md +112 -0
- data/docs/advanced/multi-timeframe.md +67 -0
- data/docs/advanced/pattern-matcher.md +75 -0
- data/docs/advanced/portfolio-optimizer.md +79 -0
- data/docs/advanced/portfolio.md +166 -0
- data/docs/advanced/risk-management.md +210 -0
- data/docs/advanced/strategy-generator.md +158 -0
- data/docs/advanced/streaming.md +209 -0
- data/docs/ai_and_ml.md +80 -0
- data/docs/api/dataframe.md +1114 -0
- data/docs/api/index.md +126 -0
- data/docs/assets/css/custom.css +88 -0
- data/docs/assets/images/sqa.jpg +0 -0
- data/docs/assets/js/mathjax.js +18 -0
- data/docs/concepts/index.md +60 -0
- data/docs/contributing/index.md +60 -0
- data/docs/data-sources/index.md +66 -0
- data/docs/data_frame.md +316 -97
- data/docs/factors_that_impact_price.md +26 -0
- data/docs/finviz.md +11 -0
- data/docs/fx_pro_bit.md +25 -0
- data/docs/genetic_programming.md +104 -0
- data/docs/getting-started/index.md +107 -0
- data/docs/getting-started/installation.md +229 -0
- data/docs/getting-started/quick-start.md +244 -0
- data/docs/i_gotta_an_idea.md +22 -0
- data/docs/index.md +161 -0
- data/docs/indicators/index.md +97 -0
- data/docs/indicators.md +110 -24
- data/docs/options.md +8 -0
- data/docs/strategies/bollinger-bands.md +146 -0
- data/docs/strategies/consensus.md +64 -0
- data/docs/strategies/custom.md +310 -0
- data/docs/strategies/ema.md +53 -0
- data/docs/strategies/index.md +92 -0
- data/docs/strategies/kbs.md +164 -0
- data/docs/strategies/macd.md +96 -0
- data/docs/strategies/market-profile.md +54 -0
- data/docs/strategies/mean-reversion.md +58 -0
- data/docs/strategies/rsi.md +95 -0
- data/docs/strategies/sma.md +55 -0
- data/docs/strategies/stochastic.md +63 -0
- data/docs/strategies/volume-breakout.md +54 -0
- data/docs/tags.md +7 -0
- data/examples/README.md +354 -0
- data/examples/advanced_features_example.rb +350 -0
- data/examples/fpop_analysis_example.rb +191 -0
- data/examples/genetic_programming_example.rb +148 -0
- data/examples/kbs_strategy_example.rb +208 -0
- data/examples/pattern_context_example.rb +300 -0
- data/examples/rails_app/Gemfile +34 -0
- data/examples/rails_app/README.md +416 -0
- data/examples/rails_app/app/assets/javascripts/application.js +107 -0
- data/examples/rails_app/app/assets/stylesheets/application.css +659 -0
- data/examples/rails_app/app/controllers/analysis_controller.rb +11 -0
- data/examples/rails_app/app/controllers/api/v1/stocks_controller.rb +227 -0
- data/examples/rails_app/app/controllers/application_controller.rb +22 -0
- data/examples/rails_app/app/controllers/backtest_controller.rb +11 -0
- data/examples/rails_app/app/controllers/dashboard_controller.rb +21 -0
- data/examples/rails_app/app/controllers/portfolio_controller.rb +7 -0
- data/examples/rails_app/app/views/analysis/show.html.erb +209 -0
- data/examples/rails_app/app/views/backtest/show.html.erb +171 -0
- data/examples/rails_app/app/views/dashboard/index.html.erb +118 -0
- data/examples/rails_app/app/views/dashboard/show.html.erb +408 -0
- data/examples/rails_app/app/views/errors/show.html.erb +17 -0
- data/examples/rails_app/app/views/layouts/application.html.erb +60 -0
- data/examples/rails_app/app/views/portfolio/index.html.erb +33 -0
- data/examples/rails_app/bin/rails +6 -0
- data/examples/rails_app/config/application.rb +45 -0
- data/examples/rails_app/config/boot.rb +5 -0
- data/examples/rails_app/config/database.yml +18 -0
- data/examples/rails_app/config/environment.rb +11 -0
- data/examples/rails_app/config/routes.rb +26 -0
- data/examples/rails_app/config.ru +8 -0
- data/examples/realtime_stream_example.rb +274 -0
- data/examples/sinatra_app/Gemfile +42 -0
- data/examples/sinatra_app/Gemfile.lock +268 -0
- data/examples/sinatra_app/QUICKSTART.md +169 -0
- data/examples/sinatra_app/README.md +471 -0
- data/examples/sinatra_app/RUNNING_WITHOUT_TALIB.md +90 -0
- data/examples/sinatra_app/TROUBLESHOOTING.md +95 -0
- data/examples/sinatra_app/app.rb +404 -0
- data/examples/sinatra_app/config.ru +5 -0
- data/examples/sinatra_app/public/css/style.css +723 -0
- data/examples/sinatra_app/public/debug_macd.html +82 -0
- data/examples/sinatra_app/public/js/app.js +107 -0
- data/examples/sinatra_app/start.sh +53 -0
- data/examples/sinatra_app/views/analyze.erb +306 -0
- data/examples/sinatra_app/views/backtest.erb +325 -0
- data/examples/sinatra_app/views/dashboard.erb +831 -0
- data/examples/sinatra_app/views/error.erb +58 -0
- data/examples/sinatra_app/views/index.erb +118 -0
- data/examples/sinatra_app/views/layout.erb +61 -0
- data/examples/sinatra_app/views/portfolio.erb +43 -0
- data/examples/strategy_generator_example.rb +346 -0
- data/hsa_portfolio.csv +11 -0
- data/justfile +0 -0
- data/lib/api/alpha_vantage_api.rb +462 -0
- data/lib/sqa/backtest.rb +329 -0
- data/lib/sqa/data_frame/alpha_vantage.rb +51 -63
- data/lib/sqa/data_frame/data.rb +92 -0
- data/lib/sqa/data_frame/yahoo_finance.rb +35 -43
- data/lib/sqa/data_frame.rb +154 -243
- data/lib/sqa/ensemble.rb +359 -0
- data/lib/sqa/fpop.rb +199 -0
- data/lib/sqa/gp.rb +259 -0
- data/lib/sqa/indicator.rb +16 -6
- data/lib/sqa/init.rb +15 -8
- data/lib/sqa/market_regime.rb +240 -0
- data/lib/sqa/multi_timeframe.rb +379 -0
- data/lib/sqa/pattern_matcher.rb +497 -0
- data/lib/sqa/portfolio.rb +260 -6
- data/lib/sqa/portfolio_optimizer.rb +377 -0
- data/lib/sqa/risk_manager.rb +442 -0
- data/lib/sqa/seasonal_analyzer.rb +209 -0
- data/lib/sqa/sector_analyzer.rb +300 -0
- data/lib/sqa/stock.rb +131 -127
- data/lib/sqa/strategy/bollinger_bands.rb +42 -0
- data/lib/sqa/strategy/consensus.rb +5 -2
- data/lib/sqa/strategy/kbs_strategy.rb +470 -0
- data/lib/sqa/strategy/macd.rb +46 -0
- data/lib/sqa/strategy/mp.rb +1 -1
- data/lib/sqa/strategy/stochastic.rb +60 -0
- data/lib/sqa/strategy/volume_breakout.rb +57 -0
- data/lib/sqa/strategy.rb +5 -0
- data/lib/sqa/strategy_generator.rb +947 -0
- data/lib/sqa/stream.rb +361 -0
- data/lib/sqa/ticker.rb +9 -2
- data/lib/sqa/version.rb +1 -7
- data/lib/sqa.rb +35 -20
- data/main.just +81 -0
- data/mkdocs.yml +252 -0
- data/trace.log +0 -0
- metadata +265 -69
- data/bin/sqa +0 -6
- data/docs/alpha_vantage_technical_indicators.md +0 -62
- data/docs/average_true_range.md +0 -9
- data/docs/bollinger_bands.md +0 -15
- data/docs/candlestick_pattern_recognizer.md +0 -4
- data/docs/donchian_channel.md +0 -5
- data/docs/double_top_bottom_pattern.md +0 -3
- data/docs/exponential_moving_average.md +0 -19
- data/docs/fibonacci_retracement.md +0 -30
- data/docs/head_and_shoulders_pattern.md +0 -3
- data/docs/market_profile.md +0 -4
- data/docs/momentum.md +0 -19
- data/docs/moving_average_convergence_divergence.md +0 -23
- data/docs/peaks_and_valleys.md +0 -11
- data/docs/relative_strength_index.md +0 -6
- data/docs/simple_moving_average.md +0 -8
- data/docs/stochastic_oscillator.md +0 -4
- data/docs/ta_lib.md +0 -160
- data/docs/true_range.md +0 -12
- data/lib/patches/dry-cli.rb +0 -228
- data/lib/sqa/activity.rb +0 -10
- data/lib/sqa/cli.rb +0 -62
- data/lib/sqa/commands/analysis.rb +0 -309
- data/lib/sqa/commands/base.rb +0 -139
- data/lib/sqa/commands/web.rb +0 -199
- data/lib/sqa/commands.rb +0 -22
- data/lib/sqa/constants.rb +0 -23
- data/lib/sqa/indicator/average_true_range.rb +0 -33
- data/lib/sqa/indicator/bollinger_bands.rb +0 -28
- data/lib/sqa/indicator/candlestick_pattern_recognizer.rb +0 -60
- data/lib/sqa/indicator/donchian_channel.rb +0 -29
- data/lib/sqa/indicator/double_top_bottom_pattern.rb +0 -34
- data/lib/sqa/indicator/elliott_wave_theory.rb +0 -57
- data/lib/sqa/indicator/exponential_moving_average.rb +0 -25
- data/lib/sqa/indicator/exponential_moving_average_trend.rb +0 -36
- data/lib/sqa/indicator/fibonacci_retracement.rb +0 -23
- data/lib/sqa/indicator/head_and_shoulders_pattern.rb +0 -26
- data/lib/sqa/indicator/market_profile.rb +0 -32
- data/lib/sqa/indicator/mean_reversion.rb +0 -37
- data/lib/sqa/indicator/momentum.rb +0 -28
- data/lib/sqa/indicator/moving_average_convergence_divergence.rb +0 -29
- data/lib/sqa/indicator/peaks_and_valleys.rb +0 -29
- data/lib/sqa/indicator/predict_next_value.rb +0 -202
- data/lib/sqa/indicator/relative_strength_index.rb +0 -47
- data/lib/sqa/indicator/simple_moving_average.rb +0 -24
- data/lib/sqa/indicator/simple_moving_average_trend.rb +0 -32
- data/lib/sqa/indicator/stochastic_oscillator.rb +0 -68
- data/lib/sqa/indicator/true_range.rb +0 -39
- data/lib/sqa/trade.rb +0 -26
data/docs/momentum.md
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# Momentum
|
|
2
|
-
|
|
3
|
-
Calculates the momentum of a stock based on the rate of change (ROC).
|
|
4
|
-
|
|
5
|
-
The interpretation of a stock's momentum value in terms of forecasting future price depends on the specific trading strategy or approach being used. However, in general, a positive momentum value indicates that the stock's price has been increasing over the specified period, while a negative momentum value indicates that the stock's price has been decreasing.
|
|
6
|
-
|
|
7
|
-
Here are some common interpretations of momentum values:
|
|
8
|
-
|
|
9
|
-
1. Positive Momentum: A positive momentum value suggests that the stock's price has been trending upwards. This could indicate that the stock is in an uptrend and may continue to rise in the near future. Traders and investors may interpret this as a bullish signal and consider buying or holding the stock.
|
|
10
|
-
|
|
11
|
-
2. Negative Momentum: A negative momentum value suggests that the stock's price has been trending downwards. This could indicate that the stock is in a downtrend and may continue to decline in the near future. Traders and investors may interpret this as a bearish signal and consider selling or avoiding the stock.
|
|
12
|
-
|
|
13
|
-
3. High Momentum: A high positive momentum value indicates a strong upward trend in the stock's price. This could suggest that the stock has significant buying pressure and may continue to rise. Traders and investors may interpret this as a strong bullish signal and consider entering or adding to their positions.
|
|
14
|
-
|
|
15
|
-
4. Low Momentum: A low positive momentum value suggests a weak upward trend or a sideways movement in the stock's price. This could indicate a lack of significant buying pressure. Traders and investors may interpret this as a neutral signal and may choose to wait for a stronger momentum signal or look for other indicators to make trading decisions.
|
|
16
|
-
|
|
17
|
-
It's important to note that momentum alone may not be sufficient for accurate price forecasting. It is often used in conjunction with other technical indicators, fundamental analysis, or market conditions to make more informed trading decisions.
|
|
18
|
-
|
|
19
|
-
Additionally, the interpretation of momentum values may vary depending on the time frame and the specific trading strategy being employed. Traders and investors should consider their own risk tolerance, investment goals, and trading approach when interpreting momentum values for forecasting future price movements.
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Moving Average Convergence Divergence (MACD)
|
|
2
|
-
|
|
3
|
-
The MACD is a trend-following momentum indicator that measures the relationship between two moving averages over a specified time period. The MACD is calculated by subtracting the long-term moving average from the short-term moving average.
|
|
4
|
-
|
|
5
|
-
The method takes in an array of historical prices for a stock, a short period (the number of days to calculate the short-term moving average over), a long period (the number of days to calculate the long-term moving average over), and a signal period (the number of days to calculate the signal line moving average over).
|
|
6
|
-
|
|
7
|
-
The method first calculates the short-term moving average by calling the `moving_averages` method with the `prices` array and the `short_period` parameter. It then calculates the long-term moving average by calling the `moving_averages` method with the `prices` array and the `long_period` parameter.
|
|
8
|
-
|
|
9
|
-
Next, the method calculates the MACD line by subtracting the long-term moving average from the short-term moving average. This is done by taking the last element of the `short_ma` array (which contains the short-term moving averages for each window) and subtracting the last element of the `long_ma` array (which contains the long-term moving averages for each window).
|
|
10
|
-
|
|
11
|
-
Finally, the method calculates the signal line by taking the moving average of the MACD line over the specified `signal_period`. This is done by calling the `moving_averages` method with the `short_ma` array and the `signal_period` parameter, and taking the last element of the resulting array.
|
|
12
|
-
|
|
13
|
-
The method returns an array containing the MACD line and the signal line.
|
|
14
|
-
|
|
15
|
-
Note that this is just a basic implementation of the MACD indicator, and there are many variations and refinements that can be made depending on the specific requirements of your program.
|
|
16
|
-
|
|
17
|
-
The Moving Average Convergence Divergence (MACD) is a technical analysis indicator that is used to identify changes in momentum, direction, and trend for a security. The MACD is calculated by subtracting the 26-period exponential moving average (EMA) from the 12-period EMA.
|
|
18
|
-
|
|
19
|
-
The values 1.8231937142857078 and 164.44427957142855 that you provided are likely the MACD line and the signal line, respectively. The MACD line is the difference between the 12-period EMA and the 26-period EMA, while the signal line is a 9-period EMA of the MACD line.
|
|
20
|
-
|
|
21
|
-
The MACD line crossing above the signal line is often considered a bullish signal, while the MACD line crossing below the signal line is often considered a bearish signal. The distance between the MACD line and the signal line can also provide insight into the strength of the trend.
|
|
22
|
-
|
|
23
|
-
Without additional context, it's difficult to interpret the specific values of 1.8231937142857078 and 164.44427957142855 for the MACD and signal lines of a stock. However, in general, the MACD can be used to identify potential buy and sell signals for a security, as well as to provide insight into the strength of the trend.
|
data/docs/peaks_and_valleys.md
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
# Peaks and Valleys
|
|
2
|
-
|
|
3
|
-
In financial technical analysis of stock prices, knowing the peak prices and low prices within a series of prices can provide valuable information. These peak and valley points are often used to identify support and resistance levels, which are important indicators for traders and investors.
|
|
4
|
-
|
|
5
|
-
- **Peak prices** represent the points at which the price of the stock reaches a high level before declining. This information can help identify potential trends and the maximum price levels that the stock has reached in the past. Traders may use peak prices to set profit targets or to determine when to sell a stock if it reaches a certain price level again.
|
|
6
|
-
|
|
7
|
-
- **Low prices in valleys** represent the points at which the price of the stock reaches a low level before increasing. These bottom points can help identify potential buying opportunities or areas of support. Traders may use valley prices to set stop-loss orders or to determine when the stock is oversold and potentially undervalued.
|
|
8
|
-
|
|
9
|
-
By analyzing the peak and valley prices within a series of prices, technical analysts can identify patterns such as trendlines, channels, or chart patterns like head and shoulders. These patterns can provide insights into the future direction of the stock price and help make informed trading decisions.
|
|
10
|
-
|
|
11
|
-
Overall, understanding the peak prices and low prices within a price array can provide valuable insights into the historical levels of support and resistance, allowing traders to make more informed decisions regarding their buying and selling strategies.
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
# Relative Strength Index (RSI)
|
|
2
|
-
|
|
3
|
-
This method takes in an array of historical prices for a stock and a period (the number of days to calculate the RSI over). It uses the `each_cons` method to iterate over a sliding window of closing prices and calculate the gains and losses for each window. Then, it calculates the average gain and average loss for the time period and uses these values to calculate the RSI. The method returns the RSI value for the given period.
|
|
4
|
-
|
|
5
|
-
* over_bought if rsi >= 70
|
|
6
|
-
* over_sold if rsi <= 30
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Simple Moving Average (SMA)
|
|
2
|
-
|
|
3
|
-
This method takes in an array of historical prices for a stock and a period (the number of days to calculate the moving average over). It uses the `each_cons` method to iterate over a sliding window of closing prices and calculate the moving average for each window. The method returns an array of the moving averages for each windo
|
|
4
|
-
|
|
5
|
-
# Simple Moving Average Trend
|
|
6
|
-
|
|
7
|
-
Up or down with angle to indicate how steep the movement is.
|
|
8
|
-
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
# Stochastic Oscillator
|
|
2
|
-
|
|
3
|
-
The Stochastic Oscillator is a popular technical indicator used in financial analysis to determine the current momentum and potential reversal points in a stock or market. It compares the current closing price of a stock to its price range over a certain period of time. The indicator consists of two lines: %K and %D.
|
|
4
|
-
|
data/docs/ta_lib.md
DELETED
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
# TA-Lib
|
|
2
|
-
|
|
3
|
-
`SQA` does not use the `ta-lib` but is considering it. Currently there are no ruby wrappers. There is a Java implementation and a Python wrapper.
|
|
4
|
-
|
|
5
|
-
The `ta-lib` library is a C/C++ implementation of about 200 technical analysis indicators which has been around since a little after the turn of the century. | It supports the follow indicators:
|
|
6
|
-
|
|
7
|
-
| TA Function | Name |
|
|
8
|
-
| ----------- | ---- |
|
|
9
|
-
| AD | Chaikin A/D Line |
|
|
10
|
-
| ADOSC | Chaikin A/D Oscillator |
|
|
11
|
-
| ADX | Average Directional Movement Index |
|
|
12
|
-
| ADXR | Average Directional Movement Index Rating |
|
|
13
|
-
| APO | Absolute Price Oscillator |
|
|
14
|
-
| AROON | Aroon |
|
|
15
|
-
| AROONOSC | Aroon Oscillator |
|
|
16
|
-
| ATR | Average True Range |
|
|
17
|
-
| AVGPRICE | Average Price |
|
|
18
|
-
| BBANDS | Bollinger Bands |
|
|
19
|
-
| BETA | Beta |
|
|
20
|
-
| BOP | Balance Of Power |
|
|
21
|
-
| CCI | Commodity Channel Index |
|
|
22
|
-
| CDL2CROWS | Two Crows |
|
|
23
|
-
| CDL3BLACKCROWS | Three Black Crows |
|
|
24
|
-
| CDL3INSIDE | Three Inside Up/Down |
|
|
25
|
-
| CDL3LINESTRIKE | Three Outside Up/Down |
|
|
26
|
-
| CDL3STARSINSOUTH | Three Stars In The South |
|
|
27
|
-
| CDL3WHITESOLDIERS | Three Advancing White Soldiers |
|
|
28
|
-
| CDLABANDONEDBABY | Abandoned Baby |
|
|
29
|
-
| CDLADVANCEBLOCK | Advance Block |
|
|
30
|
-
| CDLBELTHOLD | Belt-hold |
|
|
31
|
-
| CDLBREAKAWAY | Breakaway |
|
|
32
|
-
| CDLCLOSINGMARUBOZU | Closing Marubozu |
|
|
33
|
-
| CDLCONCEALBABYSWALL | Concealing Baby Swallow |
|
|
34
|
-
| CDLCOUNTERATTACK | Counterattack |
|
|
35
|
-
| CDLDARKCLOUDCOVER | Dark Cloud Cover |
|
|
36
|
-
| CDLDOJI | Doji |
|
|
37
|
-
| CDLDOJISTAR | Doji Star |
|
|
38
|
-
| CDLDRAGONFLYDOJI | Dragonfly Doji |
|
|
39
|
-
| CDLENGULFING | Engulfing Pattern |
|
|
40
|
-
| CDLEVENINGDOJISTAR | Evening Doji Star |
|
|
41
|
-
| CDLEVENINGSTAR | Evening Star |
|
|
42
|
-
| CDLGAPSIDESIDEWHITE | Up/Down-gap side-by-side white lines |
|
|
43
|
-
| CDLGRAVESTONEDOJI | Gravestone Doji |
|
|
44
|
-
| CDLHAMMER | Hammer |
|
|
45
|
-
| CDLHANGINGMAN | Hanging Man |
|
|
46
|
-
| CDLHARAMI | Harami Pattern |
|
|
47
|
-
| CDLHARAMICROSS | Harami Cross Pattern |
|
|
48
|
-
| CDLHIGHWAVE | High-Wave Candle |
|
|
49
|
-
| CDLHIKKAKE | Hikkake Pattern |
|
|
50
|
-
| CDLHIKKAKEMOD | Modified Hikkake Pattern |
|
|
51
|
-
| CDLHOMINGPIGEON | Homing Pigeon |
|
|
52
|
-
| CDLIDENTICAL3CROWS | Identical Three Crows |
|
|
53
|
-
| CDLINNECK | In-Neck Pattern |
|
|
54
|
-
| CDLINVERTEDHAMMER | Inverted Hammer |
|
|
55
|
-
| CDLKICKING | Kicking |
|
|
56
|
-
| CDLKICKINGBYLENGTH | Kicking - bull/bear determined by the longer marubozu |
|
|
57
|
-
| CDLLADDERBOTTOM | Ladder Bottom |
|
|
58
|
-
| CDLLONGLEGGEDDOJI | Long Legged Doji |
|
|
59
|
-
| CDLLONGLINE | Long Line Candle |
|
|
60
|
-
| CDLMARUBOZU | Marubozu |
|
|
61
|
-
| CDLMATCHINGLOW | Matching Low |
|
|
62
|
-
| CDLMATHOLD | Mat Hold |
|
|
63
|
-
| CDLMORNINGDOJISTAR | Morning Doji Star |
|
|
64
|
-
| CDLMORNINGSTAR | Morning Star |
|
|
65
|
-
| CDLONNECK | On-Neck Pattern |
|
|
66
|
-
| CDLPIERCING | Piercing Pattern |
|
|
67
|
-
| CDLRICKSHAWMAN | Rickshaw Man |
|
|
68
|
-
| CDLRISEFALL3METHODS | Rising/Falling Three Methods |
|
|
69
|
-
| CDLSEPARATINGLINES | Separating Lines |
|
|
70
|
-
| CDLSHOOTINGSTAR | Shooting Star |
|
|
71
|
-
| CDLSHORTLINE | Short Line Candle |
|
|
72
|
-
| CDLSPINNINGTOP | Spinning Top |
|
|
73
|
-
| CDLSTALLEDPATTERN | Stalled Pattern |
|
|
74
|
-
| CDLSTICKSANDWICH | Stick Sandwich |
|
|
75
|
-
| CDLTAKURI | Takuri (Dragonfly Doji with very long lower shadow) |
|
|
76
|
-
| CDLTASUKIGAP | Tasuki Gap |
|
|
77
|
-
| CDLTHRUSTING | Thrusting Pattern |
|
|
78
|
-
| CDLTRISTAR | Tristar Pattern |
|
|
79
|
-
| CDLUNIQUE3RIVER | Unique 3 River |
|
|
80
|
-
| CDLUPSIDEGAP2CROWS | Upside Gap Two Crows |
|
|
81
|
-
| CDLXSIDEGAP3METHODS | Upside/Downside Gap Three Methods |
|
|
82
|
-
| CMO | Chande Momentum Oscillator |
|
|
83
|
-
| CORREL | Pearson's Correlation Coefficient ® |
|
|
84
|
-
| DEMA | Double Exponential Moving Average |
|
|
85
|
-
| DX | Directional Movement Index |
|
|
86
|
-
| EMA | Exponential Moving Average |
|
|
87
|
-
| HT_DCPERIOD | Hilbert Transform - Dominant Cycle Period |
|
|
88
|
-
| HT_DCPHASE | Hilbert Transform - Dominant Cycle Phase |
|
|
89
|
-
| HT_PHASOR | Hilbert Transform - Phasor Components |
|
|
90
|
-
| HT_SINE | Hilbert Transform - SineWave |
|
|
91
|
-
| HT_TRENDLINE | Hilbert Transform - Instantaneous Trendline |
|
|
92
|
-
| HT_TRENDMODE | Hilbert Transform - Trend vs Cycle Mode |
|
|
93
|
-
| KAMA | Kaufman Adaptive Moving Average |
|
|
94
|
-
| LINEARREG | Linear Regression |
|
|
95
|
-
| LINEARREG_ANGLE | Linear Regression Angle |
|
|
96
|
-
| LINEARREG_INTERCEPT | Linear Regression Intercept |
|
|
97
|
-
| LINEARREG_SLOPE | Linear Regression Slope |
|
|
98
|
-
| MA | All Moving Average |
|
|
99
|
-
| MACD | Moving Average Convergence/Divergence |
|
|
100
|
-
| MACDEXT | MACD with controllable MA type |
|
|
101
|
-
| MACDFIX | Moving Average Convergence/Divergence Fix 12/26 |
|
|
102
|
-
| MAMA | MESA Adaptive Moving Average |
|
|
103
|
-
| MAX | Highest value over a specified period |
|
|
104
|
-
| MAXINDEX | Index of highest value over a specified period |
|
|
105
|
-
| MEDPRICE | Median Price |
|
|
106
|
-
| MFI | Money Flow Index |
|
|
107
|
-
| MIDPOINT | MidPoint over period |
|
|
108
|
-
| MIDPRICE | Midpoint Price over period |
|
|
109
|
-
| MIN | Lowest value over a specified period |
|
|
110
|
-
| MININDEX | Index of lowest value over a specified period |
|
|
111
|
-
| MINMAX | Lowest and highest values over a specified period |
|
|
112
|
-
| MINMAXINDEX | Indexes of lowest and highest values over a specified period |
|
|
113
|
-
| MINUS_DI | Minus Directional Indicator |
|
|
114
|
-
| MINUS_DM | Minus Directional Movement |
|
|
115
|
-
| MOM | Momentum |
|
|
116
|
-
| NATR | Normalized Average True Range |
|
|
117
|
-
| OBV | On Balance Volume |
|
|
118
|
-
| PLUS_DI | Plus Directional Indicator |
|
|
119
|
-
| PLUS_DM | Plus Directional Movement |
|
|
120
|
-
| PPO | Percentage Price Oscillator |
|
|
121
|
-
| ROC | Rate of change |
|
|
122
|
-
| ROCP | Rate of change Percentage |
|
|
123
|
-
| ROCR | Rate of change ratio |
|
|
124
|
-
| ROCR100 | Rate of change ratio 100 scale |
|
|
125
|
-
| RSI | Relative Strength Index |
|
|
126
|
-
| SAR | Parabolic SAR |
|
|
127
|
-
| SAREXT | Parabolic SAR - Extended |
|
|
128
|
-
| SMA | Simple Moving Average |
|
|
129
|
-
| STDDEV | Standard Deviation |
|
|
130
|
-
| STOCH | Stochastic |
|
|
131
|
-
| STOCHF | Stochastic Fast |
|
|
132
|
-
| STOCHRSI | Stochastic Relative Strength Index |
|
|
133
|
-
| SUM | Summation |
|
|
134
|
-
| T3 | Triple Exponential Moving Average (T3) |
|
|
135
|
-
| TEMA | Triple Exponential Moving Average |
|
|
136
|
-
| TRANGE | True Range |
|
|
137
|
-
| TRIMA | Triangular Moving Average |
|
|
138
|
-
| TRIX | 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA |
|
|
139
|
-
| TSF | Time Series Forecast |
|
|
140
|
-
| TYPPRICE | Typical Price |
|
|
141
|
-
| ULTOSC | Ultimate Oscillator |
|
|
142
|
-
| VAR | Variance |
|
|
143
|
-
| WCLPRICE | Weighted Close Price |
|
|
144
|
-
| WILLR | Williams' %R |
|
|
145
|
-
| WMA | Weighted Moving Average |
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
Rate of Change Implementation Definitions:
|
|
149
|
-
|
|
150
|
-
ROC - Rate of Change
|
|
151
|
-
> `((price/prevPrice)-1)*100`
|
|
152
|
-
|
|
153
|
-
ROCP - Rate of Change Precentage
|
|
154
|
-
> `(price-prevPrice)/prevPrice`
|
|
155
|
-
|
|
156
|
-
ROCR - Rate of Change Ratio
|
|
157
|
-
> `(price/prevPrice)`
|
|
158
|
-
|
|
159
|
-
ROCR100 - Rate of Change Ration on 100 Scale
|
|
160
|
-
> `(price/prevPrice)*100`
|
data/docs/true_range.md
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
# True Range
|
|
2
|
-
|
|
3
|
-
Calculates the True Range (TR) for a given set of price data.
|
|
4
|
-
|
|
5
|
-
The True Range is a measure of the price volatility of a security over a given period. It is calculated as the greatest of the following three values:
|
|
6
|
-
|
|
7
|
-
* The difference between the current high and the current low.
|
|
8
|
-
* The absolute value of the difference between the current high and the previous close.
|
|
9
|
-
* The absolute value of the difference between the current low and the previous close.
|
|
10
|
-
|
|
11
|
-
The True Range helps to capture the true extent of price movement, taking into account potential gaps or price jumps between periods. It is often used as a component in calculating other indicators, such as the Average True Range.
|
|
12
|
-
|
data/lib/patches/dry-cli.rb
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
# sqa/lib/patches/dry-cli.rb
|
|
2
|
-
|
|
3
|
-
#####################################################################
|
|
4
|
-
###
|
|
5
|
-
## File: dry-cli.rb
|
|
6
|
-
## Desc: Monkey around with the Dry::CLI class.
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
=begin
|
|
11
|
-
This monkey patch adds four new class methods to the Command class:
|
|
12
|
-
|
|
13
|
-
global_header .. Program/Glocal context custom header/footer
|
|
14
|
-
global_footer ..
|
|
15
|
-
header ......... Command context custom header / footer
|
|
16
|
-
footer .........
|
|
17
|
-
|
|
18
|
-
In addition to the new commands, tail-patched call methods in the
|
|
19
|
-
Banner and Usage modules wrap the existing help text formatting
|
|
20
|
-
with the appropriate global and command level header and footer
|
|
21
|
-
text.
|
|
22
|
-
|
|
23
|
-
The expected usage pattern is to have the global customerized
|
|
24
|
-
header / footer help text defined in the Base command class
|
|
25
|
-
for an application. All other commands inherent from this
|
|
26
|
-
Base class.
|
|
27
|
-
|
|
28
|
-
The header / footer class methods are used to wrap the command
|
|
29
|
-
help text. When "--help" is used on a command, the customerized
|
|
30
|
-
global header and footer text are on the outside of the help text.
|
|
31
|
-
The customized command header / footer are inside of the
|
|
32
|
-
global context but still wrap the original help text
|
|
33
|
-
|
|
34
|
-
Here is an example help output:
|
|
35
|
-
|
|
36
|
-
$ ./bin_cli.rb start --help
|
|
37
|
-
== Base Global Header ==
|
|
38
|
-
== Start Header ==
|
|
39
|
-
Command:
|
|
40
|
-
bin_cli.rb start
|
|
41
|
-
|
|
42
|
-
Usage:
|
|
43
|
-
bin_cli.rb start ROOT | bin_cli.rb start SUBCOMMAND
|
|
44
|
-
|
|
45
|
-
Description:
|
|
46
|
-
Start Foo machinery
|
|
47
|
-
|
|
48
|
-
Subcommands:
|
|
49
|
-
version # Print version
|
|
50
|
-
|
|
51
|
-
Arguments:
|
|
52
|
-
ROOT # REQUIRED Root directory
|
|
53
|
-
|
|
54
|
-
Options:
|
|
55
|
-
--[no-]debug, -d, --debug # Print debug information, default: false
|
|
56
|
-
--[no-]verbose, -v, --verbose # Print verbose information, default: false
|
|
57
|
-
--[no-]xyzzy, -x, --xyzzy # Magic, default: false
|
|
58
|
-
--help, -h # Print this help
|
|
59
|
-
|
|
60
|
-
Examples:
|
|
61
|
-
bin_cli.rb start path/to/root # Start Foo at root directory
|
|
62
|
-
== Start Footer ==
|
|
63
|
-
== Base Global Footer ==
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
=end
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
module Dry::CLI::Banner
|
|
70
|
-
class << self
|
|
71
|
-
alias_method :original_call, :call
|
|
72
|
-
|
|
73
|
-
# Overwrites the original 'call' method to accommodate a custom header and footer
|
|
74
|
-
# for the help text.
|
|
75
|
-
# @param command [Class] the the command class
|
|
76
|
-
# @param name [String] command line without help option
|
|
77
|
-
# @return [String] modified help text
|
|
78
|
-
|
|
79
|
-
def call(command, name)
|
|
80
|
-
help_text = original_call(command, name)
|
|
81
|
-
|
|
82
|
-
my_header, my_footer = command_help_wrapper(command)
|
|
83
|
-
|
|
84
|
-
help_text.prepend(my_header)
|
|
85
|
-
help_text += my_footer
|
|
86
|
-
|
|
87
|
-
help_text
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
# Provides the header and footer for the received command.
|
|
92
|
-
# @param command [Class] the command class
|
|
93
|
-
# @return [Array<String>] an array with the header at the 0 index and
|
|
94
|
-
# the footer at the 1 index
|
|
95
|
-
|
|
96
|
-
def command_help_wrapper(command)
|
|
97
|
-
global_header = Dry::CLI::Command.global_header
|
|
98
|
-
global_footer = Dry::CLI::Command.global_footer
|
|
99
|
-
command_header = command.header
|
|
100
|
-
command_footer = command.footer
|
|
101
|
-
|
|
102
|
-
my_header = ""
|
|
103
|
-
my_header += global_header + "\n" unless (global_header.nil? || global_header.empty?)
|
|
104
|
-
my_header += command_header+ "\n" unless (command_header.nil?|| command_header.empty?)
|
|
105
|
-
|
|
106
|
-
my_footer = ""
|
|
107
|
-
my_footer += "\n" + command_footer unless (command_footer.nil?|| command_footer.empty?)
|
|
108
|
-
my_footer += "\n" + global_footer unless (global_footer.nil? || global_footer.empty?)
|
|
109
|
-
|
|
110
|
-
[my_header, my_footer]
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
module Dry::CLI::Usage
|
|
117
|
-
class << self
|
|
118
|
-
alias_method :original_call, :call
|
|
119
|
-
|
|
120
|
-
# Overwrites the original 'call' method to allow a global header
|
|
121
|
-
# and footer wrap for the help text.
|
|
122
|
-
# @return [String] modified help text
|
|
123
|
-
|
|
124
|
-
def call(result)
|
|
125
|
-
help_text = original_call(result)
|
|
126
|
-
|
|
127
|
-
global_header = Dry::CLI::Command.global_header
|
|
128
|
-
global_footer = Dry::CLI::Command.global_footer
|
|
129
|
-
|
|
130
|
-
help_text.prepend(global_header + "\n") unless (global_header.nil? || global_header.empty?)
|
|
131
|
-
help_text += "\n" + global_footer unless (global_footer.nil? || global_footer.empty?)
|
|
132
|
-
|
|
133
|
-
help_text
|
|
134
|
-
end
|
|
135
|
-
end
|
|
136
|
-
end
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
class Dry::CLI::Command
|
|
140
|
-
# Provides a way to set a custom, command specific header.
|
|
141
|
-
# @param a_string [String] optional, header text
|
|
142
|
-
# @return [String] header text
|
|
143
|
-
|
|
144
|
-
def self.header(a_string=nil)
|
|
145
|
-
if a_string.nil?
|
|
146
|
-
@header_string
|
|
147
|
-
else
|
|
148
|
-
@header_string = a_string
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
# Provides a way to set a custom, command specific footer.
|
|
154
|
-
# @param a_string [String] optional, footer text
|
|
155
|
-
# @return [String] footer text
|
|
156
|
-
|
|
157
|
-
def self.footer(a_string=nil)
|
|
158
|
-
if a_string.nil?
|
|
159
|
-
@footer_string
|
|
160
|
-
else
|
|
161
|
-
@footer_string = a_string
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
# Provides a way to set a global custom header to overwrite the default one.
|
|
167
|
-
# @param a_string [String] optional, global header text
|
|
168
|
-
# @return [String] global header text
|
|
169
|
-
|
|
170
|
-
def self.global_header(a_string=nil)
|
|
171
|
-
if a_string.nil?
|
|
172
|
-
@@global_header_string
|
|
173
|
-
else
|
|
174
|
-
@@global_header_string = a_string
|
|
175
|
-
end
|
|
176
|
-
end
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
# Provides a way to set a global custom footer to overwrite the default one.
|
|
180
|
-
# @param a_string [String] optional, global footer text
|
|
181
|
-
# @return [String] global footer text
|
|
182
|
-
|
|
183
|
-
def self.global_footer(a_string=nil)
|
|
184
|
-
if a_string.nil?
|
|
185
|
-
@@global_footer_string
|
|
186
|
-
else
|
|
187
|
-
@@global_footer_string = a_string
|
|
188
|
-
end
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
# Add option value transformation based upon the value of the
|
|
194
|
-
# option's "type:" parameter.
|
|
195
|
-
|
|
196
|
-
module Dry::CLI::Parser
|
|
197
|
-
TRANSFORMERS = {
|
|
198
|
-
integer: -> (v) { v&.to_i },
|
|
199
|
-
float: -> (v) { v&.to_f }
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
def self.call(command, arguments, prog_name)
|
|
203
|
-
original_arguments = arguments.dup
|
|
204
|
-
parsed_options = {}
|
|
205
|
-
|
|
206
|
-
OptionParser.new do |opts|
|
|
207
|
-
command.options.each do |option|
|
|
208
|
-
opts.on(*option.parser_options) do |value|
|
|
209
|
-
if TRANSFORMERS.has_key?(option.options[:type])
|
|
210
|
-
value = TRANSFORMERS[option.options[:type]].call(value)
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
parsed_options[option.name.to_sym] = value
|
|
214
|
-
end
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
opts.on_tail("-h", "--help") do
|
|
218
|
-
return Result.help
|
|
219
|
-
end
|
|
220
|
-
end.parse!(arguments)
|
|
221
|
-
|
|
222
|
-
parsed_options = command.default_params.merge(parsed_options)
|
|
223
|
-
parse_required_params(command, arguments, prog_name, parsed_options)
|
|
224
|
-
rescue ::OptionParser::ParseError
|
|
225
|
-
Result.failure("ERROR: \"#{prog_name}\" was called with arguments \"#{original_arguments.join(" ")}\"") # rubocop:disable Metrics/LineLength
|
|
226
|
-
end
|
|
227
|
-
end
|
|
228
|
-
|
data/lib/sqa/activity.rb
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
# lib/sqa/activity.rb
|
|
2
|
-
|
|
3
|
-
# Historical daily stock activity
|
|
4
|
-
# primary id is [ticker, date]
|
|
5
|
-
|
|
6
|
-
class SQA::Activity < ActiveRecord::Base
|
|
7
|
-
# belongs_to :stock using ticker as the foreign key
|
|
8
|
-
# need a unique constraint on [ticker, date]
|
|
9
|
-
# should date be saved as a Date object or string?
|
|
10
|
-
end
|
data/lib/sqa/cli.rb
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
# lib/sqa/cli.rb
|
|
2
|
-
|
|
3
|
-
require 'dry/cli'
|
|
4
|
-
|
|
5
|
-
require_relative '../sqa'
|
|
6
|
-
require_relative 'commands'
|
|
7
|
-
|
|
8
|
-
module SQA::CLI
|
|
9
|
-
class << self
|
|
10
|
-
def run!
|
|
11
|
-
Dry::CLI.new(SQA::Commands).call
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
__END__
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
# header "Stock Quantitative Analysis (SQA)"
|
|
25
|
-
# footer "WARNING: This is a toy, a play thing, not intended for serious use."
|
|
26
|
-
|
|
27
|
-
# program "sqa"
|
|
28
|
-
# desc "A collection of things"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
class << self
|
|
34
|
-
|
|
35
|
-
##################################################
|
|
36
|
-
def run(argv = ARGV)
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
elsif params[:dump_config]
|
|
40
|
-
SQA.config.config_file = params[:dump_config]
|
|
41
|
-
`touch #{SQA.config.config_file}`
|
|
42
|
-
SQA.config.dump_file
|
|
43
|
-
exit(0)
|
|
44
|
-
|
|
45
|
-
elsif params[:config_file]
|
|
46
|
-
# Override the defaults <- envars <- config file content
|
|
47
|
-
params[:config_file] = SQA.homify params[:config_file]
|
|
48
|
-
SQA.config.config_file = params[:config_file]
|
|
49
|
-
SQA.config.from_file
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
# Override the defaults <- envars <- config file <- cli parameters
|
|
55
|
-
SQA.config.merge!(remove_temps params.to_h)
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
end
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|