AI_Trade_Model

matplotlib.pyplot AS PLT Import 
from matplotlib.animation Import FuncAnimation
from the deque Collections Import

# coordinate fig, ax = plt.subplots () is equivalent to the fig, ax = plt.subplots (11) .
"" "
Fig plt.figure = ()
matpltlib.pyplot.figure (
NUM = None, # figure set name. Default ascending numerical order named figure_num (pivot table output window) eg" figure1 ". Can set their own figure name, or the name of INT, str or type;
figsize = None, size # figure set default command rcParams [ "figure.fig.size"] = [ 6.4, 4.8], i.e., length and width of 6.4 * figure. 4.8;
dpi = None, # figure pixel density setting command is the default system rcParams [ "sigure.dpi"] = 100;.
facecolor = None, # figure set default background color command rcParams [ "figure.facecolor". ] = 'w', i.e. white white;
edgecolor = None, frameon = True, # set not to draw the outline & contour colors. Default drawing contour, dyeing rcParams [ "figure.edgecolor"] = ' w', i.e., white White;
FigureClass = <class 'matplotlib.figure.Figure'>, # is set so as not to use a figure template. The system default is not used;
Clear = False, setting # figure when the same name exists, whether to replace it. Default False, that is not replaced.
kwargs **)
the subplot (1,2,1)
Plot (X, Y, 'r--')
the subplot (1,2,2)
Plot (Y, X, 'G * -')
"" "

# Fig, ax = plt.subplots () is equivalent to the following two
# Fig plt.figure = ()
# fig.add_subplot AX = (. 1,. 1,. 1)
# 12 wherein the parameters represent the number of rows and columns of the sub-picture number, a total of 1x1 sub-images, when there is no default parameter a.
Fig, plt.subplots AX = (1,1)

# data source
f = open ( "C: / Users / Cheung /Desktop/USDJPY240.csv", "r"








d = 0
global prev
prev = 0

scale = 1.0
queue = deque([(0, 0)])

for line in f:
#print(line)
values = line.split(",")
price = float(values[5].strip())
if prev == 0:
queue.append((x, price))
prev = price
elif d == 0 and price > prev:
queue.append((x, price))
prev = price
elif d == 0 and price <= prev:
if (prev - price) >= scale:
d = 1
x = x + 1
queue.append((x, prev))
queue.append((x, price))
prev = price

elif d == 1 and price < prev:
queue.append((x, price))
prev = price
elif d == 1 and price >= prev:
if (price - prev) >= scale:
d = 0
x = x + 1
queue.append((x, prev))
queue.append((x, price))
prev = price


def init():
ax.set_xlim(0, 100)
ax.set_ylim(60, 100)
return ax.plot([], [], "r-", animated=False)


def update(frame):
print(frame)
xdate.append(frame[0])
ydate.append(frame[1])
return ax.plot(xdate, ydate, "r-", animated=False)


ani = FuncAnimation(fig, update, frames=queue,
init_func=init, blit=True, repeat=False)

plt.show()

Guess you like

Origin www.cnblogs.com/saber-himesama/p/11595263.html