Giter Site home page Giter Site logo

tpo_project's Introduction

TPO project in Python

This is a pure Python project to calculate various Market profile related operations in python and visualize them interactively with the help of plotly and dash components. The motivation behind this project is to feed price distribution (TPOs with alphabets) and other visual cues to convolution neural networks and see if NN learns from the visualization. Therefore this project will be heavy with all the visual cues, colours and different shapes. While working on the project realized that it is possible to use this entire framework for regular charting as well.

Okay, let's get started.

Dependencies

pip install plotly (update if previously installed)

pip install dash (update if previously installed)

pip install pandas

Finally, download all the files or clone this repo as zip and extract in local folder.

Steps for live chart

  1. Open tpo_project.py from the folder in python editor

  2. Run the code

  3. In the console, you will see the message something like Running on http://127.0.0.1:8050/ copy the server address your console printed and paste it in your browser

  4. That's it, you will get the TPO chart in browser with sample file provided in the folder.

  5. About sample file: There is live.txt file in the folder. Add data manually and you should see new updated price in the chart.

  6. Marker shows the last closing price. The market color changes to green if price >= POC else it is red.

  7. If the test runs successfully replace live and historical data with your desired data feed.

  8. Stop the server by pressing ctrl + c in the console.

For static chart

Simply run static_tpo.py and the chart will open in your browser. It uses a single file as a source for generating charts (unlike dash version which uses history.txt and live.txt), you can replace history.txt with your own data while making sure header names are matching.

For static chart with slider

Run 'static_tpo_slider.py'. Copy or click the IP address and chart will open in the browser. It uses Dash for dynamically updating Y-axis as you move the slider on X-axis. Minimum number of days to display set to 5, you can increase if you want by sliding to the left. The reason using Dash for slider because PLotly's zoomin option do not update Y-axis dynamically which makes chart really squeezed up on larger range.

Important

  1. Match data format and headers exactly with given sample file.

  2. It is not necessary to have the same data source for historical and live data as long as the format matches. It wouldn't matter even if symbol name is different, or there is price overlap the algorithm will drop the duplicate entries automatically.

  3. Algorithm uses historical data for generating context. In tpo_project.py at the start, there is 'avglen' parameter. That number should be lower or equal to the sample size of your historical data. If you have 31 days of historical data then use avglen = 30

  4. Make sure your historical file is up to date, especially entries representing day 1 and day 2. The algorithm automatically calculates session time and Initial Balance period using that info. IB is of 60 minutes. It assumes you have 1-minute data. I haven't tested on daily data.

  5. If your live feed is of 1 minute instead of a tick, you may want to increase the refresh time 'refresh_int' which is set to default 1 second.

  6. Chart update will not work until live file gets at least 30 minutes worth of data. To remove the limitation reduce frequency-time 'freq' from default 30 to 5 minutes or lower. But it will affect TPO chart calculations. So if possible don't change the parameter.

Do you have a dash compatability issue?

Run no_dash.py The flow is exactly the same as live version but without dash.

General overview of the TPO chart produced by the algo

How to read TPO chart generated by our algo-1

Bubbles at the top:

How to read charts. Hover menu -2

Square boxes at the bottom:

How to read the charts: square boxes -3

About Insights in square boxes and bubbles:

eg for square box. IB>yPOC<yVAH: 1> Explanation: It means Mid of IB range is above Yesterday's POC ( point of control ) but below yesterday's value area high (VAH)For that the algorithm gave the weightage of '1' RF means Rotational factor. RF Calculated on 1 minute bar. For a single bar RF can be at maximum 3 when there is higher high, lower low and higher close. Minimum value is -3 for a single bar. Then we sup up all the values for the day for daily RF and for IB RF summation for the 1st 1 hr. If you observe the breakdown for IB values, it doesn't have a lookahead bias so whatever the prediction or the strength of the IB at the end of 1st hour of the session it will remain the same and won't get updated. If size and color of squares matches with bubbles (which gets updated as day progress) IB predictions were right on the track.

New static TPO with slider window:

Slider window

Everything cannot be explained here, if you're interested do read this small handbook on Auction Market Theory CBOT Market Profile handbook (it is 13 mb pdf file) https://t.co/L8DfNkLNi5?amp=1

tpo_project's People

Contributors

beinghorizontal 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.