Gemma-3-4B Market Analyst β€” LoRA Adapter

A LoRA fine-tune of google/gemma-3-4b-it trained by Ramailo Technologies to perform structured financial market analysis across crypto, stocks, forex, and commodities.

The model reads raw OHLCV candle data, technical indicators, options flow, and sentiment signals, then produces condition-based market analysis β€” without giving hard price targets.


What it does

Given structured market data (candles, RSI, MACD, Bollinger Bands, EMA stack, funding rates, put/call ratios, open interest, volume ratios), the model produces analysis across 7 task types:

Task Description
setup_evaluation Evaluates whether a trade setup is valid or a trap
technical_analysis Full multi-timeframe technical read with directional bias
risk_reading Identifies risk signals from volume, options flow, and price action
market_regime Classifies current market regime (trending, ranging, distribution, etc.)
asset_comparison Compares two assets and identifies relative strength
concept_explain Explains a market concept grounded in the current data
api_parse Parses and interprets raw options/derivatives API output

Supported asset classes: crypto, stocks, forex, commodities


How to use

from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel
import torch

base_model_id = "google/gemma-3-4b-it"
adapter_id    = "Ramailo-Technologies/gemma3-4b-market-analyst"

tokenizer = AutoTokenizer.from_pretrained(base_model_id)

base = AutoModelForCausalLM.from_pretrained(
    base_model_id,
    torch_dtype=torch.bfloat16,
    device_map="auto",
)
model = PeftModel.from_pretrained(base, adapter_id)
model.eval()

messages = [
    {
        "role": "system",
        "content": "You are an expert market analyst. Analyse the provided market data and give a structured, condition-based assessment. Never give hard price targets. Always state what would change your bias."
    },
    {
        "role": "user",
        "content": "Market data:\n<your JSON market data here>\n\nIs this a valid long setup or a trap?"
    }
]

inputs = tokenizer.apply_chat_template(
    messages, return_tensors="pt", add_generation_prompt=True
).to(model.device)

with torch.no_grad():
    output = model.generate(inputs, max_new_tokens=512, do_sample=False)

response = tokenizer.decode(output[0][inputs.shape[-1]:], skip_special_tokens=True)
print(response)

Training data examples

Example 1 β€” Setup Evaluation (BNB/USDT, 5m)

User prompt (abbreviated):

{
  "exchange": "binance",
  "symbol": "BNB/USDT",
  "timeframe": "5m",
  "indicators": {
    "rsi": 30,
    "bollinger_lower": 2684.93,
    "funding_rate": -0.0469,
    "long_short_ratio": 2.09,
    "price": 2635.74
  }
}

Is this a valid long setup or a falling knife?

Model response:

This is a textbook 'falling knife' scenario. While the price of 2635.74 is
aggressively oversold β€” sitting well below the lower Bollinger Band (2684.93)
and hitting an RSI of 30 β€” the sentiment data suggests a dangerous trap.
The Long/Short ratio of 2.09 is the critical signal here; it indicates that
retail traders are heavily positioned for a bounce. In a downtrend, a high
L/S ratio provides the exact liquidity needed for further declines via long
liquidations. The negative funding rate (-0.0469) confirms that shorts are
paying longs, which often precedes a bounce β€” but not when the long-side is
this overcrowded.

Bias change condition: A valid long setup would require the L/S ratio to drop
below 1.2 and price to reclaim the lower Bollinger Band (2684.93) on a
closing basis.

Example 2 β€” Risk Reading (NFLX, 15m)

User prompt (abbreviated):

{
  "exchange": "nasdaq",
  "symbol": "NFLX",
  "timeframe": "15m",
  "indicators": {
    "volume_ratio": 3.67,
    "put_call_ratio": 1.5,
    "ema_20": 688.22,
    "price": 669.81
  }
}

What does the volume spike tell us?

Model response:

The spike in volume ratio to 3.67 while price remains stagnant at 669.81 is
a classic signal of 'churning' or distribution. When volume surges but price
fails to move, it indicates a massive battle between buyers and sellers where
supply is exactly meeting demand. The Put/Call ratio of 1.5 is the deciding
factor β€” it reveals that the volume spike is driven largely by bearish bets
and hedging. NFLX is in a precarious position, trading below its EMA_20
(688.22).

Bias change condition: Bias turns neutral if price closes above EMA_20
(688.22) with a volume ratio below 2.0, signalling distribution pressure
is exhausting.

Evaluation

Evaluated on 84 held-out samples across all task types and asset classes. GPT-4o was used as judge, scoring each response 1–5 on five criteria.

Overall β€” before vs after fine-tuning

Metric Base model Fine-tuned Delta
Factual grounding 3.08 4.07 +0.99
No price targets 4.83 4.96 +0.13
Directional clarity 3.10 4.37 +1.27
Bias change condition 1.73 4.40 +2.68
Hallucination penalty 4.39 4.61 +0.21
Overall 3.43 4.48 +1.06

The biggest gain is bias change condition (+2.68) β€” the base model almost never stated what would change its view. The fine-tuned model does this consistently on every response.

By task type

Task Before After Delta
api_parse 3.25 4.73 +1.48
market_regime 3.73 4.68 +0.95
risk_reading 3.33 4.55 +1.22
setup_evaluation 3.62 4.42 +0.80
concept_explain 3.43 4.42 +0.98
technical_analysis 3.43 4.35 +0.92
asset_comparison 3.18 4.23 +1.05

By asset class

Asset class Before After Delta
Crypto 3.38 4.70 +1.32
Forex 3.29 4.45 +1.16
Commodities 3.58 4.43 +0.85
Stocks 3.46 4.35 +0.90

Before vs after β€” response comparison

NFLX β€” Asset Comparison (overall delta: +2.2)

Base model (score: 2.8/5)

Okay, let's break down this NFLX data and assess whether this presents a
genuine short setup or a potential "fake-out."

1. Immediate Price Action & Volatility:
- Range: The stock has traded between 241.21 and 264.48.
- Volatility: The ATR of 4.15 indicates moderate volatility.
[Generic bullets with no directional conviction and no bias change condition]

Fine-tuned model (score: 5.0/5)

This is a valid short setup, not a fake-out. The conflict between the
put/call ratio (0.44) and the RSI (67.3) is a classic divergence. A put/call
ratio of 0.44 indicates extreme bullish sentiment, while the RSI of 67.3
shows the asset is overbought. When the options market is this aggressively
bullish while price is consolidating and the MACD histogram is negative
(-5.988), it suggests that 'smart money' is positioning for a reversal.
Price is trading below all major EMAs: EMA_20 (259.78), EMA_50 (277.25).

Bias change condition: Short bias invalidated if price closes above EMA_20
(259.78) with a put/call ratio rising above 0.6.

META β€” API Parse (overall delta: +2.2)

Base model (score: 2.2/5)

Based on the provided data, the options flow indicates "mixed" unusual
activity. The put-call ratio is 0.71, suggesting a slight preference for
puts. A cautious approach is advised...
[No specific data references, no bias change condition stated]

Fine-tuned model (score: 4.4/5)

I cannot provide a directional call on the 1H chart because the data is
contradictory. The Put/Call ratio is 0.71 (bullish), yet the IV Rank is
extremely high at 86.6. An IV Rank this high indicates the market expects a
massive volatility move, but the Put/Call ratio suggests no conviction in a
specific direction.

Bias change condition: A directional call becomes possible if IV Rank drops
below 60 while the Put/Call ratio holds above 0.8, or if a clear break
occurs above/below the consolidation range with a volume ratio above 2.0.

Training details

Parameter Value
Base model google/gemma-3-4b-it
Method QLoRA (4-bit NF4) + SFT
Training samples 2,269
LoRA rank 16
LoRA alpha 32
Target modules q_proj, v_proj, k_proj, o_proj, gate_proj, up_proj, down_proj
Trainable parameters 32,788,480 (0.76%)
Epochs 3
Effective batch size 16 (2 Γ— 8 grad accum)
Learning rate 2e-4 (cosine, 5% warmup)
Precision bf16
Hardware AWS ml.g5.2xlarge (NVIDIA A10G 24 GB)
Framework transformers + trl + peft 0.19.1

Limitations

  • Trained primarily on crypto data β€” crypto task scores are highest (+1.32 delta). Stock/forex/commodities performance, while improved, may be less consistent on edge cases.
  • The model analyses data it is given β€” it has no live market access.
  • Not financial advice. All outputs are for research and educational purposes only.
  • Performance depends on the quality and completeness of the market data JSON provided as input.

Developed by

Ramailo Technologies

Downloads last month
6
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Model tree for Ramailo-Technologies/gemma3-4b-market-analyst

Adapter
(468)
this model