380 lines
8.2 KiB
ReStructuredText
380 lines
8.2 KiB
ReStructuredText
Learning System
|
|
===============
|
|
|
|
The learning system enables agents to improve their skills through courses, unlocking better performance and new capabilities.
|
|
|
|
Overview
|
|
--------
|
|
|
|
Learning Model
|
|
~~~~~~~~~~~~~~
|
|
|
|
Agents can:
|
|
|
|
* Enroll in courses to improve skills
|
|
* Learn new trading strategies
|
|
* Unlock advanced factors
|
|
* Increase analysis accuracy
|
|
|
|
Course Types
|
|
~~~~~~~~~~~~
|
|
|
|
* **Beginner Courses**: Basic trading concepts
|
|
* **Intermediate Courses**: Technical analysis
|
|
* **Advanced Courses**: Complex strategies
|
|
* **Specialization Courses**: Specific asset classes
|
|
|
|
Using the Learning System
|
|
-------------------------
|
|
|
|
Browse Available Courses
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
from openclaw.learning.manager import LearningManager
|
|
|
|
# Create learning manager
|
|
manager = LearningManager()
|
|
|
|
# List all available courses
|
|
courses = manager.list_courses()
|
|
for course in courses:
|
|
print(f"{course.name}: {course.price} credits")
|
|
print(f" Duration: {course.duration_hours} hours")
|
|
print(f" Skill gain: +{course.skill_boost:.0%}")
|
|
|
|
Enroll in a Course
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
from openclaw.learning.manager import LearningManager
|
|
|
|
manager = LearningManager()
|
|
|
|
# Enroll agent in a course
|
|
if manager.can_enroll(agent, "technical_analysis_101"):
|
|
enrollment = manager.enroll(
|
|
agent=agent,
|
|
course_id="technical_analysis_101"
|
|
)
|
|
print(f"Enrolled: {enrollment.course.name}")
|
|
else:
|
|
print("Cannot enroll: insufficient funds or prerequisites not met")
|
|
|
|
Complete a Course
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
# Complete the course
|
|
result = manager.complete_course(agent, "technical_analysis_101")
|
|
|
|
if result.success:
|
|
print(f"Course completed!")
|
|
print(f"Skill increase: +{result.skill_increase:.0%}")
|
|
print(f"New skill level: {agent.state.skill_level:.2f}")
|
|
|
|
# Check unlocked factors
|
|
if result.unlocked_factors:
|
|
print(f"Unlocked factors: {result.unlocked_factors}")
|
|
else:
|
|
print(f"Course failed: {result.reason}")
|
|
|
|
Course Categories
|
|
-----------------
|
|
|
|
Beginner Courses
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
**Trading Fundamentals**
|
|
|
|
* Duration: 10 hours
|
|
* Cost: $50
|
|
* Skill boost: +0.05
|
|
* Prerequisites: None
|
|
|
|
Topics:
|
|
|
|
* Basic market concepts
|
|
* Order types
|
|
* Risk management basics
|
|
* Position sizing
|
|
|
|
**Technical Analysis Basics**
|
|
|
|
* Duration: 15 hours
|
|
* Cost: $75
|
|
* Skill boost: +0.08
|
|
* Prerequisites: Trading Fundamentals
|
|
|
|
Topics:
|
|
|
|
* Chart patterns
|
|
* Support and resistance
|
|
* Trend identification
|
|
* Basic indicators
|
|
|
|
Intermediate Courses
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
**Advanced Technical Analysis**
|
|
|
|
* Duration: 20 hours
|
|
* Cost: $150
|
|
* Skill boost: +0.12
|
|
* Prerequisites: Technical Analysis Basics
|
|
|
|
Topics:
|
|
|
|
* Complex patterns
|
|
* Multiple timeframe analysis
|
|
* Advanced indicators
|
|
* Volume analysis
|
|
|
|
**Sentiment Analysis**
|
|
|
|
* Duration: 18 hours
|
|
* Cost: $125
|
|
* Skill boost: +0.10
|
|
* Prerequisites: Trading Fundamentals
|
|
|
|
Topics:
|
|
|
|
* News analysis
|
|
* Social media sentiment
|
|
* Market mood indicators
|
|
* Contrarian strategies
|
|
|
|
Advanced Courses
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
**Algorithmic Trading**
|
|
|
|
* Duration: 40 hours
|
|
* Cost: $500
|
|
* Skill boost: +0.20
|
|
* Prerequisites: Advanced Technical Analysis
|
|
|
|
Topics:
|
|
|
|
* Strategy development
|
|
* Backtesting
|
|
* Optimization
|
|
* Risk management
|
|
|
|
**Machine Learning for Trading**
|
|
|
|
* Duration: 50 hours
|
|
* Cost: $750
|
|
* Skill boost: +0.25
|
|
* Prerequisites: Algorithmic Trading
|
|
|
|
Topics:
|
|
|
|
* Feature engineering
|
|
* Model selection
|
|
* Training and validation
|
|
* Live deployment
|
|
|
|
Specialization Courses
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
**Forex Trading**
|
|
|
|
* Duration: 25 hours
|
|
* Cost: $300
|
|
* Skill boost: +0.15 (forex only)
|
|
|
|
**Cryptocurrency Trading**
|
|
|
|
* Duration: 20 hours
|
|
* Cost: $250
|
|
* Skill boost: +0.12 (crypto only)
|
|
|
|
**Options Trading**
|
|
|
|
* Duration: 35 hours
|
|
* Cost: $600
|
|
* Skill boost: +0.18 (options only)
|
|
|
|
Learning Manager
|
|
----------------
|
|
|
|
Managing Enrollments
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
from openclaw.learning.manager import LearningManager
|
|
|
|
manager = LearningManager()
|
|
|
|
# Get agent's active courses
|
|
active = manager.get_active_courses(agent)
|
|
for course in active:
|
|
print(f"In progress: {course.name}")
|
|
print(f" Progress: {course.progress:.0%}")
|
|
print(f" Time remaining: {course.time_remaining} hours")
|
|
|
|
# Pause a course
|
|
manager.pause_course(agent, "technical_analysis_101")
|
|
|
|
# Resume a course
|
|
manager.resume_course(agent, "technical_analysis_101")
|
|
|
|
Checking Prerequisites
|
|
~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
# Check if prerequisites are met
|
|
can_enroll = manager.check_prerequisites(
|
|
agent=agent,
|
|
course_id="advanced_technical"
|
|
)
|
|
|
|
if not can_enroll:
|
|
missing = manager.get_missing_prerequisites(agent, "advanced_technical")
|
|
print(f"Missing prerequisites: {missing}")
|
|
|
|
Course Creation
|
|
---------------
|
|
|
|
Creating Custom Courses
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
from openclaw.learning.courses import Course, CourseContent
|
|
|
|
# Create course content
|
|
content = CourseContent(
|
|
modules=[
|
|
{
|
|
"title": "Module 1: Introduction",
|
|
"duration_hours": 2,
|
|
"topics": ["Overview", "Setup"]
|
|
},
|
|
{
|
|
"title": "Module 2: Advanced Concepts",
|
|
"duration_hours": 5,
|
|
"topics": ["Strategy", "Implementation"]
|
|
}
|
|
],
|
|
assessments=[
|
|
{
|
|
"type": "quiz",
|
|
"passing_score": 0.8
|
|
},
|
|
{
|
|
"type": "practical",
|
|
"requirements": ["Complete 5 trades"]
|
|
}
|
|
]
|
|
)
|
|
|
|
# Create course
|
|
course = Course(
|
|
course_id="custom_strategy",
|
|
name="Custom Strategy Development",
|
|
description="Learn to develop custom trading strategies",
|
|
duration_hours=20,
|
|
price=200.0,
|
|
skill_boost=0.15,
|
|
prerequisites=["technical_analysis_basics"],
|
|
unlocks_factors=["custom_factor_1", "custom_factor_2"],
|
|
content=content
|
|
)
|
|
|
|
# Register course
|
|
manager.register_course(course)
|
|
|
|
Learning Progression
|
|
--------------------
|
|
|
|
Typical Learning Path
|
|
~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
1. **Start**: Skill level 0.5
|
|
2. **Beginner Courses**: Skill level 0.5 → 0.65
|
|
3. **Intermediate Courses**: Skill level 0.65 → 0.80
|
|
4. **Advanced Courses**: Skill level 0.80 → 0.95
|
|
5. **Specialization**: Skill level 0.95 → 1.0
|
|
|
|
Skill Level Benefits
|
|
~~~~~~~~~~~~~~~~~~~~
|
|
|
|
Higher skill levels provide:
|
|
|
|
* More accurate analysis
|
|
* Better trade timing
|
|
* Lower error rates
|
|
* Access to advanced factors
|
|
* Improved win rates
|
|
|
|
Learning vs Trading Balance
|
|
---------------------------
|
|
|
|
When to Learn
|
|
~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
from openclaw.core.work_trade_balance import WorkTradeBalance
|
|
|
|
balance = WorkTradeBalance(agent)
|
|
|
|
# Check if agent should learn
|
|
if balance.should_focus_on_learning():
|
|
# Find appropriate course
|
|
course = manager.recommend_course(agent)
|
|
if course:
|
|
manager.enroll(agent, course.id)
|
|
print(f"Enrolled in {course.name} to improve skills")
|
|
else:
|
|
print("Agent should continue trading")
|
|
|
|
Auto-Learning Mode
|
|
~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
# Enable auto-learning
|
|
agent.enable_auto_learning(
|
|
threshold=0.3, # Learn when balance drops below 30%
|
|
max_course_cost=0.2 # Spend max 20% of balance on courses
|
|
)
|
|
|
|
Learning Analytics
|
|
------------------
|
|
|
|
Track Learning Progress
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
# Get learning statistics
|
|
stats = manager.get_learning_stats(agent)
|
|
|
|
print(f"Courses completed: {stats.completed_courses}")
|
|
print(f"Total learning hours: {stats.total_hours}")
|
|
print(f"Total skill gain: +{stats.total_skill_gain:.0%}")
|
|
print(f"Learning investment: ${stats.total_investment:.2f}")
|
|
print(f"ROI: {stats.roi:.2f}x")
|
|
|
|
Learning Recommendations
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
.. code-block:: python
|
|
|
|
# Get personalized recommendations
|
|
recommendations = manager.recommend_courses(agent)
|
|
|
|
print("Recommended courses:")
|
|
for rec in recommendations:
|
|
print(f" {rec.course.name}")
|
|
print(f" Expected benefit: {rec.expected_benefit:.2f}")
|
|
print(f" Priority: {rec.priority}")
|