550 lines
31 KiB
Plaintext
550 lines
31 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Rolling Window Market Movement Analysis\n",
|
|
"\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"Fetched 316 rows of data.\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import sys\n",
|
|
"sys.path.append('../')\n",
|
|
"import asyncio\n",
|
|
"import pandas as pd\n",
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import seaborn as sns\n",
|
|
"from datetime import datetime, timedelta\n",
|
|
"from IPython.display import display\n",
|
|
"from tqdm.notebook import tqdm\n",
|
|
"\n",
|
|
"from market_predictor.market_data_fetcher import MarketDataFetcher\n",
|
|
"from market_predictor.data_processor import MarketDataProcessor\n",
|
|
"from market_predictor.rag_engine import RAGEngine\n",
|
|
"from market_predictor.performance_metrics import PerformanceMetrics\n",
|
|
"from market_predictor.prediction_service import PredictionService\n",
|
|
"\n",
|
|
"\n",
|
|
"symbol = \"BTC-USD\"\n",
|
|
"end_date = datetime.now()\n",
|
|
"start_date = end_date - timedelta(days=5)\n",
|
|
"fetcher = MarketDataFetcher(symbol)\n",
|
|
"market_data = fetcher.fetch_data(\n",
|
|
" start_date=start_date.strftime('%Y-%m-%d'),\n",
|
|
" end_date=end_date.strftime('%Y-%m-%d'),\n",
|
|
" interval='5m'\n",
|
|
")\n",
|
|
"print(f\"Fetched {len(market_data)} rows of data.\")\n",
|
|
"\n",
|
|
"rag_engine = RAGEngine()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"### Define Rolling Window Prediction Functions"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"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"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"import asyncio\n",
|
|
"import pandas as pd\n",
|
|
"from tqdm import tqdm\n",
|
|
"import nest_asyncio\n",
|
|
"\n",
|
|
"# Enable nested event loops\n",
|
|
"nest_asyncio.apply()\n",
|
|
"\n",
|
|
"async def analyze_market_data(\n",
|
|
" market_data: pd.DataFrame,\n",
|
|
" training_window_size: int = 36,\n",
|
|
" inference_window_size: int = 12,\n",
|
|
" inference_offset: int = 0\n",
|
|
") -> pd.DataFrame:\n",
|
|
" processor = MarketDataProcessor(market_data)\n",
|
|
" processed_data = processor.df\n",
|
|
" \n",
|
|
" service = PredictionService(\n",
|
|
" market_data=processed_data,\n",
|
|
" training_window_size=training_window_size,\n",
|
|
" inference_window_size=inference_window_size,\n",
|
|
" inference_offset=inference_offset\n",
|
|
" )\n",
|
|
" \n",
|
|
" total_size = training_window_size + inference_offset + inference_window_size\n",
|
|
" total_windows = len(processed_data) - total_size\n",
|
|
" \n",
|
|
" predictions = []\n",
|
|
" with tqdm(total=total_windows, desc=\"Processing\", ncols=80) as pbar:\n",
|
|
" async for pred in service.generate_rolling_predictions():\n",
|
|
" if pred:\n",
|
|
" # print(pred)\n",
|
|
" predictions.append(pred)\n",
|
|
" pbar.update(1)\n",
|
|
" \n",
|
|
" return pd.DataFrame(predictions) if predictions else pd.DataFrame()\n",
|
|
"\n",
|
|
"# Run analysis\n",
|
|
"try:\n",
|
|
" predictions_df = await analyze_market_data(\n",
|
|
" market_data,\n",
|
|
" training_window_size=60,\n",
|
|
" inference_window_size=12,\n",
|
|
" inference_offset=0\n",
|
|
" )\n",
|
|
" \n",
|
|
" if not predictions_df.empty:\n",
|
|
" metrics = PerformanceMetrics(predictions_df, market_data)\n",
|
|
" report = metrics.generate_report()\n",
|
|
" print(\"\\nPerformance Report:\")\n",
|
|
" print(report)\n",
|
|
" \n",
|
|
" print(\"\\nPredictions Summary:\")\n",
|
|
" print(predictions_df.head())\n",
|
|
" else:\n",
|
|
" print(\"No predictions generated\")\n",
|
|
" \n",
|
|
"except Exception as e:\n",
|
|
" print(f\"Analysis failed: {str(e)}\")"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 5,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"name": "stderr",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"INFO:httpx:HTTP Request: GET https://api.openai.com/v1/fine_tuning/jobs?limit=10 \"HTTP/1.1 200 OK\"\n"
|
|
]
|
|
},
|
|
{
|
|
"name": "stdout",
|
|
"output_type": "stream",
|
|
"text": [
|
|
"SyncCursorPage[FineTuningJob](data=[FineTuningJob(id='ftjob-wIUgfbwCoeUXBzBdb2jNqkMW', created_at=1738624595, error=Error(code='invalid_n_examples', message='Training file has 8 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=941448681, status='failed', trained_tokens=None, training_file='file-JFJ8pqwiCvNSbqhfEYsJfH', 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-wrfsXikgf6WDmBTsyP9bzWho', created_at=1738622626, 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=1006076083, status='failed', trained_tokens=None, training_file='file-VJKnjsMD4nT4p33yhnwiWU', 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-IqQ7CJ2kXCGl3vXtXIWbbSEV', created_at=1738621366, error=Error(code='invalid_n_examples', message='Training file has 3 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=553846108, status='failed', trained_tokens=None, training_file='file-3w9821tRBCAaQr274SzBNE', 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-mOw8bph9RRH9W6SNKpywklWy', created_at=1738575118, error=Error(code='invalid_training_file', message='The job failed due to an invalid training file. Unexpected file format, expected either prompt/completion pairs or chat messages.', 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=814473608, status='failed', trained_tokens=None, training_file='file-5ivaRBKXpFqY24CdSEiGoc', 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-obgdBUjJ9cIsxjeE7YZeu3EE', created_at=1738574894, error=Error(code='invalid_training_file', message='The job failed due to an invalid training file. Unexpected file format, expected either prompt/completion pairs or chat messages.', 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=1621977344, status='failed', trained_tokens=None, training_file='file-WMgYRKkUBSjdRrsLRtJUcT', 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-qDBemboNOg8rKWMvreUtKYqr', created_at=1738570690, error=Error(code='invalid_n_examples', message='Training file has 3 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=1950862311, status='failed', trained_tokens=None, training_file='file-J7NkngveduCT4ob3RGMoFX', 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-WxdpAXpuzwaOi0jitrQCH2hd', created_at=1738570510, error=Error(code='invalid_n_examples', message='Training file has 3 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=1531489607, status='failed', trained_tokens=None, training_file='file-34VoUAXgesMZ5Tipx8HDSh', 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-P35JtWmiBvijQSIi8fDmX3es', created_at=1738570109, error=Error(code='invalid_n_examples', message='Training file has 3 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=667822474, status='failed', trained_tokens=None, training_file='file-KyvSRkzxex4phv5UYZu2eK', 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-zInUs8778guYModhgpZyMM6j', created_at=1738570001, error=Error(code='invalid_n_examples', message='Training file has 3 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=1152709743, status='failed', trained_tokens=None, training_file='file-FHgehWp6fGjtqAv8uo2nZX', 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-1iRubnLEfXrTACm5xWObJk2U', created_at=1738568241, error=Error(code='invalid_n_examples', message='Training file has 2 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=242651269, status='failed', trained_tokens=None, training_file='file-V1y1qrdmrjapMLGUvwAayY', 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)], object='list', has_more=True)\n"
|
|
]
|
|
}
|
|
],
|
|
"source": [
|
|
"# filepath: rolling_window_analysis.ipynb\n",
|
|
"import sys\n",
|
|
"import os\n",
|
|
"sys.path.append(os.path.abspath(\"..\")) # Adjust the path as needed\n",
|
|
"\n",
|
|
"from market_predictor.config import OPENAI_API_KEY\n",
|
|
"\n",
|
|
"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": 2,
|
|
"metadata": {},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/html": [
|
|
"<div>\n",
|
|
"<style scoped>\n",
|
|
" .dataframe tbody tr th:only-of-type {\n",
|
|
" vertical-align: middle;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe tbody tr th {\n",
|
|
" vertical-align: top;\n",
|
|
" }\n",
|
|
"\n",
|
|
" .dataframe thead th {\n",
|
|
" text-align: right;\n",
|
|
" }\n",
|
|
"</style>\n",
|
|
"<table border=\"1\" class=\"dataframe\">\n",
|
|
" <thead>\n",
|
|
" <tr style=\"text-align: right;\">\n",
|
|
" <th></th>\n",
|
|
" <th>vwap_direction_next_5min</th>\n",
|
|
" <th>confidence_score</th>\n",
|
|
" <th>expected_vwap_change</th>\n",
|
|
" <th>volatility_estimate</th>\n",
|
|
" <th>suggested_entry</th>\n",
|
|
" <th>suggested_stop_loss</th>\n",
|
|
" <th>suggested_take_profit</th>\n",
|
|
" <th>key_signals</th>\n",
|
|
" <th>reasoning</th>\n",
|
|
" <th>timestamp_prediction</th>\n",
|
|
" <th>actual_vwap_change</th>\n",
|
|
" <th>actual_price_change</th>\n",
|
|
" <th>actual_volume</th>\n",
|
|
" <th>actual_return</th>\n",
|
|
" <th>actual_movement</th>\n",
|
|
" <th>prediction_correct</th>\n",
|
|
" <th>hour</th>\n",
|
|
" <th>day_of_week</th>\n",
|
|
" </tr>\n",
|
|
" </thead>\n",
|
|
" <tbody>\n",
|
|
" <tr>\n",
|
|
" <th>0</th>\n",
|
|
" <td>up</td>\n",
|
|
" <td>0.85</td>\n",
|
|
" <td>0.01</td>\n",
|
|
" <td>0.02</td>\n",
|
|
" <td>701.50</td>\n",
|
|
" <td>700.5</td>\n",
|
|
" <td>702.5</td>\n",
|
|
" <td>['Consistent upward VWAP movement', 'Price abo...</td>\n",
|
|
" <td>The current market window shows a consistent u...</td>\n",
|
|
" <td>2025-01-31 10:50:00-05:00</td>\n",
|
|
" <td>0.000048</td>\n",
|
|
" <td>0.000126</td>\n",
|
|
" <td>149963.0</td>\n",
|
|
" <td>0.000048</td>\n",
|
|
" <td>up</td>\n",
|
|
" <td>True</td>\n",
|
|
" <td>10</td>\n",
|
|
" <td>4</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>1</th>\n",
|
|
" <td>up</td>\n",
|
|
" <td>0.85</td>\n",
|
|
" <td>0.01</td>\n",
|
|
" <td>0.02</td>\n",
|
|
" <td>699.50</td>\n",
|
|
" <td>698.5</td>\n",
|
|
" <td>700.5</td>\n",
|
|
" <td>['Consistent upward VWAP movement', 'Price sta...</td>\n",
|
|
" <td>The current market window shows a consistent u...</td>\n",
|
|
" <td>2025-01-31 10:55:00-05:00</td>\n",
|
|
" <td>0.000044</td>\n",
|
|
" <td>-0.000251</td>\n",
|
|
" <td>135296.6</td>\n",
|
|
" <td>0.000044</td>\n",
|
|
" <td>up</td>\n",
|
|
" <td>True</td>\n",
|
|
" <td>10</td>\n",
|
|
" <td>4</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>2</th>\n",
|
|
" <td>up</td>\n",
|
|
" <td>0.85</td>\n",
|
|
" <td>0.01</td>\n",
|
|
" <td>0.02</td>\n",
|
|
" <td>700.00</td>\n",
|
|
" <td>698.5</td>\n",
|
|
" <td>701.5</td>\n",
|
|
" <td>['Consistent upward VWAP movement', 'Price sta...</td>\n",
|
|
" <td>The current market window shows a consistent u...</td>\n",
|
|
" <td>2025-01-31 11:00:00-05:00</td>\n",
|
|
" <td>0.000043</td>\n",
|
|
" <td>0.000080</td>\n",
|
|
" <td>131817.6</td>\n",
|
|
" <td>0.000043</td>\n",
|
|
" <td>up</td>\n",
|
|
" <td>True</td>\n",
|
|
" <td>11</td>\n",
|
|
" <td>4</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>3</th>\n",
|
|
" <td>up</td>\n",
|
|
" <td>0.85</td>\n",
|
|
" <td>0.01</td>\n",
|
|
" <td>0.02</td>\n",
|
|
" <td>700.84</td>\n",
|
|
" <td>699.5</td>\n",
|
|
" <td>702.0</td>\n",
|
|
" <td>['Consistent upward VWAP movement', 'Price sta...</td>\n",
|
|
" <td>The current market window shows a consistent u...</td>\n",
|
|
" <td>2025-01-31 11:05:00-05:00</td>\n",
|
|
" <td>0.000041</td>\n",
|
|
" <td>-0.000457</td>\n",
|
|
" <td>131642.2</td>\n",
|
|
" <td>0.000041</td>\n",
|
|
" <td>up</td>\n",
|
|
" <td>True</td>\n",
|
|
" <td>11</td>\n",
|
|
" <td>4</td>\n",
|
|
" </tr>\n",
|
|
" <tr>\n",
|
|
" <th>4</th>\n",
|
|
" <td>up</td>\n",
|
|
" <td>0.85</td>\n",
|
|
" <td>0.01</td>\n",
|
|
" <td>0.02</td>\n",
|
|
" <td>699.50</td>\n",
|
|
" <td>698.5</td>\n",
|
|
" <td>700.5</td>\n",
|
|
" <td>['Consistent upward VWAP movement', 'Price sta...</td>\n",
|
|
" <td>The current market window shows a consistent u...</td>\n",
|
|
" <td>2025-01-31 11:10:00-05:00</td>\n",
|
|
" <td>0.000044</td>\n",
|
|
" <td>-0.000564</td>\n",
|
|
" <td>139622.6</td>\n",
|
|
" <td>0.000044</td>\n",
|
|
" <td>up</td>\n",
|
|
" <td>True</td>\n",
|
|
" <td>11</td>\n",
|
|
" <td>4</td>\n",
|
|
" </tr>\n",
|
|
" </tbody>\n",
|
|
"</table>\n",
|
|
"</div>"
|
|
],
|
|
"text/plain": [
|
|
" vwap_direction_next_5min confidence_score expected_vwap_change \\\n",
|
|
"0 up 0.85 0.01 \n",
|
|
"1 up 0.85 0.01 \n",
|
|
"2 up 0.85 0.01 \n",
|
|
"3 up 0.85 0.01 \n",
|
|
"4 up 0.85 0.01 \n",
|
|
"\n",
|
|
" volatility_estimate suggested_entry suggested_stop_loss \\\n",
|
|
"0 0.02 701.50 700.5 \n",
|
|
"1 0.02 699.50 698.5 \n",
|
|
"2 0.02 700.00 698.5 \n",
|
|
"3 0.02 700.84 699.5 \n",
|
|
"4 0.02 699.50 698.5 \n",
|
|
"\n",
|
|
" suggested_take_profit key_signals \\\n",
|
|
"0 702.5 ['Consistent upward VWAP movement', 'Price abo... \n",
|
|
"1 700.5 ['Consistent upward VWAP movement', 'Price sta... \n",
|
|
"2 701.5 ['Consistent upward VWAP movement', 'Price sta... \n",
|
|
"3 702.0 ['Consistent upward VWAP movement', 'Price sta... \n",
|
|
"4 700.5 ['Consistent upward VWAP movement', 'Price sta... \n",
|
|
"\n",
|
|
" reasoning \\\n",
|
|
"0 The current market window shows a consistent u... \n",
|
|
"1 The current market window shows a consistent u... \n",
|
|
"2 The current market window shows a consistent u... \n",
|
|
"3 The current market window shows a consistent u... \n",
|
|
"4 The current market window shows a consistent u... \n",
|
|
"\n",
|
|
" timestamp_prediction actual_vwap_change actual_price_change \\\n",
|
|
"0 2025-01-31 10:50:00-05:00 0.000048 0.000126 \n",
|
|
"1 2025-01-31 10:55:00-05:00 0.000044 -0.000251 \n",
|
|
"2 2025-01-31 11:00:00-05:00 0.000043 0.000080 \n",
|
|
"3 2025-01-31 11:05:00-05:00 0.000041 -0.000457 \n",
|
|
"4 2025-01-31 11:10:00-05:00 0.000044 -0.000564 \n",
|
|
"\n",
|
|
" actual_volume actual_return actual_movement prediction_correct hour \\\n",
|
|
"0 149963.0 0.000048 up True 10 \n",
|
|
"1 135296.6 0.000044 up True 10 \n",
|
|
"2 131817.6 0.000043 up True 11 \n",
|
|
"3 131642.2 0.000041 up True 11 \n",
|
|
"4 139622.6 0.000044 up True 11 \n",
|
|
"\n",
|
|
" day_of_week \n",
|
|
"0 4 \n",
|
|
"1 4 \n",
|
|
"2 4 \n",
|
|
"3 4 \n",
|
|
"4 4 "
|
|
]
|
|
},
|
|
"execution_count": 2,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"import pandas as pd\n",
|
|
"df = pd.read_csv('/Users/ysheynin/deepseek_playground/market_predictor/output/META_2025-01-29_2025-02-02_20250204_044205/predictions.csv')\n",
|
|
"df.head()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": null,
|
|
"metadata": {},
|
|
"outputs": [],
|
|
"source": []
|
|
}
|
|
],
|
|
"metadata": {
|
|
"kernelspec": {
|
|
"display_name": "DeepSeek Playground (Poetry)",
|
|
"language": "python",
|
|
"name": "deepseek_playground"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.12.8"
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|