Chartilo
Cool chart drawer for pyqt5 with candle support
Chartilo is the open-source library which allow you to draw charts on qtpainter with support for lines, candles, bars or heiken-ashi.
Features
Tech
Chartilo uses a number of open source projects to work properly:
- PyQt5 - app build framework
And of course Chartilo itself is open source with a public repository
on GitHub.
Installation
Chatrilo requires python v3+ to run.
If you didn't install PyQt5...
pip install pyqt5
Install the dependency.
pip install chartilo
Development
Ready to code? Great!
Make a change in your file and instantaneously see your updates!
Open your favorite code editor and paste these code lines.
The base sctructure likes this, you can browse demo version here
import sys
from PyQt5.QtWidgets import QApplication, QBoxLayout, QMainWindow, QVBoxLayout, QWidget
from PyQt5 import uic
from PyQt5.QtWidgets import QApplication, QMainWindow
from chartilo import Chartilo
from chartilo.drawers import GridDrawer, CandleChartDrawer, LineChartDrawer, LineDrawer, MaxMinValuesDrawer
from ast import literal_eval
from chartilo.models import Line, Candle
from chartilo.themes import Light, Dark
class MyWidget(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('untitled.ui', self)
self._chartilo = Chartilo()
layout = QVBoxLayout()
layout.addWidget(self._chartilo)
self.frame.setLayout(layout)
states = {
"type" : Candle,
"theme": Dark,
"drawers" : {
"grid" : GridDrawer,
"lineChart" : CandleChartDrawer,
"line" : LineDrawer,
"maxMinDrawer" : MaxMinValuesDrawer
},
}
file = open("data.txt", "r")
data = literal_eval(file.read())
self._chartilo.setData(data)
self._chartilo.setStates(states)
self._chartilo.updateCanvas()
if __name__ == '__main__':
app = QApplication(sys.argv)
ex = MyWidget()
ex.show()
sys.exit(app.exec_())
First of all, you must have a qtframe in order to insert a painter there:
class MyWidget(QMainWindow):
def __init__(self):
super().__init__()
uic.loadUi('uifile.ui', self)
self._chartilo = Chartilo()
layout = QVBoxLayout()
layout.addWidget(self._chartilo)
self.frame.setLayout(layout)
Second step is to create setting of library:
this is how you can implement drawers, models, themes from chartilo library:
states = {
"type" : Candle,
"theme": Dark,
"drawers" : {
"grid" : GridDrawer,
"lineChart" : CandleChartDrawer,
"line" : LineDrawer,
"maxMinDrawer" : MaxMinValuesDrawer
},
}
Note: Type of vertexes and type of vertexes darwer
should be same for proper work.
Note: you can remove some of the classes to get the functionality you want
from chartilo.drawers import GridDrawer, CandleChartDrawer, LineChartDrawer, LineDrawer, MaxMinValuesDrawer, Drawer
Note: Drawer
is required if you wanna build your own drawer.
from chartilo.models import Line, Candle
Note: models
is setting the type of vertexes and you can create your own models to draw them in your own drawers using base drawer class for calculation.
this is how line generates
class Line:
width = 8
def __init__(self, data):
self.closeTime = data[0]
self.openPrice = float(data[1])
self.closePrice = float(data[4])
this is how candle generates
from . import Line
class Candle(Line):
width = 8
def __init__(self, data):
super().__init__(data);
self.maximalPrice = float(data[2])
self.minimalPrice = float(data[3])
from chartilo.themes import Light, Dark, Theme
Note: Theme
is required if you wanna create your own theme.
The last step:
self._chartilo.setData(data)
self._chartilo.setStates(states)
self._chartilo.updateCanvas()
Note: data
must be a two-dimensional array [[closeTime, openPrice, maximalPrice, minimalPrice, closePrice], [closeTime, openPrice, maximalPrice, minimalPrice, closePrice]] example here another fields are not required yet.
This is all have a nice day
if this is not enougth you can browse crypto-meneger-project here
License
MIT
Free Software, Hell Yeah!