added new ft model

This commit is contained in:
Yasha Sheynin
2025-02-02 21:54:32 -05:00
parent 5dcab576c3
commit 7b1f8c6d9a
5 changed files with 451 additions and 1885 deletions
+151 -2
View File
@@ -63,14 +63,143 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"Processing: 58%|████████████████▉ | 142/244 [10:00<18:10, 10.69s/it]"
"Processing: 100%|█████████████████████████████| 244/244 [16:34<00:00, 4.08s/it]"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Debug Counts:\n",
"Initial DataFrame rows: 244\n",
"Skipped: No next VWAP for timestamp 2025-01-31 16:00:00+00:00\n",
"\n",
"Processing Summary:\n",
"Total rows initially: 244\n",
"Valid predictions: 243\n",
"Skipped timestamps: 1\n",
"Final predictions count: 243\n",
"\n",
"\n",
"Class distributions:\n",
"Actual: {'down': 171, 'up': 72}\n",
"Predicted: {'down': 164, 'up': 79}\n",
"\n",
"Confusion Matrix:\n",
" Pred Down Pred Up\n",
"True Down 137 34\n",
"True Up 27 45\n",
"\n",
"Performance Report:\n",
"\n",
"Performance Report\n",
"=================\n",
"Total Predictions: 243\n",
"Accuracy: 74.90%\n",
"Precision: 56.96%\n",
"Recall: 62.50%\n",
"F1 Score: 59.60%\n",
"\n",
"Direction Distribution:\n",
"-------------------\n",
"Up: 79\n",
"Down: 164\n",
"\n",
"Confidence Analysis:\n",
"-----------------\n",
"Average Confidence: 80.08%\n",
"High Confidence Accuracy: 74.90%\n",
"\n",
"Trading Metrics:\n",
"--------------\n",
"Avg Expected VWAP Change: 0.12%\n",
"Avg Volatility Estimate: 198.74%\n",
"\n",
"Price Target Analysis:\n",
"-------------------\n",
"Entry Success Rate: 74.90%\n",
"Stop Loss Hits: 9.05%\n",
"Take Profit Hits: 9.47%\n",
"Avg Risk/Reward Ratio: 1.02\n",
"\n",
"Top Signals:\n",
"----------\n",
"Decreasing volume trend: 151\n",
"Price below VWAP: 127\n",
"Increasing volume suggests strong momentum.: 69\n",
"Price above VWAP supports bullish momentum.: 68\n",
"Decreasing volume suggests potential trend weakness.: 16\n",
"\n",
"Time Coverage:\n",
"-----------\n",
"Start: 2025-01-28 15:30:00+00:00\n",
"End: 2025-01-31 15:55:00+00:00\n",
"\n",
"\n",
"Predictions Summary:\n",
" vwap_direction_next_5min confidence_score expected_vwap_change \\\n",
"0 down 0.8 0.000000 \n",
"1 up 0.8 0.000433 \n",
"2 up 0.8 0.045066 \n",
"3 down 0.8 0.000000 \n",
"4 down 0.8 0.000000 \n",
"\n",
" volatility_estimate suggested_entry suggested_stop_loss \\\n",
"0 0.000000 102547.785632 102849.709244 \n",
"1 0.102457 102830.485685 102778.485685 \n",
"2 10.792993 103057.394632 102757.894632 \n",
"3 7.125226 103057.394967 103357.394967 \n",
"4 6.469257 103057.394968 103357.394968 \n",
"\n",
" suggested_take_profit key_signals \\\n",
"0 102245.862020 [Decreasing volume trend, VWAP below price] \n",
"1 102882.485685 [Increasing volume suggests strong momentum., ... \n",
"2 103356.894632 [Increasing volume suggests strong momentum., ... \n",
"3 102757.394967 [Decreasing volume trend, Price below VWAP] \n",
"4 102757.394968 [Decreasing volume trend, Price below VWAP, MA... \n",
"\n",
" reasoning \\\n",
"0 The decreasing volume trend suggests potential... \n",
"1 The increasing volume indicates strong momentu... \n",
"2 The significant increase in volume indicates s... \n",
"3 The decreasing volume trend suggests potential... \n",
"4 The decreasing volume trend suggests potential... \n",
"\n",
" timestamp_prediction historical_start \\\n",
"0 2025-01-28 15:30:00+00:00 2025-01-28 09:30:00+00:00 \n",
"1 2025-01-28 15:35:00+00:00 2025-01-28 09:35:00+00:00 \n",
"2 2025-01-28 15:40:00+00:00 2025-01-28 09:40:00+00:00 \n",
"3 2025-01-28 15:45:00+00:00 2025-01-28 09:45:00+00:00 \n",
"4 2025-01-28 15:50:00+00:00 2025-01-28 09:50:00+00:00 \n",
"\n",
" historical_end current_window_start \\\n",
"0 2025-01-28 14:25:00+00:00 2025-01-28 14:30:00+00:00 \n",
"1 2025-01-28 14:30:00+00:00 2025-01-28 14:35:00+00:00 \n",
"2 2025-01-28 14:35:00+00:00 2025-01-28 14:40:00+00:00 \n",
"3 2025-01-28 14:40:00+00:00 2025-01-28 14:45:00+00:00 \n",
"4 2025-01-28 14:45:00+00:00 2025-01-28 14:50:00+00:00 \n",
"\n",
" current_window_end prediction_timestamp actual_movement \n",
"0 2025-01-28 15:25:00+00:00 2025-01-28 15:30:00+00:00 up \n",
"1 2025-01-28 15:30:00+00:00 2025-01-28 15:35:00+00:00 down \n",
"2 2025-01-28 15:35:00+00:00 2025-01-28 15:40:00+00:00 down \n",
"3 2025-01-28 15:40:00+00:00 2025-01-28 15:45:00+00:00 down \n",
"4 2025-01-28 15:45:00+00:00 2025-01-28 15:50:00+00:00 down \n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"\n"
]
}
],
@@ -136,6 +265,26 @@
" print(f\"Analysis failed: {str(e)}\")"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"SyncCursorPage[FineTuningJob](data=[FineTuningJob(id='ftjob-hggoauCsSRZHZkQyPoPRn05W', created_at=1738549484, error=Error(code=None, message=None, param=None), fine_tuned_model='ft:gpt-4o-mini-2024-07-18:yasha-sheynin::AwgWhL48', finished_at=1738549856, hyperparameters=Hyperparameters(batch_size=1, learning_rate_multiplier=1.8, n_epochs=3), model='gpt-4o-mini-2024-07-18', object='fine_tuning.job', organization_id='org-EfEdakLI3PxeXpcffWaFxdol', result_files=['file-Cr1t8xFGTdjpjQCXBGqE5L'], seed=288523345, status='succeeded', trained_tokens=58239, training_file='file-WwWvai4rxePmvifhN2KVmz', validation_file=None, estimated_finish=None, integrations=[], method=Method(dpo=None, supervised=MethodSupervised(hyperparameters=MethodSupervisedHyperparameters(batch_size=1, learning_rate_multiplier=1.8, n_epochs=3)), type='supervised'), user_provided_suffix=None), FineTuningJob(id='ftjob-PS4EXlVz5SdInps2MU4f64B2', created_at=1738549280, error=Error(code='invalid_n_examples', message='Training file has 4 example(s), but must have at least 10 examples', param='training_file'), fine_tuned_model=None, finished_at=None, hyperparameters=Hyperparameters(batch_size='auto', learning_rate_multiplier='auto', n_epochs=3), model='gpt-4o-mini-2024-07-18', object='fine_tuning.job', organization_id='org-EfEdakLI3PxeXpcffWaFxdol', result_files=[], seed=912538967, status='failed', trained_tokens=None, training_file='file-2YxyNCNuFnLeoyCsmwRFh4', validation_file=None, estimated_finish=None, integrations=[], method=Method(dpo=None, supervised=MethodSupervised(hyperparameters=MethodSupervisedHyperparameters(batch_size='auto', learning_rate_multiplier='auto', n_epochs=3)), type='supervised'), user_provided_suffix=None), FineTuningJob(id='ftjob-CdU86w4P5d5sAIeW2exVJJPo', created_at=1738524908, error=Error(code=None, message=None, param=None), fine_tuned_model='ft:gpt-4o-mini-2024-07-18:yasha-sheynin::Awacdfg6', finished_at=1738527160, hyperparameters=Hyperparameters(batch_size=3, learning_rate_multiplier=1.8, n_epochs=3), model='gpt-4o-mini-2024-07-18', object='fine_tuning.job', organization_id='org-EfEdakLI3PxeXpcffWaFxdol', result_files=['file-6DUBwAYAsFk94P8Qe8n8nL'], seed=223641031, status='succeeded', trained_tokens=1320606, training_file='file-BNa5KfcVuuSY9HmbwwXoWb', validation_file=None, estimated_finish=None, integrations=[], method=Method(dpo=None, supervised=MethodSupervised(hyperparameters=MethodSupervisedHyperparameters(batch_size=3, learning_rate_multiplier=1.8, n_epochs=3)), type='supervised'), user_provided_suffix=None)], object='list', has_more=False)\n"
]
}
],
"source": [
"from market_predictor.config import OPENAI_API_KEY\n",
"from openai import OpenAI\n",
"client = OpenAI(api_key = OPENAI_API_KEY)\n",
"print(client.fine_tuning.jobs.list(limit=10))\n"
]
},
{
"cell_type": "code",
"execution_count": null,