United States/Tennessee
BlogApril 30, 2026

Jumping into AI: Training My First Trading Agent (and Surviving the Swim)

Doruk Kocausta
Jumping into AI: Training My First Trading Agent (and Surviving the Swim)
Alright, I’ll be honest—sometimes the fastest way to learn is to throw yourself into the deep end. When I was 5 or 6, my dad tossed me into the sea and just watched (don’t worry—definitely not a trauma 😂). That summer I learned to swim fast. Five years later, I was competing as a pro athlete. Now I know I can swim anywhere. So, what’s that got to do with programming? Recently, I spent three days learning how to train an AI agent with Ollama and Hugging Face on Google Colab—all in Python. As I wrote that sentence, it felt just like that first swim: jumping into the unknown and trusting I’ll make it to shore. I had NO idea how these technologies worked before. Until now, I was deep in the JavaScript/TypeScript world—building with Next.js, Nest.js, and React. But AI has always been my dream. So here I am, finally getting my hands dirty with model training. Spoiler: I’d been crafting this idea for over a month (this was no sudden 2-day inspiration). I spent weeks jotting down notes, sketching out what I’d need, thinking, and re-thinking. Eventually, things started to snap together. If you’re ready, join me for the (turbulent) flight.
Back in college at Pamukkale University in Denizli/Turkey, my senior project was a cybersecurity tool in Python. I was always drawn to LLMs and machine learning—curious how they worked and wanted to dig in—but cybersecurity kept calling. Then I came to the U.S... and now, finally, I’ve trained my first AI agent. Honestly, finding information today is almost too easy—Google, AI assistants, forums. But the real challenge is designing a system and a roadmap: figuring out how to connect all the dots and make an idea reality. I’ve always been fascinated by trading—especially forex and crypto. (Stocks? Honestly, not my vibe. They feel a bit too manipulated for my taste.) So I knew I wanted to train an AI model for trading. Python was the clear choice:
  • I wanted to level up my backend skills, not just JS/TS frameworks.
  • Plus, I always enjoyed building in Python when I worked in cybersecurity.
And wouldn’t you know—the universe nudged me again. My next job interview included “Python backend programming” as a requirement. So, what do I know? What can I build?
  • I know I can make frontends with Next.js and deploy to Vercel. Easy.
  • I’m comfortable enough in Python to handle the project.
  • But let’s be honest: nobody knows everything on their first try! I remind myself—it’s fine not to know (yet). I’ll figure it out.
Databases? PostgreSQL: check.
Connecting deployed services? Done that.
Biggest advantage: AI assistance is now at everyone’s fingertips—no more scratching through random forums for every bug.
Here’s how I broke it down, step by step:
Goal: Fetch global market data and prep it for an AI agent. This backend is minimal by design—it fetches market data (like OHLCV from TradingView), transforms it, and exposes endpoints for the AI agent to consume. Super for practicing backend development in Python. MVP is ready and waiting for an agent to connect!
Goal: Pretrain and fine-tune an AI trading agent.
  • Tech Stack: Hugging Face, Google Colab, Python, Ollama, Unsloth, LoRA, Jupyter Notebook
I dove head-first into Google Colab—a browser-based Jupyter Notebook environment with free (and paid) access to GPU servers, perfect for ML experimentation. Free tier was good but limiting, so I grabbed Colab Pro for $10/month. It gives you longer GPU usage and higher resource limits. You do have to save your data/models somewhere—so I used Hugging Face as my “GitHub of AI,” pushing trained models and grabbing datasets from their massive catalog. First, I started training manually, typing out dependencies and wrestling with package versions and CUDA errors for hours. (Colab is amazing for debugging—you run code in chunks, see instant outputs and errors, and adjust on the fly.) Frustrated, I hunted for better workflows. Enter Unsloth—a high-performance library for fine-tuning large language models (LLMs) like Llama2 and Mistral using LoRA (Low-Rank Adaptation) and quantization, which makes training much faster and resource-friendly even on modest GPUs. My first pick was Mistral Vision (a 3B parameter vision-language model), but I quickly realized it focuses on images—not what I needed for a trading agent (yet). Swapped to conversational models, specifically Llama 3.2B, suited for NLP and dialogue. Code-wise: I didn’t copy-paste. I wrote everything out, line by line, unless it was a known snippet—best way to cement the learning. Result:
My first tiny training dataset:
Json
{"messages": [
  {"role": "user", "content": "Hello"},
  {"role": "assistant", "content": "Hello user, I’m ready for trading data. Please send your OHLCV candles or trading question..."}
]}
{"messages": [
  {"role": "user", "content": "What can you do?"},
  {"role": "assistant", "content": "I am a finance and trading assistant. You can send me market data, news, or scenarios..."}
]}
It’s super basic, but it works! Now I can scale this up, push models to Hugging Face, and deploy when ready.
Goal: Track everything—conversations, analyses, sessions, user info.
  • Tech: PostgreSQL, SQLAlchemy or other Python ORMs, SQL queries.
Will power persistent data for chat logs, analysis results, and session tracking.
Not started yet—waiting for real agent output to shape the UI. Plans:
  • Tech: Next.js, React, TypeScript, Vercel
  • Features: Conversational UI, market/news widgets, analytics display
At MVP, only basic chat (no image or file inputs). I’ll expand once the data and model needs are clearer—could include news feeds (from TradingView or elsewhere), trading signals, educational content, etc.
(Pro tip: I’m also a sous chef, and honestly, the parallels between kitchen and code are wild.)
  • Frontend: The dining room, where users experience and interact.
  • Backend: The kitchen, prepping and serving up data (the “food”).
  • Servers: The “waitstaff”—they handle requests between frontend and backend.
  • Storage: Local storage is like a minibar; big industrial freezers? That’s your database.
See? Same principles—structure, flow, prepping components for seamless experiences.
Backend is running.
First data payload from TradingView API:
Json
{
  "symbol": "BINANCE:BTCUSDT",
  "timeframe": "D",
  "candles": [{ "timestamp": ..., "open": ..., "close": ..., "high": ..., "low": ..., "volume": ... }, ...]
}
Success! Data ready, MVP-ing as we speak. Next Steps:
  • Get deeper into AI model training & deployment (with Unsloth + LoRA).
  • Expand dataset and conversation quality.
  • Wire everything together—end-to-end.
  • Build a slick, user-friendly frontend, tightly integrated with the backend and the AI agent.
Three days ago, I’d barely heard of some of these tools—Colab, Hugging Face, LoRA, Ollama, Unsloth.
Now I’ve built the backend, started meaningful AI training, and have a working pipeline from trading data to AI agent inference.
  • Jupyter/Colab Notebooks: Essential for hands-on ML, stepwise coding, and iterative troubleshooting.
  • Hugging Face: Like GitHub for AI; model hosting and dataset streaming made dead simple.
  • Unsloth & LoRA: Make large-model training feasible—even without supercomputers.
The biggest lesson?
Don’t be afraid to dive in—even when you feel like you’re in over your head. Debug, refactor, iterate, and ask for help (Copilot and AI assistants are friends, not cheats).
I’m genuinely excited about this project, and about learning more every day—AI, backend, full stack, and beyond. I’ll share more updates as I go (and talk less next time, maybe 😉). Time to get back to training my model! If you’re working on something similar, or just want to trade data or AI wisdom, drop a comment or connect. Let’s keep swimming.
#python #ai #llm #tradingbot #huggingface #googlecolab #ollama #unsloth #machinelearning #finetuning #fastapi #postgresql #nextjs #backend #learningjourney #personalproject #coding #devblog #developer #fullstack #openai #jupyter #alpaca #lora #unstructuredlearning #projectlog
Share this post:
On this page