buda_api 1.0.0 โ†’ 1.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4a433f2896be92c5a860e32dd6d2ee0dcfe1de74cf5f6f49a9da3d60c9c63750
4
- data.tar.gz: 2ac6836267f19130e6c130e96475cff7b98a6ea84d611ec3fdfd5a3b1c7aeba5
3
+ metadata.gz: e1106716da601c58bf56e37ff6308dbb2bd269ff5827c9d99e710b402fabfe88
4
+ data.tar.gz: 672bda6f820e1c816a29145e25f2c78ddc4f7a9ca645a435f3848ae3da15e02d
5
5
  SHA512:
6
- metadata.gz: 898d29f2186c0072b78062e4e0c61bd37587cd3e666f4aab8b7182169f5a260e2218daab6e892fc51369d58f1c05f2cf3e9a8ea9aaa81271ec9ec5cefcea87c0
7
- data.tar.gz: '05972086e7ce2168148375c016e8e937fcf42ad1c79426c5cd0c15dfd76c2dff074556c10bdf7bd2463341a3ea675a775b09e4314c521a4ce33dcd13ca7cdf64'
6
+ metadata.gz: 0be69e4ed08718e1b9377bf1f6a447c049567b0eedf9ce0200b29a6c4ee8d99c3e285db9ccdf74fe7cc92a4f1635de9382f91770784b3c8e385649eca9ac93cd
7
+ data.tar.gz: 053b5fc3d4d904d75dca3d0cdd2360ddba1ea6bafe974b81c284e69763badbaf0b290677637a2dbf10b075f6b3dbcc7053ac66b85cc7fa5e861277e252bd0e1a
data/README.md CHANGED
@@ -16,6 +16,7 @@ A comprehensive Ruby SDK for [Buda.com](https://buda.com) cryptocurrency exchang
16
16
  - โšก **Automatic Retries** - Built-in retry logic for transient failures
17
17
  - ๐Ÿ“– **Extensive Documentation** - Complete API reference and examples
18
18
  - ๐Ÿงช **Comprehensive Examples** - Real-world usage examples including a trading bot
19
+ - ๐Ÿค– **AI-Powered Trading** - Advanced AI features with RubyLLM integration
19
20
 
20
21
  ## Installation
21
22
 
@@ -37,6 +38,12 @@ Or install it yourself as:
37
38
  $ gem install buda_api
38
39
  ```
39
40
 
41
+ For AI features, also install:
42
+
43
+ ```bash
44
+ $ gem install ruby_llm
45
+ ```
46
+
40
47
  ## Quick Start
41
48
 
42
49
  ### Public API (No Authentication Required)
@@ -373,6 +380,14 @@ The SDK includes comprehensive examples in the `examples/` directory:
373
380
 
374
381
  - [`trading_bot_example.rb`](examples/trading_bot_example.rb) - Simple trading bot with price monitoring
375
382
 
383
+ ### AI-Enhanced Examples
384
+
385
+ - [`ai/trading_assistant_example.rb`](examples/ai/trading_assistant_example.rb) - Comprehensive AI trading assistant
386
+ - [`ai/natural_language_trading.rb`](examples/ai/natural_language_trading.rb) - Conversational trading interface
387
+ - [`ai/risk_management_example.rb`](examples/ai/risk_management_example.rb) - AI-powered risk analysis
388
+ - [`ai/anomaly_detection_example.rb`](examples/ai/anomaly_detection_example.rb) - Market anomaly detection
389
+ - [`ai/report_generation_example.rb`](examples/ai/report_generation_example.rb) - Automated trading reports
390
+
376
391
  ### Running Examples
377
392
 
378
393
  1. Copy the environment file:
@@ -391,6 +406,9 @@ BUDA_API_SECRET=your_api_secret_here
391
406
  # Public API example (no credentials needed)
392
407
  ruby examples/public_api_example.rb
393
408
 
409
+ # AI-enhanced trading assistant
410
+ ruby examples/ai/trading_assistant_example.rb
411
+
394
412
  # Authenticated API example (requires credentials)
395
413
  ruby examples/authenticated_api_example.rb
396
414
 
@@ -462,9 +480,88 @@ The SDK automatically handles HMAC-SHA384 signature generation:
462
480
  2. Creates signature using HTTP method, path, body, and nonce
463
481
  3. Includes proper headers: `X-SBTC-APIKEY`, `X-SBTC-NONCE`, `X-SBTC-SIGNATURE`
464
482
 
483
+ ## AI Features
484
+
485
+ The BudaApi Ruby SDK includes powerful AI enhancements through RubyLLM integration:
486
+
487
+ ### Trading Assistant
488
+ ```ruby
489
+ # Initialize AI trading assistant
490
+ assistant = BudaApi.trading_assistant(client)
491
+
492
+ # Get AI market analysis
493
+ analysis = assistant.analyze_market("BTC-CLP")
494
+ puts analysis[:ai_recommendation][:action] # "buy", "sell", or "hold"
495
+ puts analysis[:ai_recommendation][:confidence] # Confidence percentage
496
+
497
+ # Get trading strategy recommendations
498
+ strategy = assistant.suggest_trading_strategy(
499
+ market_id: "BTC-CLP",
500
+ risk_tolerance: "medium",
501
+ investment_horizon: "short_term"
502
+ )
503
+ ```
504
+
505
+ ### Natural Language Trading
506
+ ```ruby
507
+ # Create conversational trading interface
508
+ nl_trader = BudaApi.natural_language_trader(client)
509
+
510
+ # Execute commands in natural language
511
+ result = nl_trader.execute_command("Check my Bitcoin balance")
512
+ result = nl_trader.execute_command("What's the current price of Ethereum?")
513
+ result = nl_trader.execute_command("Buy 0.001 BTC at market price")
514
+ ```
515
+
516
+ ### Risk Management
517
+ ```ruby
518
+ # Initialize AI risk manager
519
+ risk_manager = BudaApi::AI::RiskManager.new(client)
520
+
521
+ # Analyze portfolio risk with AI insights
522
+ portfolio_risk = risk_manager.analyze_portfolio_risk(
523
+ include_ai_insights: true
524
+ )
525
+
526
+ # Evaluate individual trade risk
527
+ trade_risk = risk_manager.evaluate_trade_risk(
528
+ "BTC-CLP", "buy", 0.001
529
+ )
530
+ ```
531
+
532
+ ### Anomaly Detection
533
+ ```ruby
534
+ # Create market anomaly detector
535
+ detector = BudaApi::AI::AnomalyDetector.new(client)
536
+
537
+ # Detect market anomalies with AI analysis
538
+ anomalies = detector.detect_market_anomalies(
539
+ markets: ["BTC-CLP", "ETH-CLP"],
540
+ include_ai_analysis: true
541
+ )
542
+ ```
543
+
544
+ ### Report Generation
545
+ ```ruby
546
+ # Generate AI-powered reports
547
+ reporter = BudaApi::AI::ReportGenerator.new(client)
548
+
549
+ # Portfolio summary with AI insights
550
+ report = reporter.generate_portfolio_summary(
551
+ format: "markdown",
552
+ include_ai: true
553
+ )
554
+
555
+ # Custom AI analysis
556
+ custom_report = reporter.generate_custom_report(
557
+ "Analyze market trends and provide investment recommendations",
558
+ [:portfolio, :market]
559
+ )
560
+ ```
561
+
465
562
  ## Contributing
466
563
 
467
- 1. Fork it (https://github.com/yourusername/buda-api-ruby/fork)
564
+ 1. Fork it (https://github.com/PabloB07/buda-api-ruby/fork)
468
565
  2. Create your feature branch (`git checkout -b my-new-feature`)
469
566
  3. Commit your changes (`git commit -am 'Add some feature'`)
470
567
  4. Push to the branch (`git push origin my-new-feature`)
@@ -473,7 +570,7 @@ The SDK automatically handles HMAC-SHA384 signature generation:
473
570
  ### Development Setup
474
571
 
475
572
  ```bash
476
- git clone https://github.com/yourusername/buda-api-ruby.git
573
+ git clone https://github.com/PabloB07/buda-api-ruby.git
477
574
  cd buda-api-ruby
478
575
  bundle install
479
576
  bundle exec rspec
@@ -517,8 +614,8 @@ The authors and contributors are not responsible for any financial losses incurr
517
614
  ## Support
518
615
 
519
616
  - ๐Ÿ“– [API Documentation](https://api.buda.com)
520
- - ๐Ÿ› [Issue Tracker](https://github.com/yourusername/buda-api-ruby/issues)
521
- - ๐Ÿ’ฌ [Discussions](https://github.com/yourusername/buda-api-ruby/discussions)
617
+ - ๐Ÿ› [Issue Tracker](https://github.com/PabloB07/buda-api-ruby/issues)
618
+ - ๐Ÿ’ฌ [Discussions](https://github.com/PabloB07/buda-api-ruby/discussions)
522
619
 
523
620
  ## Related Projects
524
621
 
data/buda_api.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "buda_api"
3
- spec.version = "1.0.0"
3
+ spec.version = "1.0.1"
4
4
  spec.authors = ["Buda API Ruby SDK"]
5
5
  spec.email = ["pablob0798@gmail.com"]
6
6
 
@@ -29,6 +29,9 @@ Gem::Specification.new do |spec|
29
29
  spec.add_dependency "logger", "~> 1.5"
30
30
  spec.add_dependency "json", "~> 2.6"
31
31
 
32
+ # Optional AI dependencies
33
+ spec.add_dependency "ruby_llm", "~> 0.5", ">= 0.5.0"
34
+
32
35
  # Development dependencies
33
36
  spec.add_development_dependency "rspec", "~> 3.0"
34
37
  spec.add_development_dependency "webmock", "~> 3.0"
@@ -0,0 +1,314 @@
1
+ # AI-Enhanced Ruby SDK Examples
2
+
3
+ This directory contains comprehensive examples demonstrating the AI-powered features of the BudaApi Ruby SDK.
4
+
5
+ ## Examples Overview
6
+
7
+ ### 1. Trading Assistant (`trading_assistant_example.rb`)
8
+ **Main AI-Enhanced Trading Example**
9
+
10
+ Comprehensive demonstration of AI trading capabilities including:
11
+ - **Market Analysis**: AI-powered technical and fundamental analysis
12
+ - **Trading Strategies**: Intelligent strategy recommendations
13
+ - **Entry/Exit Signals**: Automated signal generation
14
+ - **Natural Language Trading**: Conversational trading interface
15
+ - **Risk Management**: Portfolio risk assessment
16
+ - **Anomaly Detection**: Market irregularity detection
17
+ - **Report Generation**: AI-generated trading reports
18
+ - **Interactive Mode**: Real-time AI trading assistant
19
+
20
+ ```bash
21
+ # Run the main example
22
+ ruby examples/ai/trading_assistant_example.rb
23
+
24
+ # Run in interactive mode
25
+ ruby examples/ai/trading_assistant_example.rb
26
+ # Select option 2 for interactive mode
27
+ ```
28
+
29
+ ### 2. Advanced Risk Management (`risk_management_example.rb`)
30
+ **Comprehensive Risk Analysis System**
31
+
32
+ Features:
33
+ - **Portfolio Risk Analysis**: Diversification and concentration analysis
34
+ - **Pre-Trade Risk Evaluation**: Risk assessment before placing orders
35
+ - **Risk Monitoring**: Real-time threshold monitoring with alerts
36
+ - **Stop-Loss Recommendations**: AI-calculated stop-loss levels
37
+ - **Position Sizing**: Risk-adjusted position calculations
38
+ - **Correlation Analysis**: Asset correlation detection
39
+ - **Risk Dashboard**: Comprehensive risk overview
40
+
41
+ ```bash
42
+ ruby examples/ai/risk_management_example.rb
43
+ ```
44
+
45
+ ### 3. Natural Language Trading (`natural_language_trading.rb`)
46
+ **Conversational Trading Interface**
47
+
48
+ Chat-based trading with AI:
49
+ - **Natural Language Queries**: Ask questions in plain English
50
+ - **Balance Inquiries**: "Check my BTC balance"
51
+ - **Market Data**: "What's the current price of Ethereum?"
52
+ - **Trading Commands**: "Buy 0.001 BTC at market price"
53
+ - **Safety Features**: Demo mode and confirmations
54
+ - **Context Awareness**: Maintains conversation history
55
+
56
+ ```bash
57
+ ruby examples/ai/natural_language_trading.rb
58
+ ```
59
+
60
+ ### 4. Anomaly Detection (`anomaly_detection_example.rb`)
61
+ **AI-Powered Market Monitoring**
62
+
63
+ Automated market surveillance:
64
+ - **Real-Time Scanning**: Continuous market anomaly detection
65
+ - **Multiple Detection Types**: Price spikes, volume anomalies, whale activity
66
+ - **Severity Classification**: Critical, high, medium, low alerts
67
+ - **Historical Analysis**: Pattern detection in historical data
68
+ - **AI Analysis**: Intelligent anomaly interpretation
69
+ - **Monitoring Modes**: One-time, continuous, or single-market analysis
70
+
71
+ ```bash
72
+ # One-time scan
73
+ ruby examples/ai/anomaly_detection_example.rb
74
+
75
+ # Demo mode (simulated data)
76
+ ruby examples/ai/anomaly_detection_example.rb --demo
77
+ ```
78
+
79
+ ### 5. Report Generation (`report_generation_example.rb`)
80
+ **Automated AI Report System**
81
+
82
+ Professional trading reports:
83
+ - **Portfolio Reports**: Comprehensive portfolio analysis
84
+ - **Trading Performance**: Trading statistics and insights
85
+ - **Market Analysis**: Market trend analysis
86
+ - **Custom Reports**: AI-generated custom analysis
87
+ - **Multiple Formats**: Markdown, HTML, JSON, CSV export
88
+ - **Report Dashboard**: Interactive report generation interface
89
+
90
+ ```bash
91
+ # Interactive dashboard
92
+ ruby examples/ai/report_generation_example.rb
93
+
94
+ # Generate demo reports
95
+ ruby examples/ai/report_generation_example.rb --demo
96
+ ```
97
+
98
+ ## Prerequisites
99
+
100
+ ### Required Gems
101
+ ```bash
102
+ # Install the AI dependency
103
+ gem install ruby_llm
104
+
105
+ # Or add to your Gemfile
106
+ gem 'ruby_llm', '~> 0.5'
107
+ ```
108
+
109
+ ### API Configuration
110
+ Set your Buda API credentials:
111
+
112
+ ```bash
113
+ export BUDA_API_KEY="your_api_key_here"
114
+ export BUDA_API_SECRET="your_api_secret_here"
115
+ ```
116
+
117
+ ### LLM Provider Setup
118
+ Configure your preferred AI provider:
119
+
120
+ **OpenAI (Recommended)**
121
+ ```bash
122
+ export OPENAI_API_KEY="your_openai_key"
123
+ ```
124
+
125
+ **Anthropic Claude**
126
+ ```bash
127
+ export ANTHROPIC_API_KEY="your_anthropic_key"
128
+ ```
129
+
130
+ ## Usage Patterns
131
+
132
+ ### Basic AI Trading Assistant
133
+ ```ruby
134
+ require_relative '../lib/buda_api'
135
+
136
+ client = BudaApi::AuthenticatedClient.new(
137
+ api_key: ENV['BUDA_API_KEY'],
138
+ api_secret: ENV['BUDA_API_SECRET']
139
+ )
140
+
141
+ # Initialize AI assistant
142
+ assistant = BudaApi.trading_assistant(client)
143
+
144
+ # Get market analysis
145
+ analysis = assistant.analyze_market("BTC-CLP")
146
+ puts "Trend: #{analysis[:trend]}"
147
+ puts "AI Recommendation: #{analysis[:ai_recommendation][:action]}"
148
+ ```
149
+
150
+ ### Natural Language Trading
151
+ ```ruby
152
+ # Create natural language trader
153
+ nl_trader = BudaApi.natural_language_trader(client)
154
+
155
+ # Execute commands in natural language
156
+ result = nl_trader.execute_command("Check my Bitcoin balance")
157
+ result = nl_trader.execute_command("What's the current ETH price?")
158
+ result = nl_trader.execute_command("Buy 0.001 BTC at market price")
159
+ ```
160
+
161
+ ### Risk Management
162
+ ```ruby
163
+ # Initialize risk manager
164
+ risk_manager = BudaApi::AI::RiskManager.new(client)
165
+
166
+ # Analyze portfolio risk
167
+ portfolio_risk = risk_manager.analyze_portfolio_risk(
168
+ include_ai_insights: true
169
+ )
170
+
171
+ # Evaluate trade risk
172
+ trade_risk = risk_manager.evaluate_trade_risk(
173
+ "BTC-CLP", "buy", 0.001
174
+ )
175
+
176
+ puts "Trade Risk: #{trade_risk[:risk_level]}"
177
+ puts "Should Proceed: #{trade_risk[:should_proceed]}"
178
+ ```
179
+
180
+ ### Anomaly Detection
181
+ ```ruby
182
+ # Create anomaly detector
183
+ detector = BudaApi::AI::AnomalyDetector.new(client)
184
+
185
+ # Detect market anomalies
186
+ anomalies = detector.detect_market_anomalies(
187
+ markets: ["BTC-CLP", "ETH-CLP"],
188
+ include_ai_analysis: true
189
+ )
190
+
191
+ puts "Anomalies Detected: #{anomalies[:anomalies_detected]}"
192
+ ```
193
+
194
+ ### Report Generation
195
+ ```ruby
196
+ # Initialize report generator
197
+ reporter = BudaApi::AI::ReportGenerator.new(client)
198
+
199
+ # Generate portfolio report
200
+ report = reporter.generate_portfolio_summary(
201
+ format: "markdown",
202
+ include_ai: true
203
+ )
204
+
205
+ # Export to file
206
+ reporter.export_report(report, "portfolio_report.md")
207
+ ```
208
+
209
+ ## AI Features Overview
210
+
211
+ ### Market Analysis Capabilities
212
+ - **Technical Analysis**: Price patterns, trends, support/resistance
213
+ - **Fundamental Analysis**: Market sentiment, news impact assessment
214
+ - **Risk Assessment**: Volatility analysis, correlation detection
215
+ - **Strategy Recommendations**: Entry/exit points, position sizing
216
+
217
+ ### Natural Language Processing
218
+ - **Command Interpretation**: Understands trading intentions in natural language
219
+ - **Context Awareness**: Maintains conversation history and context
220
+ - **Error Handling**: Provides helpful suggestions for unclear commands
221
+ - **Safety Features**: Confirms potentially risky operations
222
+
223
+ ### Risk Management AI
224
+ - **Portfolio Analysis**: Diversification scoring, concentration risk
225
+ - **Pre-Trade Evaluation**: Impact assessment before order placement
226
+ - **Dynamic Monitoring**: Real-time risk threshold monitoring
227
+ - **Predictive Modeling**: Risk-adjusted return optimization
228
+
229
+ ### Anomaly Detection AI
230
+ - **Pattern Recognition**: Identifies unusual market behaviors
231
+ - **Multi-Factor Analysis**: Price, volume, spread, and correlation anomalies
232
+ - **Severity Scoring**: Intelligent risk prioritization
233
+ - **Real-Time Monitoring**: Continuous market surveillance
234
+
235
+ ### Report Generation AI
236
+ - **Intelligent Summarization**: Key insights extraction
237
+ - **Trend Analysis**: Pattern identification and explanation
238
+ - **Actionable Recommendations**: Specific improvement suggestions
239
+ - **Multi-Format Export**: Professional report formatting
240
+
241
+ ## Safety Features
242
+
243
+ ### Demo Mode
244
+ All examples default to demo/sandbox mode for safety:
245
+ - No real trades are executed without explicit confirmation
246
+ - Clear indicators when in demo vs. live mode
247
+ - Sandbox API endpoints used by default
248
+
249
+ ### Confirmation Systems
250
+ - **Trade Confirmations**: All trading operations require explicit confirmation
251
+ - **Risk Warnings**: High-risk operations trigger warnings
252
+ - **Clear Feedback**: Detailed success/error messages
253
+
254
+ ### Error Handling
255
+ - **Graceful Degradation**: Functions work even if AI features unavailable
256
+ - **Helpful Error Messages**: Clear guidance when issues occur
257
+ - **Fallback Options**: Alternative approaches when AI fails
258
+
259
+ ## Performance Notes
260
+
261
+ ### API Rate Limits
262
+ - Examples include appropriate delays between API calls
263
+ - Batch operations optimize API usage
264
+ - Rate limit error handling and retry logic
265
+
266
+ ### AI Provider Costs
267
+ - Most examples use moderate token limits to control costs
268
+ - Optional AI features can be disabled to reduce usage
269
+ - Clear documentation of approximate token consumption
270
+
271
+ ## Troubleshooting
272
+
273
+ ### Common Issues
274
+
275
+ **AI Features Not Available**
276
+ ```
277
+ โŒ AI features are not available. Please install ruby_llm gem:
278
+ gem install ruby_llm
279
+ ```
280
+
281
+ **Authentication Errors**
282
+ ```
283
+ โŒ Authentication failed. Please check your API credentials.
284
+ ```
285
+ Set proper environment variables:
286
+ ```bash
287
+ export BUDA_API_KEY="your_key"
288
+ export BUDA_API_SECRET="your_secret"
289
+ ```
290
+
291
+ **LLM API Errors**
292
+ - Verify your LLM provider API key is set
293
+ - Check your API quota/billing status
294
+ - Try a different LLM provider
295
+
296
+ ### Debug Mode
297
+ Enable debug output:
298
+ ```bash
299
+ DEBUG=1 ruby examples/ai/trading_assistant_example.rb
300
+ ```
301
+
302
+ ## Contributing
303
+
304
+ When adding new AI examples:
305
+
306
+ 1. **Follow Safety Patterns**: Always default to demo mode
307
+ 2. **Include Error Handling**: Graceful degradation when AI unavailable
308
+ 3. **Add Documentation**: Clear comments and usage instructions
309
+ 4. **Test Thoroughly**: Verify both AI and non-AI code paths
310
+ 5. **Optimize Costs**: Be mindful of LLM API usage
311
+
312
+ ## License
313
+
314
+ These examples are part of the BudaApi Ruby SDK and are subject to the same license terms.