ollama-client 0.2.5 → 0.2.7
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/CHANGELOG.md +22 -0
- data/README.md +336 -91
- data/RELEASE_NOTES_v0.2.6.md +41 -0
- data/docs/AREAS_FOR_CONSIDERATION.md +325 -0
- data/docs/EXAMPLE_REORGANIZATION.md +412 -0
- data/docs/FEATURES_ADDED.md +12 -1
- data/docs/GETTING_STARTED.md +361 -0
- data/docs/INTEGRATION_TESTING.md +170 -0
- data/docs/NEXT_STEPS_SUMMARY.md +114 -0
- data/docs/PERSONAS.md +383 -0
- data/docs/QUICK_START.md +195 -0
- data/docs/TESTING.md +392 -170
- data/docs/TEST_CHECKLIST.md +450 -0
- data/examples/README.md +62 -63
- data/examples/basic_chat.rb +33 -0
- data/examples/basic_generate.rb +29 -0
- data/examples/mcp_executor.rb +39 -0
- data/examples/mcp_http_executor.rb +45 -0
- data/examples/tool_calling_parsing.rb +59 -0
- data/examples/tool_dto_example.rb +0 -0
- data/exe/ollama-client +128 -1
- data/lib/ollama/agent/planner.rb +7 -2
- data/lib/ollama/chat_session.rb +101 -0
- data/lib/ollama/client.rb +41 -35
- data/lib/ollama/config.rb +9 -4
- data/lib/ollama/document_loader.rb +1 -1
- data/lib/ollama/embeddings.rb +61 -28
- data/lib/ollama/errors.rb +1 -0
- data/lib/ollama/mcp/http_client.rb +149 -0
- data/lib/ollama/mcp/stdio_client.rb +146 -0
- data/lib/ollama/mcp/tools_bridge.rb +72 -0
- data/lib/ollama/mcp.rb +31 -0
- data/lib/ollama/options.rb +3 -1
- data/lib/ollama/personas.rb +287 -0
- data/lib/ollama/version.rb +1 -1
- data/lib/ollama_client.rb +17 -5
- metadata +22 -48
- data/examples/advanced_complex_schemas.rb +0 -366
- data/examples/advanced_edge_cases.rb +0 -241
- data/examples/advanced_error_handling.rb +0 -200
- data/examples/advanced_multi_step_agent.rb +0 -341
- data/examples/advanced_performance_testing.rb +0 -186
- data/examples/chat_console.rb +0 -143
- data/examples/complete_workflow.rb +0 -245
- data/examples/dhan_console.rb +0 -843
- data/examples/dhanhq/README.md +0 -236
- data/examples/dhanhq/agents/base_agent.rb +0 -74
- data/examples/dhanhq/agents/data_agent.rb +0 -66
- data/examples/dhanhq/agents/orchestrator_agent.rb +0 -120
- data/examples/dhanhq/agents/technical_analysis_agent.rb +0 -252
- data/examples/dhanhq/agents/trading_agent.rb +0 -81
- data/examples/dhanhq/analysis/market_structure.rb +0 -138
- data/examples/dhanhq/analysis/pattern_recognizer.rb +0 -192
- data/examples/dhanhq/analysis/trend_analyzer.rb +0 -88
- data/examples/dhanhq/builders/market_context_builder.rb +0 -67
- data/examples/dhanhq/dhanhq_agent.rb +0 -829
- data/examples/dhanhq/indicators/technical_indicators.rb +0 -158
- data/examples/dhanhq/scanners/intraday_options_scanner.rb +0 -492
- data/examples/dhanhq/scanners/swing_scanner.rb +0 -247
- data/examples/dhanhq/schemas/agent_schemas.rb +0 -61
- data/examples/dhanhq/services/base_service.rb +0 -46
- data/examples/dhanhq/services/data_service.rb +0 -118
- data/examples/dhanhq/services/trading_service.rb +0 -59
- data/examples/dhanhq/technical_analysis_agentic_runner.rb +0 -411
- data/examples/dhanhq/technical_analysis_runner.rb +0 -420
- data/examples/dhanhq/test_tool_calling.rb +0 -538
- data/examples/dhanhq/test_tool_calling_verbose.rb +0 -251
- data/examples/dhanhq/utils/instrument_helper.rb +0 -32
- data/examples/dhanhq/utils/parameter_cleaner.rb +0 -28
- data/examples/dhanhq/utils/parameter_normalizer.rb +0 -45
- data/examples/dhanhq/utils/rate_limiter.rb +0 -23
- data/examples/dhanhq/utils/trading_parameter_normalizer.rb +0 -72
- data/examples/dhanhq_agent.rb +0 -964
- data/examples/dhanhq_tools.rb +0 -1663
- data/examples/multi_step_agent_with_external_data.rb +0 -368
- data/examples/structured_outputs_chat.rb +0 -72
- data/examples/structured_tools.rb +0 -89
- data/examples/test_dhanhq_tool_calling.rb +0 -375
- data/examples/test_tool_calling.rb +0 -160
- data/examples/tool_calling_direct.rb +0 -124
- data/examples/tool_calling_pattern.rb +0 -269
- data/exe/dhan_console +0 -4
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require_relative "market_structure"
|
|
4
|
-
require_relative "pattern_recognizer"
|
|
5
|
-
require_relative "../indicators/technical_indicators"
|
|
6
|
-
|
|
7
|
-
module DhanHQ
|
|
8
|
-
module Analysis
|
|
9
|
-
# Comprehensive trend analysis
|
|
10
|
-
class TrendAnalyzer
|
|
11
|
-
def self.analyze(ohlc_data)
|
|
12
|
-
return {} if ohlc_data.nil? || ohlc_data.empty?
|
|
13
|
-
|
|
14
|
-
closes = extract_closes(ohlc_data)
|
|
15
|
-
highs = extract_highs(ohlc_data)
|
|
16
|
-
lows = extract_lows(ohlc_data)
|
|
17
|
-
opens = extract_opens(ohlc_data)
|
|
18
|
-
volumes = extract_volumes(ohlc_data)
|
|
19
|
-
|
|
20
|
-
return {} if closes.nil? || closes.empty?
|
|
21
|
-
|
|
22
|
-
# Technical indicators
|
|
23
|
-
sma20 = DhanHQ::Indicators::TechnicalIndicators.sma(closes, 20)
|
|
24
|
-
sma50 = DhanHQ::Indicators::TechnicalIndicators.sma(closes, 50)
|
|
25
|
-
ema12 = DhanHQ::Indicators::TechnicalIndicators.ema(closes, 12)
|
|
26
|
-
rsi = DhanHQ::Indicators::TechnicalIndicators.rsi(closes, 14)
|
|
27
|
-
macd = DhanHQ::Indicators::TechnicalIndicators.macd(closes)
|
|
28
|
-
|
|
29
|
-
# Market structure
|
|
30
|
-
trend = MarketStructure.analyze_trend(highs, lows, closes)
|
|
31
|
-
structure_break = MarketStructure.detect_structure_break(highs, lows, closes)
|
|
32
|
-
support_resistance = DhanHQ::Indicators::TechnicalIndicators.support_resistance(highs, lows, closes)
|
|
33
|
-
|
|
34
|
-
# Patterns
|
|
35
|
-
candlestick_patterns = PatternRecognizer.detect_candlestick_patterns(opens, highs, lows, closes)
|
|
36
|
-
chart_patterns = PatternRecognizer.detect_chart_patterns(highs, lows, closes)
|
|
37
|
-
|
|
38
|
-
# SMC Analysis
|
|
39
|
-
order_blocks = MarketStructure.find_order_blocks(highs, lows, closes, volumes || [])
|
|
40
|
-
liquidity_zones = MarketStructure.find_liquidity_zones(highs, lows, closes)
|
|
41
|
-
|
|
42
|
-
{
|
|
43
|
-
trend: trend,
|
|
44
|
-
structure_break: structure_break,
|
|
45
|
-
indicators: {
|
|
46
|
-
sma20: sma20.last,
|
|
47
|
-
sma50: sma50.last,
|
|
48
|
-
ema12: ema12.last,
|
|
49
|
-
rsi: rsi.last,
|
|
50
|
-
macd: macd[:macd].last,
|
|
51
|
-
macd_signal: macd[:signal].last,
|
|
52
|
-
macd_histogram: macd[:histogram].last
|
|
53
|
-
},
|
|
54
|
-
support_resistance: support_resistance,
|
|
55
|
-
patterns: {
|
|
56
|
-
candlestick: candlestick_patterns.last(5),
|
|
57
|
-
chart: chart_patterns
|
|
58
|
-
},
|
|
59
|
-
smc: {
|
|
60
|
-
order_blocks: order_blocks.last(3),
|
|
61
|
-
liquidity_zones: liquidity_zones
|
|
62
|
-
},
|
|
63
|
-
current_price: closes.last
|
|
64
|
-
}
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
def self.extract_closes(data)
|
|
68
|
-
data.map { |d| d[:close] || d["close"] || d["c"] || d[:c] }.compact
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def self.extract_highs(data)
|
|
72
|
-
data.map { |d| d[:high] || d["high"] || d["h"] || d[:h] }.compact
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
def self.extract_lows(data)
|
|
76
|
-
data.map { |d| d[:low] || d["low"] || d["l"] || d[:l] }.compact
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def self.extract_opens(data)
|
|
80
|
-
data.map { |d| d[:open] || d["open"] || d["o"] || d[:o] }.compact
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def self.extract_volumes(data)
|
|
84
|
-
data.map { |d| d[:volume] || d["volume"] || d["v"] || d[:v] }.compact
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
end
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module DhanHQ
|
|
4
|
-
module Builders
|
|
5
|
-
# Builds human-readable market context from raw market data
|
|
6
|
-
class MarketContextBuilder
|
|
7
|
-
def self.build(market_data)
|
|
8
|
-
new(market_data).build
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
def initialize(market_data)
|
|
12
|
-
@market_data = market_data || {}
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def build
|
|
16
|
-
context_parts = []
|
|
17
|
-
context_parts << build_nifty_context
|
|
18
|
-
context_parts << build_reliance_context
|
|
19
|
-
context_parts << build_positions_context
|
|
20
|
-
context_parts.compact.join("\n")
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
private
|
|
24
|
-
|
|
25
|
-
def build_nifty_context
|
|
26
|
-
return "NIFTY data not available" unless @market_data[:nifty]
|
|
27
|
-
|
|
28
|
-
ltp = @market_data[:nifty][:ltp]
|
|
29
|
-
change = @market_data[:nifty][:change_percent]
|
|
30
|
-
|
|
31
|
-
if ltp && ltp != 0
|
|
32
|
-
"NIFTY is trading at #{ltp} (#{change || 'unknown'}% change)"
|
|
33
|
-
else
|
|
34
|
-
"NIFTY data retrieved but LTP is not available (may be outside market hours)"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def build_reliance_context
|
|
39
|
-
return "RELIANCE data not available" unless @market_data[:reliance]
|
|
40
|
-
|
|
41
|
-
ltp = @market_data[:reliance][:ltp]
|
|
42
|
-
change = @market_data[:reliance][:change_percent]
|
|
43
|
-
volume = @market_data[:reliance][:volume]
|
|
44
|
-
|
|
45
|
-
if ltp && ltp != 0
|
|
46
|
-
"RELIANCE is at #{ltp} (#{change || 'unknown'}% change, Volume: #{volume || 'N/A'})"
|
|
47
|
-
else
|
|
48
|
-
"RELIANCE data retrieved but LTP is not available (may be outside market hours)"
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
|
|
52
|
-
def build_positions_context
|
|
53
|
-
positions = @market_data[:positions] || []
|
|
54
|
-
|
|
55
|
-
if positions.empty?
|
|
56
|
-
"Current positions: None"
|
|
57
|
-
else
|
|
58
|
-
parts = ["Current positions: #{positions.length} active"]
|
|
59
|
-
positions.each do |pos|
|
|
60
|
-
parts << " - #{pos[:trading_symbol]}: #{pos[:quantity]} @ #{pos[:average_price]}"
|
|
61
|
-
end
|
|
62
|
-
parts.join("\n")
|
|
63
|
-
end
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|