amor71 / LiuAlgoTrader

Framework for algorithmic trading
MIT License
784 stars 129 forks source link

Alpaca api changes #391

Closed amor71 closed 1 year ago

sourcery-ai[bot] commented 1 year ago

Sourcery Code Quality Report

❌  Merging this PR will decrease code quality in the affected files by 0.46%.

Quality metrics Before After Change
Complexity 7.90 ⭐ 8.20 ⭐ 0.30 👎
Method Length 74.47 🙂 72.80 🙂 -1.67 👍
Working memory 9.10 🙂 9.35 🙂 0.25 👎
Quality 65.51% 🙂 65.05% 🙂 -0.46% 👎
Other metrics Before After Change
Lines 8814 8104 -710
Changed files Quality Before Quality After Quality Change
analysis/backtester_ui.py 4.62% ⛔ 4.62% ⛔ 0.00%
analysis/day_trade_ui.py 3.30% ⛔ 3.30% ⛔ 0.00%
examples/skeleton-strategy/my_strategy.py 58.42% 🙂 59.47% 🙂 1.05% 👍
liualgotrader/enhanced_backtest.py 52.93% 🙂 53.70% 🙂 0.77% 👍
liualgotrader/analytics/analysis.py 59.84% 🙂 59.77% 🙂 -0.07% 👎
liualgotrader/common/config.py 57.01% 🙂 56.07% 🙂 -0.94% 👎
liualgotrader/common/data_loader.py 67.28% 🙂 66.70% 🙂 -0.58% 👎
liualgotrader/common/market_data.py 65.38% 🙂 65.39% 🙂 0.01% 👍
liualgotrader/data/alpaca.py 61.09% 🙂 68.00% 🙂 6.91% 👍
liualgotrader/data/data_base.py 88.07% ⭐ 86.93% ⭐ -1.14% 👎
liualgotrader/models/portfolio.py 85.90% ⭐ 85.81% ⭐ -0.09% 👎
liualgotrader/scanners/momentum.py 74.61% 🙂 73.49% 🙂 -1.12% 👎
liualgotrader/scripts/backtester.py 29.84% 😞 31.64% 😞 1.80% 👍
liualgotrader/scripts/liu.py 36.78% 😞 39.54% 😞 2.76% 👍
liualgotrader/scripts/market_miner.py 64.51% 🙂 63.47% 🙂 -1.04% 👎
liualgotrader/scripts/optimizer.py 68.33% 🙂 68.79% 🙂 0.46% 👍
liualgotrader/scripts/portfolio.py 86.79% ⭐ 87.36% ⭐ 0.57% 👍
liualgotrader/scripts/trader.py 46.70% 😞 48.75% 😞 2.05% 👍
liualgotrader/strategies/base.py 76.78% ⭐ 76.81% ⭐ 0.03% 👍
liualgotrader/trading/alpaca.py 68.99% 🙂 70.16% 🙂 1.17% 👍
liualgotrader/trading/base.py 95.71% ⭐ 95.06% ⭐ -0.65% 👎
liualgotrader/trading/gemini.py 72.68% 🙂 74.11% 🙂 1.43% 👍
tests/test_alpaca_basic.py 90.10% ⭐ 89.70% ⭐ -0.40% 👎
tests/test_alpaca_crypto_data_loader.py 86.79% ⭐ 89.14% ⭐ 2.35% 👍
tests/test_alpaca_data_loader.py 85.97% ⭐ 82.08% ⭐ -3.89% 👎
tests/test_alpaca_data_loader_concurrency.py 70.39% 🙂 68.34% 🙂 -2.05% 👎
tests/test_alpaca_data_loader_multi.py 61.32% 🙂 61.61% 🙂 0.29% 👍
tests/test_alpaca_data_loader_perf.py 71.08% 🙂 66.62% 🙂 -4.46% 👎
tests/test_alpaca_stream.py 75.62% ⭐ 75.54% ⭐ -0.08% 👎
tests/test_alpaca_trader.py 90.90% ⭐ 88.60% ⭐ -2.30% 👎
tests/test_alpacadata.py 88.78% ⭐ 88.78% ⭐ 0.00%
tests/test_assets.py 97.34% ⭐ 97.67% ⭐ 0.33% 👍
tests/test_backtest.py 75.61% ⭐ 75.76% ⭐ 0.15% 👍
tests/test_create_scanner.py 92.55% ⭐ 92.99% ⭐ 0.44% 👍
tests/test_data_date_ranges.py 73.50% 🙂 76.68% ⭐ 3.18% 👍
tests/test_db.py 100.00% ⭐ 100.00% ⭐ 0.00%
tests/test_decorators.py 95.24% ⭐ 95.24% ⭐ 0.00%
tests/test_fincalc_vwap.py 66.29% 🙂 66.47% 🙂 0.18% 👍
tests/test_gemini_basic.py 84.62% ⭐ 84.93% ⭐ 0.31% 👍
tests/test_gemini_data_loader.py 82.72% ⭐ 83.03% ⭐ 0.31% 👍
tests/test_gemini_trader.py 86.67% ⭐ 86.21% ⭐ -0.46% 👎
tests/test_hyperparameters.py 93.67% ⭐ 93.85% ⭐ 0.18% 👍
tests/test_load_strategy.py 94.01% ⭐ 93.66% ⭐ -0.35% 👎
tests/test_market_data.py 71.83% 🙂 71.76% 🙂 -0.07% 👎
tests/test_momentum_scanner.py 88.42% ⭐ 88.42% ⭐ 0.00%
tests/test_portfolio.py 85.29% ⭐ 85.76% ⭐ 0.47% 👍
tests/test_tradeplan.py 91.79% ⭐ 92.19% ⭐ 0.40% 👍
tests/test_trader_calendar.py 95.04% ⭐ 95.36% ⭐ 0.32% 👍
tests/test_tradier_basics.py 91.61% ⭐ 91.93% ⭐ 0.32% 👍

Here are some functions in these files that still need a tune-up:

File Function Complexity Length Working Memory Quality Recommendation
liualgotrader/scripts/backtester.py main_cli 33 ⛔ 463 ⛔ 27 ⛔ 10.20% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
liualgotrader/scripts/liu.py quickstart 31 😞 578 ⛔ 12 😞 21.98% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
liualgotrader/analytics/analysis.py calc_symbol_trades_returns 27 😞 271 ⛔ 15 😞 24.10% ⛔ Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
liualgotrader/scripts/liu.py main_cli 28 😞 206 ⛔ 13 😞 29.90% 😞 Refactor to reduce nesting. Try splitting into smaller methods. Extract out complex expressions
liualgotrader/enhanced_backtest.py do_strategy_result 16 🙂 313 ⛔ 15 😞 30.06% 😞 Try splitting into smaller methods. Extract out complex expressions

Legend and Explanation

The emojis denote the absolute quality of the code:

The 👍 and 👎 indicate whether the quality has improved or gotten worse with this pull request.


Please see our documentation here for details on how these metrics are calculated.

We are actively working on this report - lots more documentation and extra metrics to come!

Help us improve this quality report!

sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 17 Code Smells

No Coverage information No Coverage information
0.1% 0.1% Duplication

github-actions[bot] commented 1 year ago

Stale pull request message