Skip to content

Commit 4b4306e

Browse files
committed
new
1 parent 981d4ec commit 4b4306e

File tree

7 files changed

+132
-26
lines changed

7 files changed

+132
-26
lines changed

setup.py

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""
2+
🌙 Moon Dev Trading System Setup
3+
"""
4+
5+
from setuptools import setup, find_packages
6+
7+
setup(
8+
name="moon-dev-trading",
9+
version="0.1.0",
10+
packages=find_packages(),
11+
install_requires=[
12+
"anthropic",
13+
"pandas",
14+
"termcolor",
15+
"requests",
16+
"pandas_ta",
17+
"schedule",
18+
"python-dotenv"
19+
]
20+
)

src/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
"""
2+
🌙 Moon Dev Trading System
3+
"""

src/agents/trading_agent.py

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
🌙 Moon Dev's AI Trading Agent
3+
Built with love by Moon Dev 🚀
4+
"""
5+
6+
import anthropic
7+
from src.core.config import *
8+
from src.data.ohlcv_collector import collect_all_tokens
9+
import os
10+
from termcolor import colored, cprint
11+
from dotenv import load_dotenv
12+
13+
# Load environment variables
14+
load_dotenv()
15+
16+
class TradingAgent:
17+
def __init__(self):
18+
"""Initialize the AI Trading Agent with Moon Dev's magic ✨"""
19+
api_key = os.getenv("ANTHROPIC_KEY")
20+
if not api_key:
21+
raise ValueError("🚨 ANTHROPIC_KEY not found in environment variables!")
22+
23+
self.client = anthropic.Anthropic(api_key=api_key)
24+
print("🤖 Moon Dev's AI Trading Agent initialized!")
25+
26+
def analyze_market_data(self, market_data):
27+
"""Analyze market data using Claude"""
28+
try:
29+
message = self.client.messages.create(
30+
model=AI_MODEL,
31+
max_tokens=AI_MAX_TOKENS,
32+
temperature=AI_TEMPERATURE,
33+
messages=[
34+
{
35+
"role": "user",
36+
"content": f"Analyze this market data and provide trading insights: {market_data}"
37+
}
38+
]
39+
)
40+
print("🎯 Moon Dev's AI Analysis Complete!")
41+
return message.content
42+
43+
except Exception as e:
44+
print(f"❌ Error in AI analysis: {str(e)}")
45+
return None
46+
47+
def main():
48+
"""Main function to run the trading agent"""
49+
print("🌙 Moon Dev AI Trading System Starting Up! 🚀")
50+
51+
try:
52+
# Collect OHLCV data for all tokens
53+
print("📊 Collecting market data...")
54+
market_data = collect_all_tokens()
55+
56+
# Initialize AI agent
57+
agent = TradingAgent()
58+
59+
# Analyze each token's data
60+
for token, data in market_data.items():
61+
print(f"\n🔍 Analyzing {token[-4:]}...")
62+
analysis = agent.analyze_market_data(data.to_dict())
63+
print(f"\n📈 Analysis for {token[-4:]}:")
64+
print(analysis)
65+
66+
except KeyboardInterrupt:
67+
print("\n👋 Moon Dev AI Agent shutting down gracefully...")
68+
except Exception as e:
69+
print(f"❌ Error: {str(e)}")
70+
print("🔧 Moon Dev suggests checking the logs and trying again!")
71+
72+
if __name__ == "__main__":
73+
main()

src/core/config.py

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,23 @@
3232
DAYSBACK_4_DATA = 10
3333
DATA_TIMEFRAME = '15m'
3434

35+
# AI Model Settings 🤖
36+
AI_MODEL = "claude-3-sonnet-20240229" # Claude model to use
37+
AI_MAX_TOKENS = 1024 # Max tokens for response
38+
AI_TEMPERATURE = 0.7 # Creativity vs precision (0-1)
39+
40+
# Token List for Trading 📋
41+
tokens_to_trade = [
42+
'9BB6NFEcjBCtnNLFko2FqVQBq8HHM13kCyYcdQbgpump', # Example token
43+
# Add more tokens here
44+
]
45+
3546
# Future variables (not active yet) 🔮
3647
sell_at_multiple = 3
3748
USDC_SIZE = 1
3849
limit = 49
3950
timeframe = '15m'
4051
stop_loss_perctentage = -.24
41-
tokens_to_trade = ['777']
4252
EXIT_ALL_POSITIONS = False
4353
DO_NOT_TRADE_LIST = ['777']
4454
CLOSED_POSITIONS_TXT = '777'

src/core/utils/nice_funcs.py

+16-12
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Built with love by Moon Dev 🚀
44
"""
55

6-
from ..config import *
6+
from src.core.config import *
77
import requests
88
import pandas as pd
99
import pprint
@@ -18,11 +18,15 @@
1818
from datetime import datetime, timedelta
1919
from termcolor import colored, cprint
2020
import solders
21-
import os
22-
import dontshare as d
21+
from dotenv import load_dotenv
22+
23+
# Load environment variables
24+
load_dotenv()
2325

24-
# API Key from your 'dontshare' file
25-
API_KEY = d.birdeye
26+
# Get API keys from environment
27+
API_KEY = os.getenv("BIRDEYE_API_KEY")
28+
if not API_KEY:
29+
raise ValueError("🚨 BIRDEYE_API_KEY not found in environment variables!")
2630

2731
sample_address = "2yXTyarttn2pTZ6cwt4DqmrRuBw1G7pmFv9oT6MStdKP"
2832

@@ -209,7 +213,6 @@ def token_creation_info(address):
209213
print("Failed to retrieve token creation info:", response.status_code)
210214

211215
def market_buy(token, amount, slippage):
212-
213216
import requests
214217
import sys
215218
import json
@@ -218,16 +221,18 @@ def market_buy(token, amount, slippage):
218221
from solders.transaction import VersionedTransaction
219222
from solana.rpc.api import Client
220223
from solana.rpc.types import TxOpts
221-
import dontshare as d
222224

223-
KEY = Keypair.from_base58_string(d.sol_key)
225+
KEY = Keypair.from_base58_string(os.getenv("SOLANA_PRIVATE_KEY"))
226+
if not KEY:
227+
raise ValueError("🚨 SOLANA_PRIVATE_KEY not found in environment variables!")
228+
224229
SLIPPAGE = slippage # 5000 is 50%, 500 is 5% and 50 is .5%
225230

226-
#QUOTE_TOKEN = "So11111111111111111111111111111111111111112"
227231
QUOTE_TOKEN = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v" # usdc
228232

229-
#http_client = Client("https://api.mainnet-beta.solana.com")
230-
http_client = Client(d.rpc_url)
233+
http_client = Client(os.getenv("RPC_ENDPOINT"))
234+
if not http_client:
235+
raise ValueError("🚨 RPC_ENDPOINT not found in environment variables!")
231236

232237
quote = requests.get(f'https://quote-api.jup.ag/v6/quote?inputMint={QUOTE_TOKEN}&outputMint={token}&amount={amount}&slippageBps={SLIPPAGE}').json()
233238
#print(quote)
@@ -595,7 +600,6 @@ def pnl_close(token_mint_address):
595600
time.sleep(1)
596601
market_sell(token_mint_address, sell_size)
597602
cprint(f'just made an order {token_mint_address[-4:]} selling {sell_size} ...', 'white', 'on_blue')
598-
time.sleep(1)
599603
time.sleep(15)
600604

601605
except:

src/data/ohlcv_collector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
Built with love by Moon Dev 🚀
55
"""
66

7-
from ..core.config import *
8-
from ..core.utils.nice_funcs import get_data
7+
from src.core.config import *
8+
from src.core.utils import nice_funcs as n
99
import pandas as pd
1010
from datetime import datetime
1111
import os
@@ -15,7 +15,7 @@ def collect_token_data(token_address, days_back=DAYSBACK_4_DATA, timeframe=DATA_
1515
"""Collect OHLCV data for a specific token"""
1616
try:
1717
print(f"🔍 Moon Dev is fetching data for {token_address[-4:]} over {days_back} days...")
18-
df = get_data(token_address, days_back, timeframe)
18+
df = n.get_data(token_address, days_back, timeframe)
1919

2020
if df is not None and not df.empty:
2121
# Save to CSV with timestamp

src/main.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,16 @@
44
Built with love by Moon Dev 🚀
55
"""
66

7-
from core.bot import bot
8-
import time
7+
from src.agents.trading_agent import main as run_agent
98

10-
def main():
11-
print("🌙 Moon Dev AI Trading System Starting Up! 🚀")
12-
print("💫 Remember: Moon Dev says trade safe and smart! 💫")
9+
if __name__ == "__main__":
10+
print("🚀 Starting Moon Dev's AI Trading System...")
11+
print("💫 Remember: Moon Dev says trade safe and smart!")
1312

1413
try:
15-
bot()
14+
run_agent()
1615
except KeyboardInterrupt:
17-
print("\n🌙 Moon Dev AI Trading System shutting down gracefully... 👋")
16+
print("\n👋 Moon Dev AI Trading System shutting down gracefully...")
1817
except Exception as e:
1918
print(f"❌ Error occurred: {str(e)}")
2019
print("🔧 Moon Dev suggests checking the logs and trying again!")
21-
22-
if __name__ == "__main__":
23-
main()

0 commit comments

Comments
 (0)