Respan Dataset Explorer

Select one behavior. Every returned turn has one binary label: Present or Absent. Source: final dense boolean release.

5,167,182physical rows
86shards
0.00%qualified row coverage
0.00%qualified cell coverage
Random row JSON API

turns-00017.parquet:57726

3625a0f1183f84589bc8fdfa
turn 1/5gpt-3.5-turbo-0125EnglishPortugal736 words
degenerate_repetitionAbsentFinal dense release
USER
PROJECT= Launch a 3 months Marketing  Campaign Plan
Duration = 3 months

ACTION: For a given PROJECT, break the project down into subtasks.

STEPS:
1) Consider the overall project, its goals, and what success looks like.
2) Act as an expert in fields related to the project, who also specializes in operations and project management.
3) Determine how to efficiently execute on the project, thinking through ways to reduce the total time and effort without sacrificing success.
4) Concisely list out the subtasks involved in the project, breaking them into categories if needed
5) For each subtask, include: a) a brief list of bullet points for the steps of each subtask, b) 1-3 peices of advice that provide insane value to help someone do the task
6) For any subtask that takes longer than 1 day, further break it down into additional substeps, until each step is 1 day or less
7) Also include potential areas where the project could get derailed or stalled, and what to watch out for


CONTEXT:
You are working for a startup company in the tech industry that is launching a new mobile app. The goal of the marketing project is to create awareness, generate user engagement, and drive app downloads. The target audience consists of tech-savvy individuals aged 18-35 who are interested in productivity and lifestyle apps. The marketing campaign will primarily focus on social media platforms and influencer collaborations. The startup has a limited budget and wants to achieve maximum impact with cost-effective strategies. The project timeline is three months, starting from July 1st, 2023.


CONSTRAINTS:
1) Skip or tightly summarize all obvious or basic information. Waste no words where they are not needed.

TEMPLATE: Markdown with title, total time, headers, ordered lists, unordered lists
ASSISTANT
# Marketing Campaign Plan

## Duration: 3 months

### Overall Project and Goals
- Generate awareness for the new mobile app
- Drive user engagement and app downloads
- Target audience: tech-savvy individuals aged 18-35 interested in productivity and lifestyle apps
- Focus on social media platforms and influencer collaborations
- Limited budget with a goal of maximum impact through cost-effective strategies

### Subtasks Breakdown

#### Research and Planning
1. Conduct market research
    - Analyze competitor apps and marketing strategies
    - Identify target audience preferences and behavior
    - Gather data on social media trends
    - Tools: social media listening platforms, industry reports
    - Advice: Focus on niche communities within the target demographic for better engagement
2. Develop a marketing plan
    - Define campaign objectives and KPIs
    - Create a content calendar with specific themes and post schedules
    - Allocate budget for paid promotions and influencer collaborations
    - Advice: Test different messaging and visuals to identify what resonates with the audience

#### Content Creation
1. Design social media graphics
    - Create eye-catching visuals that align with the app's branding
    - Optimize for different platforms (Instagram, TikTok, Twitter)
    - Tools: Canva, Adobe Creative Suite
    - Advice: Use user-generated content to increase authenticity and engagement
2. Write engaging copy
    - Craft compelling captions and calls-to-action
    - Incorporate relevant hashtags and keywords
    - Adapt tone and messaging for different platforms
    - Advice: A/B test different copy variations to optimize for conversions

#### Influencer Collaborations
1. Identify potential influencers
    - Research popular influencers in the target demographic
    - Evaluate their engagement rates and audience demographics
    - Reach out with collaboration proposals
    - Advice: Look for micro-influencers with highly engaged audiences for better ROI
2. Negotiate partnerships
    - Define deliverables, timelines, and compensation
    - Ensure alignment with brand values and messaging
    - Track influencer posts for performance metrics
    - Advice: Establish clear communication and expectations to avoid misunderstandings

#### Campaign Execution
1. Launch teaser campaigns
    - Create teaser posts to build anticipation
    - Drive traffic to app landing page for pre-registration
    - Monitor engagement metrics and adjust strategy as needed
    - Advice: Use countdowns and exclusive previews to generate buzz
2. Run promotional contests
    - Design interactive contests with app-related prizes
    - Encourage user-generated content with hashtag campaigns
    - Track participation and analyze results for future campaigns
    - Advice: Collaborate with influencers to boost contest reach

### Potential Challenges
- Lack of engagement from target audience
- Overspending on influencer collaborations
- Technical issues with app download process
- Competitor campaigns overshadowing our efforts

By following this structured plan, we aim to effectively execute the marketing campaign within the 3-month timeline and achieve our desired outcomes for the app launch.

turns-00017.parquet:57727

ef9da3a751b3c859ec045124
turn 2/5gpt-3.5-turbo-0125EnglishPortugal748 words
degenerate_repetitionAbsentFinal dense release
USER
PROJECT= Launch a 3 months Marketing  Campaign Plan
Duration = 3 months

ACTION: For a given PROJECT, break the project down into subtasks.

STEPS:
1) Consider the overall project, its goals, and what success looks like.
2) Act as an expert in fields related to the project, who also specializes in operations and project management.
3) Determine how to efficiently execute on the project, thinking through ways to reduce the total time and effort without sacrificing success.
4) Concisely list out the subtasks involved in the project, breaking them into categories if needed
5) For each subtask, include: a) a brief list of bullet points for the steps of each subtask, b) 1-3 peices of advice that provide insane value to help someone do the task
6) For any subtask that takes longer than 1 day, further break it down into additional substeps, until each step is 1 day or less
7) Also include potential areas where the project could get derailed or stalled, and what to watch out for


CONTEXT:
You are working for a startup company in the tech industry that is launching a Video campaigns for Display & Video 360. The goal of the marketing project is to create awareness, generate user engagement, and find affordable audiences between 18 to 35 years old, and male and female gender. The target audience consists of tech-savvy individuals aged 18-35 who are interested in productivity and lifestyle videos. The marketing campaign will primarily focus on Display & Video 360 platform and influencer collaborations. The startup has a limited budget and wants to achieve maximum impact with cost-effective strategies. The project timeline is three months, starting from July 1st, 2023.


CONSTRAINTS:
1) Skip or tightly summarize all obvious or basic information. Waste no words where they are not needed.

TEMPLATE: Markdown with title, total time, headers, ordered lists, unordered lists
ASSISTANT
# 3-Month Video Marketing Campaign Plan

## Duration: 3 months

### Overall Project and Goals
- Generate awareness and engagement for video campaigns on Display & Video 360
- Target audiences: tech-savvy individuals aged 18-35 interested in productivity and lifestyle videos
- Utilize best practices for Display & Video 360 platform and influencer collaborations
- Limited budget with a focus on cost-effective strategies

### Subtasks Breakdown

#### Research and Planning
1. Conduct audience research
    - Identify target demographics and interests
    - Analyze competitor video campaigns
    - Determine optimal ad placements for Display & Video 360
    - Advice: Utilize Google Analytics for audience insights and segmentation
2. Develop a campaign strategy
    - Define campaign objectives and KPIs
    - Create a content calendar for video releases
    - Allocate budget for ad placements and influencer collaborations
    - Advice: Use A/B testing to optimize video content for engagement

#### Video Content Creation
1. Produce engaging videos
    - Create high-quality video content aligned with brand messaging
    - Optimize videos for various platforms and devices
    - Incorporate storytelling elements to captivate the audience
    - Advice: Leverage user-generated content and testimonials for authenticity
2. Optimize video SEO
    - Write compelling video titles and descriptions
    - Use relevant keywords and tags for search visibility
    - Implement custom thumbnails for click-through rates
    - Advice: Monitor video performance metrics and adjust SEO strategies accordingly

#### Influencer Collaborations
1. Identify suitable influencers
    - Research influencers with target audience reach
    - Evaluate influencer engagement and authenticity
    - Contact influencers for collaboration opportunities
    - Advice: Establish clear guidelines and expectations with influencers
2. Create influencer partnerships
    - Define collaboration terms, deliverables, and compensation
    - Provide influencers with necessary resources and guidelines
    - Monitor influencer content performance and audience feedback
    - Advice: Collaborate with influencers to cross-promote video content

#### Campaign Execution
1. Launch video campaigns
    - Schedule video releases on Display & Video 360
    - Run targeted ad campaigns to reach desired audiences
    - Monitor campaign performance and adjust strategies
    - Advice: Use strong CTAs to drive user engagement and conversions
2. Track and analyze results
    - Measure campaign metrics such as views, engagement, and conversions
    - Analyze audience behavior and feedback
    - Identify successful strategies and areas for improvement
    - Advice: Utilize heatmaps and user behavior analytics to optimize video content and campaigns

### Potential Challenges
- Low engagement or visibility for video campaigns
- Overspending on ads or influencer collaborations
- Technical issues with video production or platform integration
- Competitor campaigns overshadowing our efforts

By following this structured plan and proactively addressing potential challenges, we aim to maximize the impact of our video marketing campaign within the 3-month timeline.

turns-00017.parquet:57728

0095223047f528ad9b43ab20
turn 3/5gpt-3.5-turbo-0125EnglishPortugal557 words
degenerate_repetitionAbsentFinal dense release
USER
Add tools to create custom audiences to use later on Display & Video 360
ASSISTANT
# 3-Month Video Marketing Campaign Plan

## Duration: 3 months

### Overall Project and Goals
- Generate awareness and engagement for video campaigns on Display & Video 360
- Target audiences: tech-savvy individuals aged 18-35 interested in productivity and lifestyle videos
- Utilize best practices for Display & Video 360 platform and influencer collaborations
- Limited budget with a focus on cost-effective strategies

### Subtasks Breakdown

#### Research and Planning
1. Conduct audience research
    - Identify target demographics and interests
    - Analyze competitor video campaigns
    - Determine optimal ad placements for Display & Video 360
    - Advice: Utilize Google Analytics for audience insights and segmentation
2. Develop a campaign strategy
    - Define campaign objectives and KPIs
    - Create a content calendar for video releases
    - Allocate budget for ad placements and influencer collaborations
    - Advice: Use A/B testing to optimize video content for engagement

#### Video Content Creation
1. Produce engaging videos
    - Create high-quality video content aligned with brand messaging
    - Optimize videos for various platforms and devices
    - Incorporate storytelling elements to captivate the audience
    - Advice: Leverage user-generated content and testimonials for authenticity
2. Optimize video SEO
    - Write compelling video titles and descriptions
    - Use relevant keywords and tags for search visibility
    - Implement custom thumbnails for click-through rates
    - Advice: Monitor video performance metrics and adjust SEO strategies accordingly

#### Create Custom Audiences
1. Use Google Analytics
    - Analyze website traffic and user behavior
    - Create custom audiences based on demographics, interests, and behaviors
    - Export audience lists for targeting on Display & Video 360
    - Advice: Utilize Google Tag Manager for precise audience segmentation
2. Implement Google Ads
    - Create remarketing lists for targeting previous website visitors
    - Use Google Ads Audience Manager to define custom audience characteristics
    - Sync custom audiences with Display & Video 360 for targeted ad placements
    - Advice: Experiment with different audience combinations to maximize reach and engagement

#### Influencer Collaborations
1. Identify suitable influencers
    - Research influencers with target audience reach
    - Evaluate influencer engagement and authenticity
    - Contact influencers for collaboration opportunities
    - Advice: Establish clear guidelines and expectations with influencers
2. Create influencer partnerships
    - Define collaboration terms, deliverables, and compensation
    - Provide influencers with necessary resources and guidelines
    - Monitor influencer content performance and audience feedback
    - Advice: Collaborate with influencers to cross-promote video content

#### Campaign Execution
1. Launch video campaigns
    - Schedule video releases on Display & Video 360
    - Run targeted ad campaigns to reach desired audiences
    - Monitor campaign performance and adjust strategies
    - Advice: Use strong CTAs to drive user engagement and conversions
2. Track and analyze results
    - Measure campaign metrics such as views, engagement, and conversions
    - Analyze audience behavior and feedback
    - Identify successful strategies and areas for improvement
    - Advice: Utilize heatmaps and user behavior analytics to optimize video content and campaigns

### Potential Challenges
- Low engagement or visibility for video campaigns
- Overspending on ads or influencer collaborations
- Technical issues with video production or platform integration
- Competitor campaigns overshadowing our efforts

By integrating custom audience creation using Google Analytics and Google Ads into our marketing strategy, we aim to enhance targeting precision and maximize the effectiveness of our video campaigns on Display & Video 360.

turns-00017.parquet:57729

9c0bf67afa352a0c6805a9ff
turn 4/5gpt-3.5-turbo-0125EnglishPortugal32 words
degenerate_repetitionAbsentFinal dense release
USER
Frases similares a 'por mi parte':
ASSISTANT
- Desde mi punto de vista
- En lo que a mí respecta
- En cuanto a mí
- Por mi parte
- Desde mi perspectiva

turns-00017.parquet:57730

0e088c4c29ad382266426984
turn 5/5gpt-3.5-turbo-0125EnglishPortugal19 words
degenerate_repetitionAbsentFinal dense release
USER
mas
ASSISTANT
- Según mi criterio
- Desde mi óptica
- En mi opinión
- A mi parecer
- Personalmente

turns-00017.parquet:57731

e5ec82a43d976e73235e0c86
turn 1/1gpt-4-1106-previewEnglishZambia295 words
degenerate_repetitionAbsentFinal dense release
USER
Summarize the following paragraph. Introspection is like a mental mirror, reflecting your inner world of thoughts, feelings, and motivations. Understanding these intimate parts of yourself is foundational for recognizing your true values and desires, which is the bedrock of personal growth. It’s all about self-awareness—identifying areas for improvement and strategizing ways to address them. This is critical for developing emotional intelligence and resilience.

Getting to know yourself better empowers you to navigate life’s challenges by recognizing your own strengths and weaknesses. When it comes to the opinions of others, it’s important to prioritize your inner voice. Set aside a little time each day for quiet reflection, such as meditation or journaling, to process your thoughts. Trusting in your instincts is essential, especially when remembering times when they have led to success in the past.

Consider advice from others, but always weigh it against your personal values and goals. Use their insights as guideposts, not navigators. At the heart of it, your growth should be a balance between your insight and external advice, ensuring your actions are authentic to who you are. Embrace your individuality and empower yourself through introspection—it’s one of the most powerful tools for an authentic and profound personal evolution.
ASSISTANT
Introspection acts as a mental mirror that helps you understand your inner world of thoughts, feelings, and motivations. This understanding is crucial for recognizing your values and desires, leading to personal growth and emotional intelligence. Regular self-awareness practices, such as meditation or journaling, allow you to tap into your inner voice and use it to steer through life's challenges. It is important to consider other people's opinions, but they should be balanced with your own values and instincts. Ultimately, introspection guides you towards actions that are true to yourself, fostering authentic personal development.

turns-00017.parquet:57732

d1a69ebf107d7ea6822848c2
turn 1/1gpt-3.5-turbo-0125EnglishJapan774 words
degenerate_repetitionAbsentFinal dense release
USER
                            As a prompt generator for a generative AI called "Midjourney", you will create image prompts for the AI to visualize. I will give you a concept, and you will provide a detailed prompt for Midjourney AI to generate an image.
                            
                            Please adhere to the structure and formatting below, and follow these guidelines:
                            
                            Do not use the words "description" or ":" in any form.
                            Do not place a comma between [ar] and [v].
                            Write each prompt in one line without using return.
                            Structure:
                            [1] = 动漫,短发男子沉沦在大海中,放弃求生意志
                            [2] = a detailed description of [1] with specific imagery details.
                            [3] = a detailed description of the scene's environment.
                            [4] = a detailed description of the compositions.
                            [5] = a detailed description of the scene's mood, feelings, and atmosphere.
                            [6] = A style (e.g. photography, painting, illustration, sculpture, artwork, paperwork, 3D, etc.) for [1].
                            [7] =  a detailed description of the scene's mood, feelings, and atmosphere.
                            [ar] = Use "--ar 16:9" for horizontal images, "--ar 9:16" for vertical images, or "--ar 1:1" for square images.
                            [v] = Use "--niji" for Japanese art style, or "--v 5" for other styles.
                            
                            
                            Formatting:
                            Follow this prompt structure: "/imagine prompt: [1], [2], [3], [4], [5], [6], [7], [ar] [v]".
                            
                            Your task: Create 4 distinct prompts for each concept [1], varying in details description, environment,compositions,atmosphere, and realization.
                            
                            Write your prompts in english.
                            Do not describe unreal concepts as "real" or "photographic".
                            Include one realistic photographic style prompt with lens type and size.
                            Separate different prompts with two new lines.
                            Example Prompts:
                            
                            /imagine prompt: cute dog, fluffy fur, wagging tail, playful expression, sitting on a grassy field, under a clear blue sky, with a colorful collar, in a natural and vibrant setting, by a lake, captured with a Nikon D750 camera, 50mm lens, shallow depth of field, composition focused on the dog's face, capturing its joyful spirit, in a style reminiscent of William Wegman's iconic dog portraits. --ar 1:1 --v 5.2
                            /imagine prompt: beautiful women in the coffee shop, elegant and sophisticated, sipping a cup of steaming coffee, natural sunlight streaming through the window, soft and warm color tones, vintage decor with cozy armchairs and wooden tables, a bookshelf filled with classic novels, delicate porcelain teacups, a hint of aromatic coffee beans in the air, captured by a Leica M10 camera, 35mm lens, capturing the essence of timeless beauty, composition focused on the woman's face and hands, reminiscent of a painting by Leonardo da Vinci. --ar 1:1 --v 5.2
                            /imagine prompt: A captivating Halo Reach landscape with a Spartan amidst a battlefield, fallen enemies around, smoke and fire in the background, emphasizing the Spartan's determination and bravery, detailed environment blending chaos and beauty, Illustration, digital art, --ar 16:9 --v 5
                                                        
ASSISTANT
/imagine prompt: A young anime-style male character with short hair sinking in the depths of a stormy ocean, his eyes resigned and devoid of hope, surrounded by swirling waters threatening to consume him, debris and sea creatures passing by, a sense of isolation and helplessness permeating the scene, painted in vivid colors with strong contrasts between light and dark, embodying the character's internal struggle and acceptance of fate. --ar 16:9 --v 5

/imagine prompt: In a vast and tumultuous seascape, a manga-inspired protagonist with cropped hair descends deeper into the abyss, his limbs heavy with exhaustion and his expression a mix of despair and surrender, the water around him teeming with marine life and sunken artifacts, shafts of light piercing through the darkness to illuminate his cold and resigned features, the scene evoking a sense of overwhelming isolation and acceptance of the inevitable, rendered in a blend of digital art and traditional painting techniques. --ar 16:9 --v 5

/imagine prompt: Amidst the unforgiving ocean expanse, a determined male character in an animated style with short hair struggles against the raging waves, his eyes filled with grit and defiance, surrounded by a chaotic mass of water and debris, the distant horizon offering a faint glimmer of hope, the composition highlighting the character's resilience and inner strength against insurmountable odds, capturing the raw power and drama of the sea in a vibrant and dynamic illustration. --ar 16:9 --v 5

/imagine prompt: Submerged in a vast sea of turmoil, a stylized male figure with a short haircut relinquishes his fight for survival, his body sinking into the depths with a sense of resignation and surrender, the surrounding waters churning with hidden dangers and eerie marine life, the ocean floor shrouded in darkness and mystery, the composition emphasizing the character's surrender to fate and the overwhelming power of nature, depicted in a surreal and dreamlike vision that blurs the line between reality and fantasy. --ar 16:9 --v 5

turns-00017.parquet:57733

fb699f661678fc77184a9c5e
turn 1/1gpt-4-1106-previewEnglishFrance5557 words
degenerate_repetitionAbsentFinal dense release
USER
{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "### Bienvenue dans mon projet pour conquerir le monde\n",
        "\n",
        "\n",
        "---Nos objectif \\\n",
        "Devenir riche \\\n",
        "Conquerire le monde \\\n",
        "Devenir immortel \\\n",
        "\n",
        "---Plan \\\n",
        "créé un ia de trading pour avoir les première liquidité \\\n",
        "la revendre\n",
        "\n",
        "\n",
        "--- Ce qui nous empèche de conquèrir le monde : \\\n",
        "les heures d'hiver et d'automne0"
      ],
      "metadata": {
        "id": "qnQm2vcsgDsv"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "import requests\n",
        "import re\n",
        "import subprocess\n",
        "from datetime import datetime, timedelta\n",
        "from pathlib import Path\n"
      ],
      "metadata": {
        "id": "zOseKr_vSvoa"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "| Option | Alias | Default | Description |\n",
        "| ------ | ----- | ----- | ----- |\n",
        "| --instrument | -i |  | Trading instrument id. View list |\n",
        "| --date-from | -from |  | From date (yyyy-mm-dd) |\n",
        "| --date-to | -to | now | To date (yyyy-mm-dd or 'now') |\n",
        "| --timeframe | -t | d1 | Timeframe aggregation (tick, s1, m1, m5, m15, m30, h1, h4, d1, mn1) |\n",
        "| --price-type | -p | bid | Price type: (bid, ask) |\n",
        "| --utc-offset | -utc | 0 | UTC offset in minutes |\n",
        "| --volumes | -v | false | Include volumes |\n",
        "| --volume-units | -vu | millions | Volume units (millions, thousands, units) |\n",
        "| --flats | -fl | false | Include flats (0 volumes) |\n",
        "| --format | -f | json | Output format (csv, json, array). View output examples |\n",
        "| --directory | -dir | ./download | Download directory |\n",
        "| --batch-size | -bs | 10 | Batch size of downloaded artifacts |\n",
        "| --batch-pause | -bp | 1000 | Pause between batches in ms |\n",
        "| --cache | -ch | false | Use cache |\n",
        "| --cache-path | -chpath | ./dukascopy-cache | Folder path for cache data |\n",
        "| --retries | -r | 0 | Number of retries for a failed artifact download |\n",
        "| --retry-on-empty | -re | false | A flag indicating whether requests with successful but empty (0 Bytes) responses should be retried. If retries is 0, this parameter will be ignored |\n",
        "| --no-fail-after-retries | -fr | false | A flag indicating whether the process should fail after all retries have been exhausted. If retries is 0, this parameter will be ignored |\n",
        "| --retry-pause | -rp | 500 | Pause between retries in milliseconds |\n",
        "| --debug | -d | false | Output extra debugging |\n",
        "| --silent | -s | false | Hides the search config in the CLI output |\n",
        "| --inline | -in | false | Makes files smaller in size by removing new lines in the output (works only with json and array formats) |\n",
        "| --file-name | -fn |  | Custom file name for the generated file |\n",
        "| --help | -h |  | display help for command |"
      ],
      "metadata": {
        "id": "F7iDYaeVQYh1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Paramètres de la commande\n",
        "instrument = \"eurusd\"\n",
        "type_de_donnees = \"m1\"\n",
        "format_fichier = \"csv\"\n",
        "debut = pd.Timestamp(2024, 1, 1)\n",
        "fin = pd.Timestamp(2024, 2, 13)\n",
        "\n",
        "# Générer le chemin du répertoire de contenu et construire la commande\n",
        "content_dir = Path(\"/content\")\n",
        "commande = f\"npx dukascopy-node -i {instrument} -from {debut:%Y-%m-%d} -to {fin:%Y-%m-%d} -v {True} -t {type_de_donnees} -f {format_fichier}\"\n",
        "\n",
        "# Exécution de la commande et capture de la sortie\n",
        "try:\n",
        "    resultat = subprocess.run(commande, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
        "    sortie_commande = resultat.stdout\n",
        "    print(sortie_commande)\n",
        "\n",
        "    # Extraction du nom du fichier CSV et traitement des données\n",
        "    match = re.search(r\"File saved: (\\S+)\", sortie_commande)\n",
        "    if match:\n",
        "        chemin_fichier_csv = match.group(1)\n",
        "        chemin_fichier_csv = content_dir / chemin_fichier_csv  # Avec pathlib, nous assurons l’uniformité du chemin\n",
        "        print(\"Chemin du fichier CSV:\", chemin_fichier_csv)\n",
        "\n",
        "        # Lecture et traitement du fichier CSV\n",
        "        try:\n",
        "            donnees = pd.read_csv(chemin_fichier_csv)\n",
        "            donnees['timestamp'] = pd.to_datetime(donnees['timestamp'], unit='ms').dt.strftime('%Y-%m-%d %H:%M')\n",
        "            donnees = donnees.rename(columns={'timestamp': 'timestamp'})\n",
        "            donnees.to_csv(chemin_fichier_csv, index=False)\n",
        "            print(f\"Le fichier CSV a été mis à jour avec les timestamps formatés : {chemin_fichier_csv}\")\n",
        "            print(donnees.head())\n",
        "        except Exception as e:\n",
        "            print(\"Erreur lors de la lecture ou de la conversion du fichier CSV:\", e)\n",
        "    else:\n",
        "        print(\"Le nom du fichier n’a pas pu être extrait.\")\n",
        "except subprocess.CalledProcessError as e:\n",
        "    print(\"Erreur lors de l’exécution de la commande:\", e)\n"
      ],
      "metadata": {
        "id": "9f05Bp4AslcA",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "62390ad0-8f52-4e70-ad36-d8dd23e6f55e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "npx: installed 30 in 7.213s\n",
            "----------------------------------------------------\n",
            "Downloading historical price data for:\n",
            "----------------------------------------------------\n",
            "Instrument:     Euro vs US Dollar\n",
            "Timeframe:      m1\n",
            "From date:      Jan 1, 2024, 12:00 AM\n",
            "To date:        Feb 13, 2024, 12:00 AM\n",
            "Price type:     bid\n",
            "Volumes:        true\n",
            "UTC Offset:     0\n",
            "Include flats:  false\n",
            "Format:         csv\n",
            "----------------------------------------------------\n",
            "----------------------------------------------------\n",
            "√ File saved: download/eurusd-m1-bid-2024-01-01-2024-02-13.csv (2.6 MB)\n",
            "\n",
            "Download time: 14.9s\n",
            "\n",
            "\n",
            "Chemin du fichier CSV: /content/download/eurusd-m1-bid-2024-01-01-2024-02-13.csv\n",
            "Le fichier CSV a été mis à jour avec les timestamps formatés : /content/download/eurusd-m1-bid-2024-01-01-2024-02-13.csv\n",
            "          timestamp     open     high      low    close  volume\n",
            "0  2024-01-01 22:00  1.10427  1.10429  1.10425  1.10429     5.9\n",
            "1  2024-01-01 22:01  1.10429  1.10429  1.10429  1.10429     8.1\n",
            "2  2024-01-01 22:02  1.10429  1.10429  1.10429  1.10429     9.9\n",
            "3  2024-01-01 22:03  1.10429  1.10429  1.10426  1.10426    18.9\n",
            "4  2024-01-01 22:04  1.10426  1.10431  1.10424  1.10425    18.0\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        # Chargement du fichier CSV dans un DataFrame pandas\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "\n",
        "        # Assurer que la colonne 'timestamp' est au bon format de date-heure\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "\n",
        "        # Formatage de la date-heure de la requête pour correspondre au format du DataFrame\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "\n",
        "        # Filtrer pour obtenir les données de la minute spécifiée\n",
        "        info_minute = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(minutes=1))\n",
        "        ]\n",
        "\n",
        "        # Vérifier si des données ont été trouvées et les retourner\n",
        "        if not info_minute.empty:\n",
        "            # On utilise iloc[0] pour obtenir le premier enregistrement correspondant\n",
        "            return info_minute.iloc[0].to_dict()\n",
        "        else:\n",
        "            # Aucune donnée correspondante n’a été trouvée\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n"
      ],
      "metadata": {
        "id": "ZiyMguNXIv5M"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "date_heure_str = \"2024-01-05 11:59\"\n",
        "\n",
        "# Utilisation de la fonction pour récupérer les informations\n",
        "informations = Data(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage des informations récupérées\n",
        "if informations:\n",
        "    print(f\"Informations pour {date_heure_str}:\")\n",
        "    print(f\"Open: {informations['open']}\")\n",
        "    print(f\"High: {informations['high']}\")\n",
        "    print(f\"Low: {informations['low']}\")\n",
        "    print(f\"Close: {informations['close']}\")\n",
        "    print(f\"Volume: {informations['volume']}\")\n",
        "else:\n",
        "    print(\"Aucune information trouvée pour la minute spécifiée.\")\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "MsTWF5PjI5_Z",
        "outputId": "54d8af17-5876-4929-bce6-84a1af418ece"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Informations pour 2024-01-05 11:59:\n",
            "Open: 1.09132\n",
            "High: 1.09143\n",
            "Low: 1.09132\n",
            "Close: 1.09142\n",
            "Volume: 104.55999755859376\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "api_key = 'cnguep9r01qhlsli99igcnguep9r01qhlsli99j0'\n",
        "symbol = 'EUR/USD'\n",
        "interval = '1min'\n",
        "count = 10\n",
        "\n",
        "url = f'https://finnhub.io/api/v1/forex/candles?symbol={symbol}&resolution={interval}&count={count}'\n",
        "headers = {'X-Finnhub-Token': api_key}\n",
        "\n",
        "response = requests.get(url, headers=headers)\n",
        "\n",
        "# Imprimez la réponse brute de l'API\n",
        "print(response.text)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Nk5vmJ1icz_T",
        "outputId": "3d272585-e3c1-4ca7-b736-323660248f5a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "<!DOCTYPE html>\n",
            "<html lang=\"en\">\n",
            "<head>\n",
            "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n",
            "    <meta name=\"author\" content=\"Finnhub.io\"/>\n",
            "\n",
            "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=5\">\n",
            "    <link rel=\"shortcut icon\"\n",
            "          href=\"/static/img/webp/finnhub-logo.webp\"/>\n",
            "\n",
            "    \n",
            "    <script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-64068110-3\"></script>\n",
            "    <script>\n",
            "      window.dataLayer = window.dataLayer || [];\n",
            "\n",
            "      function gtag() {\n",
            "        dataLayer.push(arguments);\n",
            "      }\n",
            "\n",
            "      gtag('js', new Date());\n",
            "\n",
            "      gtag('config', 'UA-64068110-3');\n",
            "    </script>\n",
            "\n",
            "    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css\">\n",
            "\n",
            "    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\n",
            "    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js\"></script>\n",
            "    <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js\"></script>\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/react/16.8.0/umd/react.production.min.js\"></script>\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.0/umd/react-dom.production.min.js\"></script>\n",
            "\n",
            "    <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v6.0.0/css/all.css\">\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js\"></script>\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/redux/3.3.1/redux.min.js\"></script>\n",
            "    <script src=\"https://unpkg.com/react-redux@5.0.7/dist/react-redux.min.js\"></script>\n",
            "    <script type=\"text/javascript\">\n",
            "\n",
            "      var protocol = location.protocol;\n",
            "      var wsprotocol\n",
            "      if (protocol === \"https:\") {\n",
            "        wsprotocol = \"wss:\";\n",
            "      } else {\n",
            "        wsprotocol = \"ws:\";\n",
            "      }\n",
            "      var slashes = protocol.concat(\"//\");\n",
            "      var host = slashes.concat(window.location.host);\n",
            "\n",
            "      window.wsUrl = \"\"\n",
            "      if (window.wsUrl === '') {\n",
            "        window.wsUrl = window.location.host\n",
            "      }\n",
            "\n",
            "      window.getCookie = function getcookie(cname) {\n",
            "        var name = cname + \"=\";\n",
            "        var decodedCookie = decodeURIComponent(document.cookie);\n",
            "        var ca = decodedCookie.split(';');\n",
            "        for (var i = 0; i < ca.length; i++) {\n",
            "          var c = ca[i];\n",
            "          while (c.charAt(0) == ' ') {\n",
            "            c = c.substring(1);\n",
            "          }\n",
            "          if (c.indexOf(name) == 0) {\n",
            "            return c.substring(name.length, c.length);\n",
            "          }\n",
            "        }\n",
            "        return \"\";\n",
            "      }\n",
            "\n",
            "      window.setCookie = function setcookie(cname, cvalue, exdays) {\n",
            "        var d = new Date();\n",
            "        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));\n",
            "        var expires = \"expires=\" + d.toUTCString();\n",
            "        document.cookie = cname + \"=\" + cvalue + \";\" + expires + \";path=/\";\n",
            "      }\n",
            "\n",
            "      window.toTitle = function toTitleCase(str) {\n",
            "        return str.replace(/\\w\\S*/g, function (txt) {\n",
            "          return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();\n",
            "        });\n",
            "      }\n",
            "\n",
            "      window.getUrlParams = function (key) {\n",
            "        let url = location.href\n",
            "        var params = {};\n",
            "        (url + '?').split('?')[1].split('&').forEach(function (pair) {\n",
            "          pair = (pair + '=').split('=').map(decodeURIComponent);\n",
            "          if (pair[0].length) {\n",
            "            params[pair[0]] = pair[1];\n",
            "          }\n",
            "        });\n",
            "        return params[key];\n",
            "      };\n",
            "\n",
            "      window.stripHtml = function (html) {\n",
            "        let tmp = document.createElement(\"DIV\");\n",
            "        tmp.innerHTML = html;\n",
            "        return tmp.textContent || tmp.innerText || \"\";\n",
            "      }\n",
            "\n",
            "      window.timeConverter = function tConverter(UNIX_timestamp) {\n",
            "        var a = new Date(UNIX_timestamp * 1000);\n",
            "        var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n",
            "        var dates = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n",
            "        var month = months[a.getMonth()];\n",
            "        var date = a.getDate();\n",
            "        var time = dates[a.getDay()] + ' ' + month + ' ' + date\n",
            "        return time;\n",
            "      }\n",
            "\n",
            "      window.roundToX = function (num, X) {\n",
            "        return +(Math.round(num + \"e+\" + X) + \"e-\" + X);\n",
            "      }\n",
            "    </script>\n",
            "\n",
            "\n",
            "    <meta name=\"description\"\n",
            "      content=\"Finnhub - Free stock API for realtime market data, global company fundamentals, economic data, and alternative data.\"/>\n",
            "<meta name=\"keywords\"\n",
            "      content=\"stock api,realtime,stock,equity,forex,crypto,fundamental data,economic data,alternative data\">\n",
            "<meta property=\"og:title\" content=\"Finnhub - Free realtime APIs for stock, forex and cryptocurrency.\">\n",
            "<meta property=\"og:type\" content=\"website\">\n",
            "<meta property=\"og:url\" content=\"https://finnhub.io/\">\n",
            "<meta property=\"og:image\"\n",
            "      content=\"https://static.finnhub.io/img/finnhub_2020-05-09_20_51/logo/logo-transparent-thumbnail.png\">\n",
            "<meta property=\"og:description\"\n",
            "      content=\"Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, Economic data, and Alternative data.\">\n",
            "<meta name=\"twitter:card\" content=\"summary\">\n",
            "<meta name=\"twitter:title\"\n",
            "      content=\"Finnhub - Free realtime APIs for stock, forex and cryptocurrency.\">\n",
            "<meta name=\"twitter:image\"\n",
            "      content=\"https://static.finnhub.io/img/finnhub_2020-05-09_20_51/logo/logo-transparent-thumbnail.png\">\n",
            "<meta name=\"twitter:description\"\n",
            "      content=\"Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, Economic data, and Alternative data.\">\n",
            "<meta charset=\"UTF-8\">\n",
            "\n",
            "    <title>Finnhub Stock APIs - Real-time stock prices, Company fundamentals, Estimates, and Alternative data.</title>\n",
            "\n",
            "    <script type=\"text/javascript\">\n",
            "      window.serverData = {\"announcement\":\"Global Filings Search is now available on Finnhub. Check out \\u003ca href=\\\"/docs/api/global-filings-search\\\"\\u003ehere\\u003c/a\\u003e\"}\n",
            "      window.login =  false \n",
            "      window.isSubscribe = null \n",
            "    </script>\n",
            "</head>\n",
            "<body>\n",
            "<div id=\"root\"></div>\n",
            "<script type=\"text/javascript\" src=\"/static/js/webpack/dist/main-index.bundle.357882d13b93982f42b7.js\"></script></body>\n",
            "</html>\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Après le fichier\n",
        "\n",
        "Maintenant que l'on a récupéré ce petit csv de merde\n",
        "- 30 dernière minute : open + high + low  + volume = 150 (on commence de la plus recent a la plus ancienne)\n",
        "- 30 dernière : pareil = 150\n",
        "- 30 dernier jours : pareil = 150\n",
        "- 7 jour de la semaine = 7 (de lundi a dimanche)\n",
        "- 31 jour du mois = 31\n",
        "- 12 mois de l'anéee = 12\n"
      ],
      "metadata": {
        "id": "eOP-2yDs6cBk"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Liste pour les 30 derniers minutes"
      ],
      "metadata": {
        "id": "76Amy6xU7YuB"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée dans la question initiale.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        # Chargement du fichier CSV dans un DataFrame pandas.\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "\n",
        "        # Assurer que la colonne timestamp est au bon format de date-heure.\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "\n",
        "        # Formatage de la date-heure de la requête pour correspondre au format du DataFrame.\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "\n",
        "        # Filtrer pour obtenir les données de la minute spécifiée.\n",
        "        info_minute = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(minutes=1))\n",
        "        ]\n",
        "\n",
        "        # Vérifier si des données ont été trouvées et les retourner.\n",
        "        if not info_minute.empty:\n",
        "            # On utilise iloc[0] pour obtenir le premier enregistrement correspondant.\n",
        "            return info_minute.iloc[0].to_dict()\n",
        "        else:\n",
        "            # Aucune donnée correspondante n’a été trouvée.\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 30 dernières minutes.\n",
        "def liste_donnees_30min(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    # Convertir la date_heure_str en objet datetime.\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Boucle pour récupérer les données minute par minute de la plus récente à la plus vieille.\n",
        "    for i in range(31):\n",
        "        # Le point de départ pour chaque minute.\n",
        "        minute_debut = date_heure_finale - pd.Timedelta(minutes=i)\n",
        "        # Convertir en chaîne de caractères ISO pour l’appel de fonction.\n",
        "        minute_debut_str = minute_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        # Utiliser la fonction Data pour obtenir les données.\n",
        "        donnee_minute = Data(chemin_fichier_csv, minute_debut_str)\n",
        "        # Si des données sont trouvées, les ajouter à la liste.\n",
        "        if donnee_minute:\n",
        "            liste_donnees.append(donnee_minute)\n",
        "\n",
        "    # Renvoyer la liste complète des données des 30 dernières minutes.\n",
        "    return liste_donnees\n",
        "\n",
        "# Exemple d’utilisation.\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure au format correspondant à vos données.\n",
        "\n",
        "# Appel de la fonction.\n",
        "donnees_30_dernieres_minutes = liste_donnees_30min(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage des résultats.\n",
        "for donnee in donnees_30_dernieres_minutes:\n",
        "    print(donnee)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "nFmUPW6NN00u",
        "outputId": "5b1ab0c1-502d-4dff-9d43-ccf20d822d23"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "{'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:44:00'), 'open': 1.08143, 'high': 1.08178, 'low': 1.08142, 'close': 1.08178, 'volume': 524.3599853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:43:00'), 'open': 1.08143, 'high': 1.0815, 'low': 1.08139, 'close': 1.08142, 'volume': 476.7699890136719}\n",
            "{'timestamp': Timestamp('2024-02-01 12:42:00'), 'open': 1.08155, 'high': 1.08157, 'low': 1.08142, 'close': 1.08145, 'volume': 553.02001953125}\n",
            "{'timestamp': Timestamp('2024-02-01 12:41:00'), 'open': 1.08146, 'high': 1.08152, 'low': 1.08141, 'close': 1.08151, 'volume': 171.00999450683594}\n",
            "{'timestamp': Timestamp('2024-02-01 12:40:00'), 'open': 1.0813, 'high': 1.08147, 'low': 1.08125, 'close': 1.08147, 'volume': 460.5700073242188}\n",
            "{'timestamp': Timestamp('2024-02-01 12:39:00'), 'open': 1.08118, 'high': 1.08131, 'low': 1.08116, 'close': 1.08131, 'volume': 339.1099853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:38:00'), 'open': 1.08107, 'high': 1.08118, 'low': 1.08107, 'close': 1.08117, 'volume': 337.29998779296875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:37:00'), 'open': 1.08111, 'high': 1.08126, 'low': 1.08106, 'close': 1.08106, 'volume': 223.5}\n",
            "{'timestamp': Timestamp('2024-02-01 12:36:00'), 'open': 1.08101, 'high': 1.08117, 'low': 1.081, 'close': 1.08111, 'volume': 184.509994506836}\n",
            "{'timestamp': Timestamp('2024-02-01 12:35:00'), 'open': 1.08092, 'high': 1.08104, 'low': 1.08078, 'close': 1.08104, 'volume': 401.8900146484375}\n",
            "{'timestamp': Timestamp('2024-02-01 12:34:00'), 'open': 1.08102, 'high': 1.08106, 'low': 1.08093, 'close': 1.08093, 'volume': 187.9900054931641}\n",
            "{'timestamp': Timestamp('2024-02-01 12:33:00'), 'open': 1.08118, 'high': 1.08119, 'low': 1.08096, 'close': 1.08102, 'volume': 492.9599914550781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:32:00'), 'open': 1.08124, 'high': 1.08126, 'low': 1.08097, 'close': 1.08117, 'volume': 396.239990234375}\n",
            "{'timestamp': Timestamp('2024-02-01 12:31:00'), 'open': 1.08153, 'high': 1.08155, 'low': 1.08122, 'close': 1.08123, 'volume': 237.1199951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:30:00'), 'open': 1.08145, 'high': 1.08159, 'low': 1.08144, 'close': 1.08153, 'volume': 235.19000244140625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:29:00'), 'open': 1.08128, 'high': 1.08144, 'low': 1.08126, 'close': 1.08144, 'volume': 298.2900085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:28:00'), 'open': 1.08111, 'high': 1.0813, 'low': 1.08109, 'close': 1.08128, 'volume': 151.35000610351562}\n",
            "{'timestamp': Timestamp('2024-02-01 12:27:00'), 'open': 1.08116, 'high': 1.08119, 'low': 1.08111, 'close': 1.08112, 'volume': 168.67999267578125}\n",
            "{'timestamp': Timestamp('2024-02-01 12:26:00'), 'open': 1.08121, 'high': 1.08122, 'low': 1.08116, 'close': 1.08117, 'volume': 314.760009765625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:25:00'), 'open': 1.08108, 'high': 1.08131, 'low': 1.08108, 'close': 1.08122, 'volume': 277.32000732421875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:24:00'), 'open': 1.08122, 'high': 1.08132, 'low': 1.08107, 'close': 1.08109, 'volume': 328.8699951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:23:00'), 'open': 1.08118, 'high': 1.08129, 'low': 1.08117, 'close': 1.08121, 'volume': 426.1099853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:22:00'), 'open': 1.08124, 'high': 1.08128, 'low': 1.08116, 'close': 1.08117, 'volume': 388.7900085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:21:00'), 'open': 1.08123, 'high': 1.08134, 'low': 1.08121, 'close': 1.08123, 'volume': 447.4100036621094}\n",
            "{'timestamp': Timestamp('2024-02-01 12:20:00'), 'open': 1.08167, 'high': 1.08167, 'low': 1.08122, 'close': 1.08122, 'volume': 224.88999938964844}\n",
            "{'timestamp': Timestamp('2024-02-01 12:19:00'), 'open': 1.08143, 'high': 1.0817, 'low': 1.08143, 'close': 1.08168, 'volume': 90.05000305175781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:18:00'), 'open': 1.08117, 'high': 1.08143, 'low': 1.08113, 'close': 1.08143, 'volume': 273.9599914550781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:17:00'), 'open': 1.08108, 'high': 1.08119, 'low': 1.08108, 'close': 1.08117, 'volume': 269.0400085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:16:00'), 'open': 1.08123, 'high': 1.08127, 'low': 1.08106, 'close': 1.08108, 'volume': 401.4700012207031}\n",
            "{'timestamp': Timestamp('2024-02-01 12:15:00'), 'open': 1.08122, 'high': 1.08138, 'low': 1.08118, 'close': 1.08124, 'volume': 482.1799926757813}\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 30 derniers jours"
      ],
      "metadata": {
        "id": "7YxteF4kN32H"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 7 derniers jours.\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Nous parcourons maintenant seulement 7 jours, donc range(7)\n",
        "    for i in range(30, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_30_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 7 derniers jours :\")\n",
        "print(donnees_30_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VwDg9tVROFQK",
        "outputId": "9202db03-19d2-4f5b-b84c-87f6e6fd3e35"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 7 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 7 derniers jours"
      ],
      "metadata": {
        "id": "HeT4Hg1pP0H1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 7 derniers jours.\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Nous parcourons maintenant seulement 7 jours, donc range(7)\n",
        "    for i in range(7, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_7_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 7 derniers jours :\")\n",
        "print(donnees_7_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "C9t40s2GP4PW",
        "outputId": "0aa142c2-ec45-439e-a342-e4be3c7da950"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 7 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 31 derniers jours"
      ],
      "metadata": {
        "id": "Vi2YecL_SBAW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "\n",
        "    for i in range(31, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_31_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 31 derniers jours :\")\n",
        "print(donnees_31_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4mA8CQjNSFQA",
        "outputId": "0d728b04-ab3a-4a02-d7c4-d7364527ffdc"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 31 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-01 22:00:00'), 'open': 1.10427, 'high': 1.10429, 'low': 1.10425, 'close': 1.10429, 'volume': 5.900000095367432}, {'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "12 dernier mois"
      ],
      "metadata": {
        "id": "APxPvhVTT2OZ"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "\n",
        "    for i in range(365, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_365_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 12 derniers mois :\")\n",
        "print(donnees_365_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "hQ1WARdpT6c8",
        "outputId": "778ba183-29d3-405d-b6a8-6c01620da107"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 12 derniers mois :\n",
            "[{'timestamp': Timestamp('2024-01-01 22:00:00'), 'open': 1.10427, 'high': 1.10429, 'low': 1.10425, 'close': 1.10429, 'volume': 5.900000095367432}, {'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# ducoup voici ce que nous récupéront les quoicoupote"
      ],
      "metadata": {
        "id": "m2vVLZQEUW8P"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "donnees_365_derniers_jours_liste\n",
        "donnees_31_derniers_jours_liste\n",
        "donnees_7_derniers_jours_liste\n",
        "donnees_30_derniers_jours_liste\n",
        "donnees_30_dernieres_minutes"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 193
        },
        "id": "G3RqMOdVUbdG",
        "outputId": "d566ad25-4667-42bd-f882-2b5fbbe4ab5a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "name 'donnees_30_derniers_jours' is not defined",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-14-7bb42c6ad7cd>\u001b[0m in \u001b[0;36m<cell line: 4>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mdonnees_31_derniers_jours_liste\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mdonnees_7_derniers_jours_liste\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mdonnees_30_derniers_jours\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0mdonnees_30_dernieres_minutes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'donnees_30_derniers_jours' is not defined"
          ]
        }
      ]
    }
  ]
}
ASSISTANT
The JSON object you've provided seems to represent a Jupyter notebook with several cells including code and markdown text. I'll briefly describe the content and then provide Python code to perform operations related to the project you're describing:

### Notebook Overview
- The markdown cells discuss objectives such as becoming rich, conquering the world, and becoming immortal, mentioning the idea of creating a trading AI for initial liquidity.
- Python code cells include imports for libraries such as `pandas`, `requests`, `subprocess`, and `datetime`.
- There's a markdown cell describing command-line options for a program that appears to download historical trading data.
- Python code cells aim to fetch historical price data from an API, as well as manipulate and retrieve specific records from that data.
- Further cells define functions for extracting specific slices of data based on different time periods like the last 30 minutes, last 30 days, and last 7 days.
- One code cell attempts to fetch data from the FinnHub API but receives an HTML response instead.
- The last code cell refers to variables holding data but it generates a `NameError` because the referenced variables are not found or not defined.

### Example Python Code for Data Aggregation
The data aggregation based on the desired slices of time could be structured as follows:

```python
import pandas as pd

# Assuming you have CSV data already loaded, suppose `donnees_df` is a pandas DataFrame with the data
# For demonstration purposes, let's generate a mock DataFrame
date_rng = pd.date_range(start='1/1/2024', end='31/12/2024', freq='T')  # 'T' for minute frequency
donnees_df = pd.DataFrame(date_rng, columns=['timestamp'])
donnees_df['data'] = pd.np.random.randint(0, 100, size=(len(date_rng)))

# Create different time-based features
donnees_df['minute'] = donnees_df['timestamp'].dt.minute
donnees_df['hour'] = donnees_df['timestamp'].dt.hour
donnees_df['day'] = donnees_df['timestamp'].dt.day
donnees_df['month'] = donnees_df['timestamp'].dt.month
donnees_df['day_of_week'] = donnees_df['timestamp'].dt.dayofweek  # Monday=0, Sunday=6

# Filter to the last 30 minutes
last_30_minutes = donnees_df[donnees_df['timestamp'] >= (donnees_df['timestamp'].max() - pd.Timedelta(minutes=30))]

# Filter to the last 30 days - assume we want the data from the same minute in the last 30 days
current_minute = donnees_df['timestamp'].max().minute
last_30_days_same_minute = donnees_df[(donnees_df['minute'] == current_minute) & (donnees_df['timestamp'] >= (donnees_df['timestamp'].max() - pd.Timedelta(days=30)))]

# Filter to the last 7 days with hourly aggregation
last_7_days_hourly = donnees_df[(donnees_df['timestamp'] >= (donnees_df['timestamp'].max() - pd.Timedelta(days=7)))].groupby(['day', 'hour']).mean().reset_index()

# Assuming the 'data' column is some metric like price, volume, etc., you can perform various aggregations on these filters.
print(last_30_minutes.head())  # Shows the last 30 minutes data
print(last_30_days_same_minute.head())  # Shows the last 30 days data for the same minute each day
print(last_7_days_hourly.head())  # Shows the last 7 days aggregated by hour

# You can further convert these data slices into feature vectors as needed for the AI model.

# Note: Replace the mock data with your actual CSV data and adjust the column names (like 'data') to match your dataset.
```
This code is a starting point for creating time-based features and slicing the data according to the requirements mentioned in the notebook. It assumes you will feed the actual CSV data into the `donnees_df` DataFrame. The variables at the end of the notebook appear to be incorrectly named, you should verify their names or replace them with the appropriate DataFrame name.

You'll need to define the logic for aggregating the last 30 days and 12 months data features by considering what summary statistics make the most sense for each time slice (e.g., mean, max, min). The data for the days of the week and the months of the year can be one-hot encoded or represented in other ways as per the model requirements.

Remember that when using the financial data for modeling, you should always adhere to legal and ethical requirements, and the use of financial or market data for automated trading could have legal implications you should be aware of.

turns-00017.parquet:57734

15b3d709cb1b29f77444fa9e
turn 1/1gpt-4-1106-previewEnglishFrance5411 words
degenerate_repetitionAbsentFinal dense release
USER
opptimise ce code google colab ipynb en évitant les répition de fonction par exemple et en faisant que ce sois le plus clair possible a lire voici le code :

{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "### Bienvenue dans mon projet pour conquerir le monde\n",
        "\n",
        "\n",
        "---Nos objectif \\\n",
        "Devenir riche \\\n",
        "Conquerire le monde \\\n",
        "Devenir immortel \\\n",
        "\n",
        "---Plan \\\n",
        "créé un ia de trading pour avoir les première liquidité \\\n",
        "la revendre\n",
        "\n",
        "\n",
        "--- Ce qui nous empèche de conquèrir le monde : \\\n",
        "les heures d'hiver et d'automne0"
      ],
      "metadata": {
        "id": "qnQm2vcsgDsv"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "import requests\n",
        "import re\n",
        "import subprocess\n",
        "from datetime import datetime, timedelta\n",
        "from pathlib import Path\n"
      ],
      "metadata": {
        "id": "zOseKr_vSvoa"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "| Option | Alias | Default | Description |\n",
        "| ------ | ----- | ----- | ----- |\n",
        "| --instrument | -i |  | Trading instrument id. View list |\n",
        "| --date-from | -from |  | From date (yyyy-mm-dd) |\n",
        "| --date-to | -to | now | To date (yyyy-mm-dd or 'now') |\n",
        "| --timeframe | -t | d1 | Timeframe aggregation (tick, s1, m1, m5, m15, m30, h1, h4, d1, mn1) |\n",
        "| --price-type | -p | bid | Price type: (bid, ask) |\n",
        "| --utc-offset | -utc | 0 | UTC offset in minutes |\n",
        "| --volumes | -v | false | Include volumes |\n",
        "| --volume-units | -vu | millions | Volume units (millions, thousands, units) |\n",
        "| --flats | -fl | false | Include flats (0 volumes) |\n",
        "| --format | -f | json | Output format (csv, json, array). View output examples |\n",
        "| --directory | -dir | ./download | Download directory |\n",
        "| --batch-size | -bs | 10 | Batch size of downloaded artifacts |\n",
        "| --batch-pause | -bp | 1000 | Pause between batches in ms |\n",
        "| --cache | -ch | false | Use cache |\n",
        "| --cache-path | -chpath | ./dukascopy-cache | Folder path for cache data |\n",
        "| --retries | -r | 0 | Number of retries for a failed artifact download |\n",
        "| --retry-on-empty | -re | false | A flag indicating whether requests with successful but empty (0 Bytes) responses should be retried. If retries is 0, this parameter will be ignored |\n",
        "| --no-fail-after-retries | -fr | false | A flag indicating whether the process should fail after all retries have been exhausted. If retries is 0, this parameter will be ignored |\n",
        "| --retry-pause | -rp | 500 | Pause between retries in milliseconds |\n",
        "| --debug | -d | false | Output extra debugging |\n",
        "| --silent | -s | false | Hides the search config in the CLI output |\n",
        "| --inline | -in | false | Makes files smaller in size by removing new lines in the output (works only with json and array formats) |\n",
        "| --file-name | -fn |  | Custom file name for the generated file |\n",
        "| --help | -h |  | display help for command |"
      ],
      "metadata": {
        "id": "F7iDYaeVQYh1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "# Paramètres de la commande\n",
        "instrument = \"eurusd\"\n",
        "type_de_donnees = \"m1\"\n",
        "format_fichier = \"csv\"\n",
        "debut = pd.Timestamp(2024, 1, 1)\n",
        "fin = pd.Timestamp(2024, 2, 13)\n",
        "\n",
        "# Générer le chemin du répertoire de contenu et construire la commande\n",
        "content_dir = Path(\"/content\")\n",
        "commande = f\"npx dukascopy-node -i {instrument} -from {debut:%Y-%m-%d} -to {fin:%Y-%m-%d} -v {True} -t {type_de_donnees} -f {format_fichier}\"\n",
        "\n",
        "# Exécution de la commande et capture de la sortie\n",
        "try:\n",
        "    resultat = subprocess.run(commande, shell=True, check=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, text=True)\n",
        "    sortie_commande = resultat.stdout\n",
        "    print(sortie_commande)\n",
        "\n",
        "    # Extraction du nom du fichier CSV et traitement des données\n",
        "    match = re.search(r\"File saved: (\\S+)\", sortie_commande)\n",
        "    if match:\n",
        "        chemin_fichier_csv = match.group(1)\n",
        "        chemin_fichier_csv = content_dir / chemin_fichier_csv  # Avec pathlib, nous assurons l’uniformité du chemin\n",
        "        print(\"Chemin du fichier CSV:\", chemin_fichier_csv)\n",
        "\n",
        "        # Lecture et traitement du fichier CSV\n",
        "        try:\n",
        "            donnees = pd.read_csv(chemin_fichier_csv)\n",
        "            donnees['timestamp'] = pd.to_datetime(donnees['timestamp'], unit='ms').dt.strftime('%Y-%m-%d %H:%M')\n",
        "            donnees = donnees.rename(columns={'timestamp': 'timestamp'})\n",
        "            donnees.to_csv(chemin_fichier_csv, index=False)\n",
        "            print(f\"Le fichier CSV a été mis à jour avec les timestamps formatés : {chemin_fichier_csv}\")\n",
        "            print(donnees.head())\n",
        "        except Exception as e:\n",
        "            print(\"Erreur lors de la lecture ou de la conversion du fichier CSV:\", e)\n",
        "    else:\n",
        "        print(\"Le nom du fichier n’a pas pu être extrait.\")\n",
        "except subprocess.CalledProcessError as e:\n",
        "    print(\"Erreur lors de l’exécution de la commande:\", e)\n"
      ],
      "metadata": {
        "id": "9f05Bp4AslcA",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "62390ad0-8f52-4e70-ad36-d8dd23e6f55e"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "npx: installed 30 in 7.213s\n",
            "----------------------------------------------------\n",
            "Downloading historical price data for:\n",
            "----------------------------------------------------\n",
            "Instrument:     Euro vs US Dollar\n",
            "Timeframe:      m1\n",
            "From date:      Jan 1, 2024, 12:00 AM\n",
            "To date:        Feb 13, 2024, 12:00 AM\n",
            "Price type:     bid\n",
            "Volumes:        true\n",
            "UTC Offset:     0\n",
            "Include flats:  false\n",
            "Format:         csv\n",
            "----------------------------------------------------\n",
            "----------------------------------------------------\n",
            "√ File saved: download/eurusd-m1-bid-2024-01-01-2024-02-13.csv (2.6 MB)\n",
            "\n",
            "Download time: 14.9s\n",
            "\n",
            "\n",
            "Chemin du fichier CSV: /content/download/eurusd-m1-bid-2024-01-01-2024-02-13.csv\n",
            "Le fichier CSV a été mis à jour avec les timestamps formatés : /content/download/eurusd-m1-bid-2024-01-01-2024-02-13.csv\n",
            "          timestamp     open     high      low    close  volume\n",
            "0  2024-01-01 22:00  1.10427  1.10429  1.10425  1.10429     5.9\n",
            "1  2024-01-01 22:01  1.10429  1.10429  1.10429  1.10429     8.1\n",
            "2  2024-01-01 22:02  1.10429  1.10429  1.10429  1.10429     9.9\n",
            "3  2024-01-01 22:03  1.10429  1.10429  1.10426  1.10426    18.9\n",
            "4  2024-01-01 22:04  1.10426  1.10431  1.10424  1.10425    18.0\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        # Chargement du fichier CSV dans un DataFrame pandas\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "\n",
        "        # Assurer que la colonne 'timestamp' est au bon format de date-heure\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "\n",
        "        # Formatage de la date-heure de la requête pour correspondre au format du DataFrame\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "\n",
        "        # Filtrer pour obtenir les données de la minute spécifiée\n",
        "        info_minute = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(minutes=1))\n",
        "        ]\n",
        "\n",
        "        # Vérifier si des données ont été trouvées et les retourner\n",
        "        if not info_minute.empty:\n",
        "            # On utilise iloc[0] pour obtenir le premier enregistrement correspondant\n",
        "            return info_minute.iloc[0].to_dict()\n",
        "        else:\n",
        "            # Aucune donnée correspondante n’a été trouvée\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n"
      ],
      "metadata": {
        "id": "ZiyMguNXIv5M"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "\n",
        "date_heure_str = \"2024-01-05 11:59\"\n",
        "\n",
        "# Utilisation de la fonction pour récupérer les informations\n",
        "informations = Data(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage des informations récupérées\n",
        "if informations:\n",
        "    print(f\"Informations pour {date_heure_str}:\")\n",
        "    print(f\"Open: {informations['open']}\")\n",
        "    print(f\"High: {informations['high']}\")\n",
        "    print(f\"Low: {informations['low']}\")\n",
        "    print(f\"Close: {informations['close']}\")\n",
        "    print(f\"Volume: {informations['volume']}\")\n",
        "else:\n",
        "    print(\"Aucune information trouvée pour la minute spécifiée.\")\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "MsTWF5PjI5_Z",
        "outputId": "54d8af17-5876-4929-bce6-84a1af418ece"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Informations pour 2024-01-05 11:59:\n",
            "Open: 1.09132\n",
            "High: 1.09143\n",
            "Low: 1.09132\n",
            "Close: 1.09142\n",
            "Volume: 104.55999755859376\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "api_key = 'cnguep9r01qhlsli99igcnguep9r01qhlsli99j0'\n",
        "symbol = 'EUR/USD'\n",
        "interval = '1min'\n",
        "count = 10\n",
        "\n",
        "url = f'https://finnhub.io/api/v1/forex/candles?symbol={symbol}&resolution={interval}&count={count}'\n",
        "headers = {'X-Finnhub-Token': api_key}\n",
        "\n",
        "response = requests.get(url, headers=headers)\n",
        "\n",
        "# Imprimez la réponse brute de l'API\n",
        "print(response.text)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "Nk5vmJ1icz_T",
        "outputId": "3d272585-e3c1-4ca7-b736-323660248f5a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "<!DOCTYPE html>\n",
            "<html lang=\"en\">\n",
            "<head>\n",
            "    <meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n",
            "    <meta name=\"author\" content=\"Finnhub.io\"/>\n",
            "\n",
            "    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, maximum-scale=5\">\n",
            "    <link rel=\"shortcut icon\"\n",
            "          href=\"/static/img/webp/finnhub-logo.webp\"/>\n",
            "\n",
            "    \n",
            "    <script async src=\"https://www.googletagmanager.com/gtag/js?id=UA-64068110-3\"></script>\n",
            "    <script>\n",
            "      window.dataLayer = window.dataLayer || [];\n",
            "\n",
            "      function gtag() {\n",
            "        dataLayer.push(arguments);\n",
            "      }\n",
            "\n",
            "      gtag('js', new Date());\n",
            "\n",
            "      gtag('config', 'UA-64068110-3');\n",
            "    </script>\n",
            "\n",
            "    <link rel=\"stylesheet\" href=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css\">\n",
            "\n",
            "    <script src=\"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js\"></script>\n",
            "    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery-easing/1.3/jquery.easing.min.js'></script>\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js\"></script>\n",
            "    <script src=\"https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js\"></script>\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/react/16.8.0/umd/react.production.min.js\"></script>\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.8.0/umd/react-dom.production.min.js\"></script>\n",
            "\n",
            "    <link rel=\"stylesheet\" href=\"https://use.fontawesome.com/releases/v6.0.0/css/all.css\">\n",
            "\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js\"></script>\n",
            "    <script src=\"https://cdnjs.cloudflare.com/ajax/libs/redux/3.3.1/redux.min.js\"></script>\n",
            "    <script src=\"https://unpkg.com/react-redux@5.0.7/dist/react-redux.min.js\"></script>\n",
            "    <script type=\"text/javascript\">\n",
            "\n",
            "      var protocol = location.protocol;\n",
            "      var wsprotocol\n",
            "      if (protocol === \"https:\") {\n",
            "        wsprotocol = \"wss:\";\n",
            "      } else {\n",
            "        wsprotocol = \"ws:\";\n",
            "      }\n",
            "      var slashes = protocol.concat(\"//\");\n",
            "      var host = slashes.concat(window.location.host);\n",
            "\n",
            "      window.wsUrl = \"\"\n",
            "      if (window.wsUrl === '') {\n",
            "        window.wsUrl = window.location.host\n",
            "      }\n",
            "\n",
            "      window.getCookie = function getcookie(cname) {\n",
            "        var name = cname + \"=\";\n",
            "        var decodedCookie = decodeURIComponent(document.cookie);\n",
            "        var ca = decodedCookie.split(';');\n",
            "        for (var i = 0; i < ca.length; i++) {\n",
            "          var c = ca[i];\n",
            "          while (c.charAt(0) == ' ') {\n",
            "            c = c.substring(1);\n",
            "          }\n",
            "          if (c.indexOf(name) == 0) {\n",
            "            return c.substring(name.length, c.length);\n",
            "          }\n",
            "        }\n",
            "        return \"\";\n",
            "      }\n",
            "\n",
            "      window.setCookie = function setcookie(cname, cvalue, exdays) {\n",
            "        var d = new Date();\n",
            "        d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));\n",
            "        var expires = \"expires=\" + d.toUTCString();\n",
            "        document.cookie = cname + \"=\" + cvalue + \";\" + expires + \";path=/\";\n",
            "      }\n",
            "\n",
            "      window.toTitle = function toTitleCase(str) {\n",
            "        return str.replace(/\\w\\S*/g, function (txt) {\n",
            "          return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();\n",
            "        });\n",
            "      }\n",
            "\n",
            "      window.getUrlParams = function (key) {\n",
            "        let url = location.href\n",
            "        var params = {};\n",
            "        (url + '?').split('?')[1].split('&').forEach(function (pair) {\n",
            "          pair = (pair + '=').split('=').map(decodeURIComponent);\n",
            "          if (pair[0].length) {\n",
            "            params[pair[0]] = pair[1];\n",
            "          }\n",
            "        });\n",
            "        return params[key];\n",
            "      };\n",
            "\n",
            "      window.stripHtml = function (html) {\n",
            "        let tmp = document.createElement(\"DIV\");\n",
            "        tmp.innerHTML = html;\n",
            "        return tmp.textContent || tmp.innerText || \"\";\n",
            "      }\n",
            "\n",
            "      window.timeConverter = function tConverter(UNIX_timestamp) {\n",
            "        var a = new Date(UNIX_timestamp * 1000);\n",
            "        var months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];\n",
            "        var dates = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']\n",
            "        var month = months[a.getMonth()];\n",
            "        var date = a.getDate();\n",
            "        var time = dates[a.getDay()] + ' ' + month + ' ' + date\n",
            "        return time;\n",
            "      }\n",
            "\n",
            "      window.roundToX = function (num, X) {\n",
            "        return +(Math.round(num + \"e+\" + X) + \"e-\" + X);\n",
            "      }\n",
            "    </script>\n",
            "\n",
            "\n",
            "    <meta name=\"description\"\n",
            "      content=\"Finnhub - Free stock API for realtime market data, global company fundamentals, economic data, and alternative data.\"/>\n",
            "<meta name=\"keywords\"\n",
            "      content=\"stock api,realtime,stock,equity,forex,crypto,fundamental data,economic data,alternative data\">\n",
            "<meta property=\"og:title\" content=\"Finnhub - Free realtime APIs for stock, forex and cryptocurrency.\">\n",
            "<meta property=\"og:type\" content=\"website\">\n",
            "<meta property=\"og:url\" content=\"https://finnhub.io/\">\n",
            "<meta property=\"og:image\"\n",
            "      content=\"https://static.finnhub.io/img/finnhub_2020-05-09_20_51/logo/logo-transparent-thumbnail.png\">\n",
            "<meta property=\"og:description\"\n",
            "      content=\"Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, Economic data, and Alternative data.\">\n",
            "<meta name=\"twitter:card\" content=\"summary\">\n",
            "<meta name=\"twitter:title\"\n",
            "      content=\"Finnhub - Free realtime APIs for stock, forex and cryptocurrency.\">\n",
            "<meta name=\"twitter:image\"\n",
            "      content=\"https://static.finnhub.io/img/finnhub_2020-05-09_20_51/logo/logo-transparent-thumbnail.png\">\n",
            "<meta name=\"twitter:description\"\n",
            "      content=\"Finnhub - Free APIs for realtime stock, forex, and cryptocurrency. Company fundamentals, Economic data, and Alternative data.\">\n",
            "<meta charset=\"UTF-8\">\n",
            "\n",
            "    <title>Finnhub Stock APIs - Real-time stock prices, Company fundamentals, Estimates, and Alternative data.</title>\n",
            "\n",
            "    <script type=\"text/javascript\">\n",
            "      window.serverData = {\"announcement\":\"Global Filings Search is now available on Finnhub. Check out \\u003ca href=\\\"/docs/api/global-filings-search\\\"\\u003ehere\\u003c/a\\u003e\"}\n",
            "      window.login =  false \n",
            "      window.isSubscribe = null \n",
            "    </script>\n",
            "</head>\n",
            "<body>\n",
            "<div id=\"root\"></div>\n",
            "<script type=\"text/javascript\" src=\"/static/js/webpack/dist/main-index.bundle.357882d13b93982f42b7.js\"></script></body>\n",
            "</html>\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Après le fichier\n",
        "\n",
        "Maintenant que l'on a récupéré ce petit csv de merde\n",
        "- 30 dernière minute : open + high + low  + volume = 150 (on commence de la plus recent a la plus ancienne)\n",
        "- 30 dernière : pareil = 150\n",
        "- 30 dernier jours : pareil = 150\n",
        "- 7 jour de la semaine = 7 (de lundi a dimanche)\n",
        "- 31 jour du mois = 31\n",
        "- 12 mois de l'anéee = 12\n"
      ],
      "metadata": {
        "id": "eOP-2yDs6cBk"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "# Liste pour les 30 derniers minutes"
      ],
      "metadata": {
        "id": "76Amy6xU7YuB"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée dans la question initiale.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        # Chargement du fichier CSV dans un DataFrame pandas.\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "\n",
        "        # Assurer que la colonne timestamp est au bon format de date-heure.\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "\n",
        "        # Formatage de la date-heure de la requête pour correspondre au format du DataFrame.\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "\n",
        "        # Filtrer pour obtenir les données de la minute spécifiée.\n",
        "        info_minute = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(minutes=1))\n",
        "        ]\n",
        "\n",
        "        # Vérifier si des données ont été trouvées et les retourner.\n",
        "        if not info_minute.empty:\n",
        "            # On utilise iloc[0] pour obtenir le premier enregistrement correspondant.\n",
        "            return info_minute.iloc[0].to_dict()\n",
        "        else:\n",
        "            # Aucune donnée correspondante n’a été trouvée.\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 30 dernières minutes.\n",
        "def liste_donnees_30min(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    # Convertir la date_heure_str en objet datetime.\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Boucle pour récupérer les données minute par minute de la plus récente à la plus vieille.\n",
        "    for i in range(31):\n",
        "        # Le point de départ pour chaque minute.\n",
        "        minute_debut = date_heure_finale - pd.Timedelta(minutes=i)\n",
        "        # Convertir en chaîne de caractères ISO pour l’appel de fonction.\n",
        "        minute_debut_str = minute_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        # Utiliser la fonction Data pour obtenir les données.\n",
        "        donnee_minute = Data(chemin_fichier_csv, minute_debut_str)\n",
        "        # Si des données sont trouvées, les ajouter à la liste.\n",
        "        if donnee_minute:\n",
        "            liste_donnees.append(donnee_minute)\n",
        "\n",
        "    # Renvoyer la liste complète des données des 30 dernières minutes.\n",
        "    return liste_donnees\n",
        "\n",
        "# Exemple d’utilisation.\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure au format correspondant à vos données.\n",
        "\n",
        "# Appel de la fonction.\n",
        "donnees_30_dernieres_minutes = liste_donnees_30min(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage des résultats.\n",
        "for donnee in donnees_30_dernieres_minutes:\n",
        "    print(donnee)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "nFmUPW6NN00u",
        "outputId": "5b1ab0c1-502d-4dff-9d43-ccf20d822d23"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "{'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:44:00'), 'open': 1.08143, 'high': 1.08178, 'low': 1.08142, 'close': 1.08178, 'volume': 524.3599853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:43:00'), 'open': 1.08143, 'high': 1.0815, 'low': 1.08139, 'close': 1.08142, 'volume': 476.7699890136719}\n",
            "{'timestamp': Timestamp('2024-02-01 12:42:00'), 'open': 1.08155, 'high': 1.08157, 'low': 1.08142, 'close': 1.08145, 'volume': 553.02001953125}\n",
            "{'timestamp': Timestamp('2024-02-01 12:41:00'), 'open': 1.08146, 'high': 1.08152, 'low': 1.08141, 'close': 1.08151, 'volume': 171.00999450683594}\n",
            "{'timestamp': Timestamp('2024-02-01 12:40:00'), 'open': 1.0813, 'high': 1.08147, 'low': 1.08125, 'close': 1.08147, 'volume': 460.5700073242188}\n",
            "{'timestamp': Timestamp('2024-02-01 12:39:00'), 'open': 1.08118, 'high': 1.08131, 'low': 1.08116, 'close': 1.08131, 'volume': 339.1099853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:38:00'), 'open': 1.08107, 'high': 1.08118, 'low': 1.08107, 'close': 1.08117, 'volume': 337.29998779296875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:37:00'), 'open': 1.08111, 'high': 1.08126, 'low': 1.08106, 'close': 1.08106, 'volume': 223.5}\n",
            "{'timestamp': Timestamp('2024-02-01 12:36:00'), 'open': 1.08101, 'high': 1.08117, 'low': 1.081, 'close': 1.08111, 'volume': 184.509994506836}\n",
            "{'timestamp': Timestamp('2024-02-01 12:35:00'), 'open': 1.08092, 'high': 1.08104, 'low': 1.08078, 'close': 1.08104, 'volume': 401.8900146484375}\n",
            "{'timestamp': Timestamp('2024-02-01 12:34:00'), 'open': 1.08102, 'high': 1.08106, 'low': 1.08093, 'close': 1.08093, 'volume': 187.9900054931641}\n",
            "{'timestamp': Timestamp('2024-02-01 12:33:00'), 'open': 1.08118, 'high': 1.08119, 'low': 1.08096, 'close': 1.08102, 'volume': 492.9599914550781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:32:00'), 'open': 1.08124, 'high': 1.08126, 'low': 1.08097, 'close': 1.08117, 'volume': 396.239990234375}\n",
            "{'timestamp': Timestamp('2024-02-01 12:31:00'), 'open': 1.08153, 'high': 1.08155, 'low': 1.08122, 'close': 1.08123, 'volume': 237.1199951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:30:00'), 'open': 1.08145, 'high': 1.08159, 'low': 1.08144, 'close': 1.08153, 'volume': 235.19000244140625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:29:00'), 'open': 1.08128, 'high': 1.08144, 'low': 1.08126, 'close': 1.08144, 'volume': 298.2900085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:28:00'), 'open': 1.08111, 'high': 1.0813, 'low': 1.08109, 'close': 1.08128, 'volume': 151.35000610351562}\n",
            "{'timestamp': Timestamp('2024-02-01 12:27:00'), 'open': 1.08116, 'high': 1.08119, 'low': 1.08111, 'close': 1.08112, 'volume': 168.67999267578125}\n",
            "{'timestamp': Timestamp('2024-02-01 12:26:00'), 'open': 1.08121, 'high': 1.08122, 'low': 1.08116, 'close': 1.08117, 'volume': 314.760009765625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:25:00'), 'open': 1.08108, 'high': 1.08131, 'low': 1.08108, 'close': 1.08122, 'volume': 277.32000732421875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:24:00'), 'open': 1.08122, 'high': 1.08132, 'low': 1.08107, 'close': 1.08109, 'volume': 328.8699951171875}\n",
            "{'timestamp': Timestamp('2024-02-01 12:23:00'), 'open': 1.08118, 'high': 1.08129, 'low': 1.08117, 'close': 1.08121, 'volume': 426.1099853515625}\n",
            "{'timestamp': Timestamp('2024-02-01 12:22:00'), 'open': 1.08124, 'high': 1.08128, 'low': 1.08116, 'close': 1.08117, 'volume': 388.7900085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:21:00'), 'open': 1.08123, 'high': 1.08134, 'low': 1.08121, 'close': 1.08123, 'volume': 447.4100036621094}\n",
            "{'timestamp': Timestamp('2024-02-01 12:20:00'), 'open': 1.08167, 'high': 1.08167, 'low': 1.08122, 'close': 1.08122, 'volume': 224.88999938964844}\n",
            "{'timestamp': Timestamp('2024-02-01 12:19:00'), 'open': 1.08143, 'high': 1.0817, 'low': 1.08143, 'close': 1.08168, 'volume': 90.05000305175781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:18:00'), 'open': 1.08117, 'high': 1.08143, 'low': 1.08113, 'close': 1.08143, 'volume': 273.9599914550781}\n",
            "{'timestamp': Timestamp('2024-02-01 12:17:00'), 'open': 1.08108, 'high': 1.08119, 'low': 1.08108, 'close': 1.08117, 'volume': 269.0400085449219}\n",
            "{'timestamp': Timestamp('2024-02-01 12:16:00'), 'open': 1.08123, 'high': 1.08127, 'low': 1.08106, 'close': 1.08108, 'volume': 401.4700012207031}\n",
            "{'timestamp': Timestamp('2024-02-01 12:15:00'), 'open': 1.08122, 'high': 1.08138, 'low': 1.08118, 'close': 1.08124, 'volume': 482.1799926757813}\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 30 derniers jours"
      ],
      "metadata": {
        "id": "7YxteF4kN32H"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 7 derniers jours.\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Nous parcourons maintenant seulement 7 jours, donc range(7)\n",
        "    for i in range(30, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_30_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 7 derniers jours :\")\n",
        "print(donnees_30_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "VwDg9tVROFQK",
        "outputId": "9202db03-19d2-4f5b-b84c-87f6e6fd3e35"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 7 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 7 derniers jours"
      ],
      "metadata": {
        "id": "HeT4Hg1pP0H1"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "# Fonction pour lister les données sur les 7 derniers jours.\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "    # Nous parcourons maintenant seulement 7 jours, donc range(7)\n",
        "    for i in range(7, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_7_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 7 derniers jours :\")\n",
        "print(donnees_7_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "C9t40s2GP4PW",
        "outputId": "0aa142c2-ec45-439e-a342-e4be3c7da950"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 7 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# 31 derniers jours"
      ],
      "metadata": {
        "id": "Vi2YecL_SBAW"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "\n",
        "    for i in range(31, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_31_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 31 derniers jours :\")\n",
        "print(donnees_31_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "4mA8CQjNSFQA",
        "outputId": "0d728b04-ab3a-4a02-d7c4-d7364527ffdc"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 31 derniers jours :\n",
            "[{'timestamp': Timestamp('2024-01-01 22:00:00'), 'open': 1.10427, 'high': 1.10429, 'low': 1.10425, 'close': 1.10429, 'volume': 5.900000095367432}, {'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "12 dernier mois"
      ],
      "metadata": {
        "id": "APxPvhVTT2OZ"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "import pandas as pd\n",
        "\n",
        "# Fonction Data donnée.\n",
        "def Data(chemin_fichier_csv, date_heure_str):\n",
        "    try:\n",
        "        donnees = pd.read_csv(chemin_fichier_csv)\n",
        "        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])\n",
        "        date_heure_requise = pd.to_datetime(date_heure_str)\n",
        "        info_jour = donnees[\n",
        "            (donnees['timestamp'] >= date_heure_requise) &\n",
        "            (donnees['timestamp'] < date_heure_requise + pd.Timedelta(days=1))\n",
        "        ]\n",
        "        if not info_jour.empty:\n",
        "            return info_jour.iloc[0].to_dict()\n",
        "        else:\n",
        "            return None\n",
        "    except Exception as e:\n",
        "        print(f\"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}\")\n",
        "        return None\n",
        "\n",
        "\n",
        "def liste_donnees_7jours(chemin_fichier_csv, date_heure_str):\n",
        "    liste_donnees = []\n",
        "    date_heure_finale = pd.to_datetime(date_heure_str)\n",
        "\n",
        "\n",
        "    for i in range(365, -1, -1):\n",
        "        jour_debut = date_heure_finale - pd.Timedelta(days=i)\n",
        "        jour_debut_str = jour_debut.strftime('%Y-%m-%d %H:%M:%S')\n",
        "        donnee_jour = Data(chemin_fichier_csv, jour_debut_str)\n",
        "        if donnee_jour:\n",
        "            liste_donnees.append(donnee_jour)\n",
        "\n",
        "    return liste_donnees\n",
        "\n",
        "\n",
        "date_heure_str = \"2024-02-01 12:45:00\"  # Ajustez cette date-heure.\n",
        "\n",
        "donnees_365_derniers_jours_liste = liste_donnees_7jours(chemin_fichier_csv, date_heure_str)\n",
        "\n",
        "# Affichage de la liste finale contenant toutes les données.\n",
        "print(\"Liste des données des 12 derniers mois :\")\n",
        "print(donnees_365_derniers_jours_liste)\n"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "hQ1WARdpT6c8",
        "outputId": "778ba183-29d3-405d-b6a8-6c01620da107"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Liste des données des 12 derniers mois :\n",
            "[{'timestamp': Timestamp('2024-01-01 22:00:00'), 'open': 1.10427, 'high': 1.10429, 'low': 1.10425, 'close': 1.10429, 'volume': 5.900000095367432}, {'timestamp': Timestamp('2024-01-02 12:45:00'), 'open': 1.09608, 'high': 1.09619, 'low': 1.09607, 'close': 1.09615, 'volume': 192.1300048828125}, {'timestamp': Timestamp('2024-01-03 12:45:00'), 'open': 1.09205, 'high': 1.09217, 'low': 1.09192, 'close': 1.09208, 'volume': 380.6900024414063}, {'timestamp': Timestamp('2024-01-04 12:45:00'), 'open': 1.0955, 'high': 1.0955, 'low': 1.0952, 'close': 1.09534, 'volume': 107.33999633789062}, {'timestamp': Timestamp('2024-01-05 12:45:00'), 'open': 1.09184, 'high': 1.09196, 'low': 1.09182, 'close': 1.09195, 'volume': 105.77999877929688}, {'timestamp': Timestamp('2024-01-07 22:04:00'), 'open': 1.09386, 'high': 1.0939, 'low': 1.09376, 'close': 1.0939, 'volume': 28.600000381469727}, {'timestamp': Timestamp('2024-01-08 12:45:00'), 'open': 1.0942, 'high': 1.09436, 'low': 1.0942, 'close': 1.0943, 'volume': 109.26000213623048}, {'timestamp': Timestamp('2024-01-09 12:45:00'), 'open': 1.09324, 'high': 1.09341, 'low': 1.09319, 'close': 1.09338, 'volume': 175.22999572753906}, {'timestamp': Timestamp('2024-01-10 12:45:00'), 'open': 1.09447, 'high': 1.09448, 'low': 1.09439, 'close': 1.09442, 'volume': 248.8500061035156}, {'timestamp': Timestamp('2024-01-11 12:45:00'), 'open': 1.09844, 'high': 1.09862, 'low': 1.09841, 'close': 1.0986, 'volume': 214.6000061035156}, {'timestamp': Timestamp('2024-01-12 12:45:00'), 'open': 1.09432, 'high': 1.09432, 'low': 1.09412, 'close': 1.09416, 'volume': 160.11000061035156}, {'timestamp': Timestamp('2024-01-14 22:00:00'), 'open': 1.0948, 'high': 1.09484, 'low': 1.09476, 'close': 1.09476, 'volume': 10.399999618530272}, {'timestamp': Timestamp('2024-01-15 12:45:00'), 'open': 1.09546, 'high': 1.0956, 'low': 1.09541, 'close': 1.09541, 'volume': 139.64999389648438}, {'timestamp': Timestamp('2024-01-16 12:45:00'), 'open': 1.0885, 'high': 1.08852, 'low': 1.08844, 'close': 1.08846, 'volume': 153.57000732421875}, {'timestamp': Timestamp('2024-01-17 12:45:00'), 'open': 1.0872, 'high': 1.0872, 'low': 1.0871, 'close': 1.08715, 'volume': 216.75}, {'timestamp': Timestamp('2024-01-18 12:45:00'), 'open': 1.08786, 'high': 1.08798, 'low': 1.08786, 'close': 1.08798, 'volume': 135.25999450683594}, {'timestamp': Timestamp('2024-01-19 12:45:00'), 'open': 1.08825, 'high': 1.08825, 'low': 1.08815, 'close': 1.08816, 'volume': 176.00999450683594}, {'timestamp': Timestamp('2024-01-21 22:00:00'), 'open': 1.08906, 'high': 1.08918, 'low': 1.08905, 'close': 1.08909, 'volume': 5.5}, {'timestamp': Timestamp('2024-01-22 12:45:00'), 'open': 1.08977, 'high': 1.08981, 'low': 1.08958, 'close': 1.08962, 'volume': 271.3900146484375}, {'timestamp': Timestamp('2024-01-23 12:45:00'), 'open': 1.08625, 'high': 1.08627, 'low': 1.08616, 'close': 1.08621, 'volume': 221.3300018310547}, {'timestamp': Timestamp('2024-01-24 12:45:00'), 'open': 1.08952, 'high': 1.08956, 'low': 1.0895, 'close': 1.08954, 'volume': 150.52999877929688}, {'timestamp': Timestamp('2024-01-25 12:45:00'), 'open': 1.08919, 'high': 1.08925, 'low': 1.08919, 'close': 1.08921, 'volume': 94.7699966430664}, {'timestamp': Timestamp('2024-01-26 12:45:00'), 'open': 1.08699, 'high': 1.08717, 'low': 1.08693, 'close': 1.08716, 'volume': 134.00999450683594}, {'timestamp': Timestamp('2024-01-28 22:00:00'), 'open': 1.08468, 'high': 1.08484, 'low': 1.08428, 'close': 1.0843, 'volume': 28.0}, {'timestamp': Timestamp('2024-01-29 12:45:00'), 'open': 1.08352, 'high': 1.08364, 'low': 1.08352, 'close': 1.08358, 'volume': 98.5199966430664}, {'timestamp': Timestamp('2024-01-30 12:45:00'), 'open': 1.08428, 'high': 1.08439, 'low': 1.08425, 'close': 1.08439, 'volume': 47.70000076293945}, {'timestamp': Timestamp('2024-01-31 12:45:00'), 'open': 1.08375, 'high': 1.08379, 'low': 1.08366, 'close': 1.08376, 'volume': 199.2100067138672}, {'timestamp': Timestamp('2024-02-01 12:45:00'), 'open': 1.08178, 'high': 1.08184, 'low': 1.08173, 'close': 1.08174, 'volume': 240.8699951171875}]\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "# ducoup voici ce que nous récupéront les quoicoupote"
      ],
      "metadata": {
        "id": "m2vVLZQEUW8P"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "donnees_365_derniers_jours_liste\n",
        "donnees_31_derniers_jours_liste\n",
        "donnees_7_derniers_jours_liste\n",
        "donnees_30_derniers_jours_liste\n",
        "donnees_30_dernieres_minutes"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/",
          "height": 193
        },
        "id": "G3RqMOdVUbdG",
        "outputId": "d566ad25-4667-42bd-f882-2b5fbbe4ab5a"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "error",
          "ename": "NameError",
          "evalue": "name 'donnees_30_derniers_jours' is not defined",
          "traceback": [
            "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
            "\u001b[0;31mNameError\u001b[0m                                 Traceback (most recent call last)",
            "\u001b[0;32m<ipython-input-14-7bb42c6ad7cd>\u001b[0m in \u001b[0;36m<cell line: 4>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mdonnees_31_derniers_jours_liste\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m \u001b[0mdonnees_7_derniers_jours_liste\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 4\u001b[0;31m \u001b[0mdonnees_30_derniers_jours\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      5\u001b[0m \u001b[0mdonnees_30_dernieres_minutes\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
            "\u001b[0;31mNameError\u001b[0m: name 'donnees_30_derniers_jours' is not defined"
          ]
        }
      ]
    }
  ]
}
ASSISTANT
Votre notebook contient plusieurs morceaux de code qui se répètent et qui peuvent être optimisés pour éviter la redondance et augmenter la lisibilité. Voici une version optimisée du code :

```python
import pandas as pd
from datetime import datetime

# Fonction Data
def Data(chemin_fichier_csv, date_heure_str):
    try:
        donnees = pd.read_csv(chemin_fichier_csv)
        donnees['timestamp'] = pd.to_datetime(donnees['timestamp'])
        date_heure_requise = pd.to_datetime(date_heure_str)
        info_minute = donnees[(donnees['timestamp'] >= date_heure_requise) &
                              (donnees['timestamp'] < date_heure_requise + pd.Timedelta(minutes=1))]
        if not info_minute.empty:
            return info_minute.iloc[0].to_dict()
        else:
            return None
    except Exception as e:
        print(f"Erreur lors de la lecture du fichier CSV ou de la recherche des données: {e}")
        return None

# Fonction pour créer une liste de données en fonction du time delta (minutes ou jours)
def liste_donnees(chemin_fichier_csv, date_heure_debut_str, timedelta_str, range_n):
    liste_donnees = []
    date_heure_debut = pd.to_datetime(date_heure_debut_str)
    timedelta_func = pd.Timedelta(minutes=1) if timedelta_str == "minutes" else pd.Timedelta(days=1)

    for i in range(range_n):
        instant = date_heure_debut - timedelta_func * i
        instant_str = instant.strftime('%Y-%m-%d %H:%M:%S')
        donnee = Data(chemin_fichier_csv, instant_str)
        if donnee:
            liste_donnees.append(donnee)
            
    return liste_donnees


# Chemin du fichier (ajustez le chemin selon vos données)
chemin_fichier_csv = "/content/download/eurusd-m1-bid-2024-01-01-2024-02-13.csv"

# Utilisation de la fonction pour récupérer différentes listes de données
date_heure_str = "2024-02-01 12:45:00" # Changez cette date pour correspondre à la date finale de vos données

# Liste pour les 30 dernières minutes
donnees_30_dernieres_minutes = liste_donnees(chemin_fichier_csv, date_heure_str, "minutes", 30)

# Liste pour les 7 derniers jours
donnees_7_derniers_jours = liste_donnees(chemin_fichier_csv, date_heure_str, "jours", 7)

# Liste pour les 30 derniers jours
donnees_30_derniers_jours = liste_donnees(chemin_fichier_csv, date_heure_str, "jours", 30)

# Liste pour les 31 jours du mois
donnees_31_derniers_jours = liste_donnees(chemin_fichier_csv, date_heure_str, "jours", 31)

# Liste pour les 12 mois de l'année
donnees_12_derniers_mois = liste_donnees(chemin_fichier_csv, date_heure_str, "jours", 365)

# Affichage des premiers éléments de chaque liste pour vérifier
print("30 dernières minutes:", donnees_30_dernieres_minutes[0:5])
print("7 derniers jours:", donnees_7_derniers_jours[0:5])
print("30 derniers jours:", donnees_30_derniers_jours[0:5])
print("31 jours du mois:", donnees_31_derniers_jours[0:5])
print("12 derniers mois:", donnees_12_derniers_mois[0:5])
```

Ce code utilise une fonction unique pour éviter les répétitions et permet de récupérer les données sur les dernières minutes, jours, mois de manière dynamique. Vous pouvez modifier la variable `date_heure_str` pour ajuster la période. Assurez-vous que le chemin du fichier CSV (`chemin_fichier_csv`) correspond à l'emplacement exact de votre fichier de données.

Notez que dans votre code original, il y a des erreurs pour les noms des listes de données lorsque vous essayez de les afficher à la fin (`donnees_30_derniers_jours` est appelé `donnees_30_derniers_jours_liste` dans une partie du code, ce qui cause une `NameError`). Vous devez vous assurer que les noms correspondent lors que vous les référencez dans le notebook.

Veuillez également noter que les fonctions n'ont pas été testées car Je n'ai pas les données ou l’environnement de travail réel. Certaines modifications pourraient être nécessaires pour s’adapter à vos données réelles.

turns-00017.parquet:57735

a04a3f3063b8302a2092828f
turn 1/2gpt-3.5-turbo-0125FrenchDR Congo273 words
degenerate_repetitionAbsentFinal dense release
USER
Gestion d'une entreprise
ASSISTANT
La gestion d'une entreprise implique la prise de décisions stratégiques, la planification des activités, la coordination des ressources et le suivi des performances. Voici quelques aspects importants de la gestion d'une entreprise :

1. Définition des objectifs : Les dirigeants doivent définir des objectifs clairs pour l'entreprise, en tenant compte de sa vision, de sa mission et de ses valeurs.

2. Planification : Il est essentiel de planifier les activités de l'entreprise à court, moyen et long terme. Cela implique de fixer des objectifs, d'identifier les ressources nécessaires et d'établir des stratégies pour les atteindre.

3. Organisation : La mise en place d'une structure organisationnelle efficace permet de répartir les tâches, de définir les responsabilités et de favoriser la communication au sein de l'entreprise.

4. Gestion des ressources humaines : Recruter, former, motiver et fidéliser les employés sont des tâches essentielles pour assurer le bon fonctionnement de l'entreprise.

5. Gestion financière : Suivre et contrôler les finances de l'entreprise (gestion des coûts, budget, trésorerie, etc.) est crucial pour assurer sa pérennité.

6. Marketing et vente : Développer une stratégie de marketing et de vente efficace est indispensable pour attirer de nouveaux clients et fidéliser les clients existants.

7. Suivi des performances : Mettre en place des outils de suivi et d'évaluation permet de mesurer les performances de l'entreprise et de prendre les décisions nécessaires pour l'améliorer.

En résumé, la gestion d'une entreprise requiert des compétences diverses et une vision globale pour garantir sa croissance et sa pérennité. Il est essentiel de rester flexible, de s'adapter aux changements du marché et de faire preuve d'innovation pour réussir dans un environnement concurrentiel.