Code Monkey home page Code Monkey logo

ib_flex's Introduction

IB_Flex

Assorted python scripts for downloading Interactive Brokers (IB) flex query, then saving and analyzing them. Abandoned dash and using highchart and Flask instead.

The goal of this project is to store interactive broker account history in a sqlite database and analyse them using SQL/Python, perhaps with help of panda.

Some of the analysis in mind:

  • Consider cost of funding, tax and dividend for single stock performance - hard to do with IB statements.
  • Tallying futures PnL over multiple rolling period.
  • Account Equity graph/drawdown analysis/ratios

Prerequisite:

Pandas, Flask

See requirement.txt

Disclaimer:

This is alpha software and just started developing, it just "worked" for me without any serious testing and I am not an experineced developer, so raising issues you found is welcome.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.

Usage:

xml_downloader.py
Call download_xml with token and report number, filename is optional.
The resulting xml file will be saved in the same folder as the script.
download_xml(token, report_number, filename='data.xml')

Flex query report number is generated when you create a flex query.
https://www.interactivebrokers.com.hk/en/software/am/am/reports/activityflexqueries.htm

Please refer to the link below on how to get the token https://www.interactivebrokers.com.hk/en/software/am/am/reports/flex_web_service_version_3.htm

example:

import xml_downloader
xml_downloader.download_xml('123456789012345', '123456', 'test.xml')

import_data.py Call create_table() to create account.db in the same directory with the database schema. Call import_to_db(file) to import an xml file to the database.

Run run.py to start the server and browse the resulting chart with your browser.

Sample graph

ib_flex's People

Contributors

alexpung avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.