Raul Silvania
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- title: 'Python for Algorithmic Trading: Quick Guide' disqus: hackmd --- Python for Algorithmic Trading: Quick Guide === ![downloads](https://img.shields.io/github/downloads/atom/atom/total.svg) ![build](https://img.shields.io/appveyor/ci/:user/:repo.svg) ![chat](https://img.shields.io/discord/:serverId.svg) ## Table of Contents [TOC] ## Purpose I'm going to take what's from the book and streamline it from creating the environment to execution. This is the book from Hilpisch, Yves. Setting up Docker Containers --- ### Purpose To have a script run on the cloud. Not needing a home computer to run it, avoids risk of power/connection issues to brokerage. This is good for algorithmic deployment purposes. Steps: **1) Server set up script**: running files on droplet. **2) Python and Jupyter Installation**: have a lab server. **3) Jupyter Notebook configuration file**: password protection. **4) RSA Public and Private Key Files**: SSL encryption communication. ### Digital Ocean VM: Droplet 1. Sign up: [here](https://cloud.digitalocean.com/registrations/new) 2. Create first droplet: Django Server 3. Refer to [guide](https://developers.digitalocean.com/guides/) ### Connecting to Ocean VM **Input** ```bash= $ ssh <root>@<dropletIP> ``` **Output** ```bash= Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-47-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Tue Dec 29 19:25:28 UTC 2020 System load: 0.0 Users logged in: 0 Usage of /: 9.1% of 24.06GB IPv4 address for eth0: 178.128.72.117 Memory usage: 32% IPv4 address for eth0: 10.46.0.5 Swap usage: 0% IPv4 address for eth1: 10.120.0.2 Processes: 123 0 updates can be installed immediately. 0 of these updates are security updates. The list of available updates is more than a week old. To check for new updates run: sudo apt update ******************************************************************************** Welcome to DigitalOcean's 1-Click Django Droplet. To keep this Droplet secure, the UFW firewall is enabled. All ports are BLOCKED except 22 (SSH), 80 (HTTP), and 443 (HTTPS). ... ``` Creating the Environment w/ Conda --- Conda in this instance is probably used for the environment and library/module control. ### Install Miniconda for 3.8 Python ```bash= $ sudo -s $ apt-get update; apt-get upgrade -y ... $ apt-get install -y gcc wget ... $ cd root $ wget \ > https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh \ > -O miniconda.sh ... $ bash miniconda.sh ... ``` ### Update & Profile Dir Conda ```bash= $ export PATH="/root/miniconda3/bin/:$PATH" $ conda update -y conda ... $ echo ". /root/miniconda3/etc/profile.d/conda.sh" >> ~/.bashrc $ bash ``` ### Using Conda ```bash= $ conda <command> <subject> ``` ### Conda Virtual Environment **Create** ```bash= $ conda create --name pyalgo3.8 python=3.8 ``` **Activate** ```bash= $ conda activate pyalgo3.8 ``` ### Package Installation ```bash= $ conda install -y numpy ipython matplotlib pandas pytables scikit-learn scipy ``` Financial Data --- Primary focus: importing data, handling data, storing data. ### Importing Data #### Quandl API Popular datasource is **Quandl**. It's popular because it grabs quality data from different sources, "opensource" and puts it in a central area. #### Eikon Data API Open data sources aren't enough for professionals. Refinitiv is one of the biggest financial/news data provider. Eikon is equivalent to Terminal by Bloomberg. Eikon is a python wrapper for their api. A local desktop application is required to run the API session. ##### Setting up Eikon API Refer to this [link](https://developers.refinitiv.com/en/api-catalog/eikon/eikon-data-api/quick-start#run-eikon) for instruction: 1) Register [Account](https://www.refinitiv.com/en/products/eikon-trading-software/download-eikon) or set up a MyRefinitiv Account 2) Download the [application](https://eikon.thomsonreuters.com/index.html) 3) Set up Python Wrapper: [Documentation](https://developers.refinitiv.com/en/api-catalog/eikon/eikon-data-api/documentation) ### Working with Data: Pandas Data is efficiently handled with the pandas module. Instead of using pure python, algorithms are made to efficiently process data. It's faster. ### Storing Data: Partition Disk as HDF5 standard Storing pandas DataFrames are simple. Parsing the data into a pandas HDFStore. It is a dump for DF objects and it allows to write to memory 5 times more than regular. #### Opening Database File: TsTables This opens the contents of the database in a more efficient manner. Trade Idea/Hypothesis --- What better way to develop a strategy than to find it through research papers? ## Appendix and FAQ :::info **Find this document incomplete?** Leave a comment! ::: ###### tags: `Templates` `Documentation`

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully