Visualizzazione post con etichetta pyhton. Mostra tutti i post
Visualizzazione post con etichetta pyhton. Mostra tutti i post

giovedì 1 aprile 2021

PYTHON - DICTIONARIES: A POWER

Python dictionaries: a power. Find the name of the keys, the values. Dictionaries can, linked to JSON, become a powerful lightweight database.
#HOW TO MANAGE DICTIONARY
#+-+-+-+-+-+-+-+-+-+-+-+#
d = {
  "Chiave": "Codice",
  "Costo": 1.23,
  "Ricarico": 30,
  "Listino": 3.00
}
c = d.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = d.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=d.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nd = {
    "dizionario":{"subDict":["ch1","ch2","ch3"],
                "other":"otherSub"
                },
    "numero":2,
    "codice":"codice"
}
c=nd.items()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c = nd.keys()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
c=nd.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
newD=lista[0]
c=newD.values()
print(c)
lista=list(c)
for i in range(len(lista)):
    print(lista[i])
nuovaLista=lista[0]
for i in range(len(nuovaLista)):
    print(nuovaLista[i])

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()

giovedì 23 aprile 2020

PYTHON - IA TRADING CONVERGENCE MACD

This AI is done to find convergences between MACD and prices. 
Work on Binance's SPOT databases. 
You can enter the data manually; decide to make the program work on a pre-set text file; can understand the trend automatically.

You can choose the analysis on three time frames: DAY, 4 hour and 30 minute. 
This program is open source and licensed under GNUGPL v.3. 
Together with the automatic PIVOT POINT program it can be a useful and daily support for your trading strategies.
If you want you can support my works by donating BTC, BAT or LINK or by going to this link.
Download divMacd