domenica 28 marzo 2021

PYTHON - MAKE A JSON FILE FROM DICT

Practical example of how to transform a dictionary into a json file.
The filename is updated using a variable contained in "count.py". Each file is added to the "listalogiche.dat" file.
From here we start for artificial intelligence.
import json
import conteggio
import sys

lista2={}
while True:
v1=input('Parola ')
if v1=='fine':
break
elif v1=='annulla':
sys.exit()
else:
v2=input('comando ')
lista2[v1]=v2
nomefile="comandi"+str(conteggio.conta)+".json"
#save lista2 as .json file
with open(nomefile, "w") as json_file:
json.dump(lista2, json_file)
#aggiornamento dei file di configurazione
f=open("conteggio.py","w")
n=conteggio.conta
n+=1
f.write('conta='+str(n))
f.close()
f=open("listalogiche.dat","a")
f.write(nomefile)
f.close()

domenica 21 marzo 2021

PYTHON and CURSES - Stupid text editor

I needed a light and simple text editor.
Sometimes I need to write micro programs in python or batch, with this little script I solved my problem.
How to use:
py ste.py "filename I want to save"
import sys,os
import curses
#ste : simple(or stupid) text editor

def editor(stdscr):
k = 0
h = 0
cursor_x = 0
cursor_y = 0
stdscr.clear()
stdscr.refresh()
curses.start_color()
curses.init_pair(1, curses.COLOR_BLACK, curses.COLOR_WHITE)
curses.init_pair(2, curses.COLOR_GREEN, curses.COLOR_BLACK)
while (True):
height, width = stdscr.getmaxyx()
if k == curses.KEY_DOWN:
cursor_y += 1
elif k == curses.KEY_UP:
cursor_y -= 1
elif k == curses.KEY_RIGHT:
cursor_x += 1
elif k == curses.KEY_LEFT:
cursor_x -= 1
elif k == 10: #ENTER
cursor_x=1
cursor_y+=1
h=cursor_y
elif k == 9: #tab
cursor_x = cursor_x +3
elif k == 265: #F1
break
elif k == 266: #
stringa=''
outstr=''
f=open(sys.argv[1],"wb+")
for i in range(h+1):
outstr=stdscr.instr(i, 1) #Read the screen
f.write(outstr)
acapo='\n'
f.write(acapo.encode())
f.close()
else:
stdscr.attron(curses.color_pair(2))
curses.echo()
cursor_x = cursor_x+1
cursor_x = max(0, cursor_x)
cursor_x = min(width-1, cursor_x)
cursor_y = max(0, cursor_y)
cursor_y = min(height-1, cursor_y)
statusbarstr = "Press 'F1' to exit | 'F2' to save | https://danieleporcaripython.blogspot.com"
stdscr.attron(curses.color_pair(1))
stdscr.addstr(height-1, 0, statusbarstr)
stdscr.addstr(height-1, len(statusbarstr), " " * (width - len(statusbarstr) - 1))
stdscr.attroff(curses.color_pair(1))
stdscr.move(cursor_y, cursor_x)
stdscr.refresh()
stdscr.attron(curses.color_pair(2))
k = stdscr.getch()

def main():
curses.wrapper(editor)

if __name__ == "__main__":
main()

martedì 16 marzo 2021

Python - AI for TA

 Specialized websites provide indicator-based signals, but they are not valid signals. 

The TA of my software is based on AI and crosses prices and indicators. The power of Python also allows me to search for graphic patterns by "visually" comparing the graph with sample patterns. The calculation of the pivot point is performed automatically, the software chooses the candle to be used and then builds supports and resistances with which to compare the price. Once the analysis is completed, a pdf file is built. The pdf file thus constructed is sent via email. It does not provide long or short entry signals of my choice. The convenience of this software is all in the speed of analysis and "reasoning". The alpha version is ready, anyone wishing to join can write me on Twitter or reply to this post.