File size: 3,930 Bytes
5092160
 
 
9caf6ec
 
 
 
 
 
 
 
 
 
 
 
5092160
 
9caf6ec
5092160
 
 
9caf6ec
 
5092160
9caf6ec
 
5092160
9caf6ec
5092160
 
 
 
 
9caf6ec
 
 
5092160
9caf6ec
5092160
 
 
 
 
 
9caf6ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5092160
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
---
base_model: unsloth/Qwen3-0.6B
library_name: peft
license: mit
datasets:
- atahanuz/stock_prediction
language:
- en
pipeline_tag: text-generation
tags:
- finance
- sft
- trl
- unsloth
- transformers
---

# Model Card for StockDirection-6K

## Model Details

StockDirection is a fine-tuned language model for binary stock movement prediction.
The model is trained to predict whether the next day’s stock price of Akbank (AKBNK), traded on Borsa Istanbul (BIST), will move UP or DOWN, based on the daily percentage changes from the last four days and the current day.

- Input: A formatted prompt describing the last 5 days of daily percentage price changes.
- Output: A simple categorical prediction — "UP" or "DOWN".

This model was fine-tuned on a dataset of 6,300 labeled rows of AKBNK stock data.

## Uses

### Direct Use

- Educational purposes: Demonstrating how LLMs can be fine-tuned for financial classification tasks.
- Research: Exploring text-based sequence learning for stock direction prediction.
- Proof of concept: Serving as an example for stock price direction prediction using natural language prompts.

⚠️ Not for financial advice or live trading decisions.


## How to Get Started with the Model

Use the code below to get started with the model.

```python
from transformers import AutoTokenizer, AutoModelForCausalLM
from peft import PeftModel



tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen3-0.6B",)
base_model = AutoModelForCausalLM.from_pretrained(
    "unsloth/Qwen3-0.6B",
    device_map={"": 0}
)

model = PeftModel.from_pretrained(base_model,"khazarai/StockDirection-6K")


question ="""
You are an assistant that predicts whatever a stock will go up or down in the next day based on the daily percentage price changes of the last:
4 days ago: 0.00
3 days ago: -3.09
2 days ago: 2.13
1 day ago: -2.04
today: 0.01
Predict whatever the next day's price will go up or down. Simply write your prediction as UP or DOWN
"""

messages = [
    {"role" : "user", "content" : question}
]
text = tokenizer.apply_chat_template(
    messages,
    tokenize = False,
    add_generation_prompt = True, 
    enable_thinking = False, 
)

from transformers import TextStreamer
_ = model.generate(
    **tokenizer(text, return_tensors = "pt").to("cuda"),
    max_new_tokens = 200,
    temperature = 0.7, 
    top_p = 0.8, 
    top_k = 20,
    streamer = TextStreamer(tokenizer, skip_prompt = True),
)
```
**For pipeline:** 

```python
from transformers import pipeline, AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel

tokenizer = AutoTokenizer.from_pretrained("unsloth/Qwen3-0.6B")
base_model = AutoModelForCausalLM.from_pretrained("unsloth/Qwen3-0.6B")
model = PeftModel.from_pretrained(base_model, "khazarai/StockDirection-6K")

question ="""
You are an assistant that predicts whatever a stock will go up or down in the next day based on the daily percentage price changes of the last:
4 days ago: 0.00
3 days ago: -3.09
2 days ago: 2.13
1 day ago: -2.04
today: 0.01
Predict whatever the next day's price will go up or down. Simply write your prediction as UP or DOWN
"""

pipe = pipeline("text-generation", model=model, tokenizer=tokenizer)
messages = [
    {"role": "user", "content": question}
]
pipe(messages)

```

## Training Data

- Dataset: [atahanuz/stock_prediction](https://huggingface.co/datasets/atahanuz/stock_prediction)
- Size: 6,355 labeled examples.
- Structure: Each sample contains past 5 daily percentage changes and the target label (UP/DOWN).

Example:

```vbnet
Question: You are an assistant that predicts whether a stock will go up or down in the next day 
based on the daily percentage price changes of the last:
4 days ago: nan
3 days ago: 0.00
2 days ago: 2.22
1 day ago: -2.17
today: -2.22
Predict whether the next day's price will go up or down. 
Simply write your prediction as UP or DOWN.

Answer: DOWN
```


### Framework versions

- PEFT 0.15.2