예제 #1
0
파일: mainw.py 프로젝트: tianhm/pymta
    def database_new(self):
        """Create a new database file"""

        filename = tkFileDialog.asksaveasfilename()

        if filename:
            self.log.info(
                "User asked to create a new database named {0}".format(
                    filename))
            self.source = yahoo.LocalSource(filename)

        self.refresh_all()
예제 #2
0
파일: mainw.py 프로젝트: tianhm/pymta
    def database_open(self):
        """Open an existing database"""

        filename = tkFileDialog.askopenfilename(multiple=False)

        if filename:

            try:
                self.log.info("Trying to load file {0}".format(filename))
                self.source = yahoo.LocalSource(filename)
            except Exception, ex:
                self.log.critical(
                    "Cannot open file {0} as local database".format(filename))
                self.log.error(ex.message)

            self.refresh_all()
예제 #3
0
파일: mainw.py 프로젝트: tianhm/pymta
    def __init__(self, root):

        # create logger with 'spam_application'
        self.log = logging.getLogger('main')
        self.log.setLevel(logging.DEBUG)

        # create file handler which logs even debug messages
        fh = logging.FileHandler('mainw.log')
        fh.setLevel(logging.DEBUG)

        # create console handler with a higher log level
        ch = logging.StreamHandler()
        ch.setLevel(logging.DEBUG)

        # create formatter and add it to the handlers
        formatter = logging.Formatter(
            '%(asctime)s - %(levelname)s - %(name)s - %(message)s')
        fh.setFormatter(formatter)
        ch.setFormatter(formatter)

        # add the handlers to the logger
        self.log.addHandler(fh)
        self.log.addHandler(ch)

        self.log.info('testasetat')

        self.root = root
        self.source = None

        self.root.title("pymta tkInterface {0}".format(VERSION))

        # menu bar
        menubar = tk.Menu(self.root)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="New", command=self.database_new)
        filemenu.add_command(label="Open", command=self.database_open)
        filemenu.add_command(label="Exit", command=self.quit)
        menubar.add_cascade(label="File", menu=filemenu)
        toolsmenu = tk.Menu(menubar, tearoff=0)
        toolsmenu.add_command(label="Load symbols from file",
                              command=self.symbol_load_from_file)
        menubar.add_cascade(label="Tools", menu=toolsmenu)
        self.root.config(menu=menubar)

        # paned window
        panedWindow = ttk.PanedWindow(self.root, orient=tk.VERTICAL)
        panedWindow.pack(fill=tk.BOTH, expand=1)

        # notebook
        notebook = ttk.Notebook(panedWindow)
        #~ notebook.pack(fill=tk.BOTH, expand=1)
        panedWindow.add(notebook, weight=3)

        # tabs
        manageSymbolsTab = tk.Frame(notebook)
        notebook.add(manageSymbolsTab, text="Manage symbols")
        plotTab = tk.Frame(notebook)
        notebook.add(plotTab, text="Plot")

        # manage symbols tab - symbols list
        self.symbolsList = tksym.SymbolList(manageSymbolsTab, self.source)
        self.symbolsList.pack(fill=tk.BOTH, expand=1)

        # plot symbols tab - symbols list
        self.plotFrame = tkplot.PlottingFrame(plotTab, self.source)
        self.plotFrame.pack(fill=tk.BOTH, expand=1)

        # button bar
        btnFrame = tk.Frame(manageSymbolsTab)
        btnFrame.pack(fill=tk.BOTH, expand=0)
        btnAdd = tk.Button(btnFrame, text="Add new", command=self.symbol_add)
        btnRefresh = tk.Button(btnFrame,
                               text="Refresh selected",
                               command=self.symbol_refreshEoD)
        btnAdd.pack(side=tk.RIGHT)
        btnRefresh.pack(side=tk.RIGHT)

        # FIXME: delete following rows
        self.source = yahoo.LocalSource(DEFAULT_DATABASE_PATH)
        self.refresh_all()
예제 #4
0
    def setUp(self):

        silentremove(DB3_FILE)
        self.source = yahoo.LocalSource(DB3_FILE)
        self.source.eod_load_from_csv(
            TEST_SYMBOL, CSV_FILE)  # load fake prices as symbol `TEST`
예제 #5
0
	
"""

import yahoo
from plotting import Plotter
import market
import argparse

LOCAL_DATASOURCE = "yahoo.db3"
TEST_SYMBOL = "ENI.MI"

if __name__ == '__main__':

    ## plotting ##

    source = yahoo.LocalSource(LOCAL_DATASOURCE)
    symbol = market.Symbol(source, TEST_SYMBOL, None, None, matplotlib=True)

    p = Plotter('Simple')
    p.draw_simple(symbol)
    p.run()

    p = Plotter('Candlestick')
    p.draw_candlestick(symbol)
    p.run()

    p = Plotter('Simple with volume')
    p.draw_simple_with_volume(symbol)
    p.run()

    p = Plotter('Simple with volume and OBV')
예제 #6
0
 def setUp(self):
     silentremove(TEST_DB3_FILE)
     self.source = yahoo.LocalSource(TEST_DB3_FILE)
     self.source._load_from_csv(
         TEST_SYMBOL, TEST_CSV)  # load fake prices as symbol `TEST`
     self.symbol = market.Symbol(self.source, TEST_SYMBOL)
예제 #7
0
from plotting import Plotter
import market
import argparse
import datetime
import logging

logging.basicConfig(filename='plotting_test.log', level=logging.DEBUG, format='%(asctime)s %(message)s') # log to file
log = logging.getLogger()

parser = argparse.ArgumentParser()
parser.add_argument('source', help='path to the LocalSource database')
parser.add_argument('-s', '--symbol', required=True,
	help='the symbol to plot, according to yahoo convention (ie: SPM.MI)')
args = parser.parse_args()

datasource = yahoo.LocalSource(args.source)

mindate = '2015-03-01'
maxdate = '2016-03-01'
symbol = market.Symbol(datasource, args.symbol, mindate, maxdate, matplotlib=True)


p = Plotter('Simple')
p.draw_simple(symbol)
p.run()

p = Plotter('Candlestick')
p.draw_candlestick(symbol)
p.run()

p = Plotter('Simple with volume')
예제 #8
0
파일: console.py 프로젝트: tianhm/pymta
	def __init__(self, path):
		
		self.source = yahoo.LocalSource(path)
		self.pageMain()
예제 #9
0
 def setUp(self):
     self.source = yahoo.LocalSource("yahoo.db3")