FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
finplot/finplot/live.py at master · robot-python/finplot · GitHub
robot-python
/
finplot
Public
forked from
highfestiva/finplot
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
finplot
/
finplot
/
live.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (47 loc) · 1.89 KB
Breadcrumbs
finplot
/
finplot
/
live.py
Copy path
File metadata and controls
56 lines (47 loc) · 1.89 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
'''
For simplifying plot updating.
'''
import
finplot
class
Live
:
def
__init__
(
self
):
self
.
colors
=
{}
self
.
item
=
None
self
.
item_create_func_name
=
''
def
item_create_call
(
self
,
name
):
val
=
getattr
(
finplot
,
name
)
if
not
callable
(
val
):
return
val
def
wrap_call
(
*
args
,
**
kwargs
):
if
'gfx'
in
kwargs
:
# only used in subsequent update calls
del
kwargs
[
'gfx'
]
item
=
val
(
*
args
,
**
kwargs
)
if
isinstance
(
item
,
finplot
.
pg
.
GraphicsObject
):
# some kind of plot?
setattr
(
self
,
'item'
,
item
)
setattr
(
self
,
'item_create_func_name'
,
val
.
__name__
)
# update to the "root" colors dict, if set
if
self
.
colors
:
item
.
colors
.
update
(
self
.
colors
)
# from hereon, use the item.colors instead, if present
if
hasattr
(
item
,
'colors'
):
setattr
(
self
,
'colors'
,
item
.
colors
)
return
self
return
item
return
wrap_call
def
item_update_call
(
self
,
name
):
if
name
==
self
.
item_create_func_name
:
def
wrap_call
(
*
args
,
**
kwargs
):
item
=
object
.
__getattribute__
(
self
,
'item'
)
ka
=
{
'gfx'
:
kwargs
.
get
(
'gfx'
,
True
)}
# only gfx parameter used
assert
len
(
args
)
==
1
,
'only one unnamed argument allowed for live plots'
item
.
update_data
(
*
args
,
**
ka
)
return
wrap_call
return
getattr
(
self
.
item
,
name
)
def
__getattribute__
(
self
,
name
):
try
:
return
object
.
__getattribute__
(
self
,
name
)
except
:
pass
# check if we're creating the plot, or updating data on an already created one
if
object
.
__getattribute__
(
self
,
'item'
)
is
None
:
return
self
.
item_create_call
(
name
)
return
self
.
item_update_call
(
name
)
Back
|
FazBrowse Home
|
New Git URL