Exemple #1
0

# ============================================================================
# Test
# ============================================================================

if __name__ == '__main__':
    setLevel(logging.INFO)

    # load extensions
    import itrade_ext
    itrade_ext.loadExtensions(itrade_config.fileExtData,
                              itrade_config.dirExtData)

    from itrade_quotes import quotes, initQuotesModule
    initQuotesModule()
    quotes.loadMarket('EURONEXT')
    quotes.loadMarket('NASDAQ')

    quote = quotes.lookupTicker('AAPL', 'NASDAQ')
    info('test1 %s' % quote)

    quote = quotes.lookupTicker('OSI', 'EURONEXT')
    info('test2 %s' % quote)

    trades = Trades(quote)
    trades.load('import/Cortal-2005-01-07.txt')
    trades.load('import/Cortal-2005-01-14.txt')
    trades.load('import/Cortal-2005-01-21.txt')

    info('test3 %s' % trades.trade(date(2005, 01, 04)))
Exemple #2
0
            self.m_bollUp[i] = -1.0
            self.m_bollDn[i] = -1.0

# ============================================================================
# Test
# ============================================================================

if __name__=='__main__':
    setLevel(logging.INFO)

   # load extensions
    import itrade_ext
    itrade_ext.loadExtensions(itrade_config.fileExtData,itrade_config.dirExtData)

    from itrade_quotes import quotes, initQuotesModule
    initQuotesModule()
    quotes.loadMarket('EURONEXT')
    quotes.loadMarket('NASDAQ')

    quote = quotes.lookupTicker('AAPL','NASDAQ')
    info('test1 %s' % quote )

    quote = quotes.lookupTicker('OSI','EURONEXT')
    info('test2 %s' % quote )

    trades = Trades(quote)
    trades.load('import/Cortal-2005-01-07.txt')
    trades.load('import/Cortal-2005-01-14.txt')
    trades.load('import/Cortal-2005-01-21.txt')

    info('test3 %s' % trades.trade(date(2005,01,04)))
Exemple #3
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "xeho:vt:iq:f:l:du:", ["verbose","help", "output=", "ticker=", "quote=","file=","lang=","user="******"nopsyco","nowxversion"])
    except getopt.GetoptError:
        # print help information and exit:
        usage()
        sys.exit(2)

    # default values
    output = None
    quote = None
    file = None
    wx = True
    nopsyco = False
    nowxversion = False;

    vticker = None
    vquote  = None

    lang = gMessage.getAutoDetectedLang('us')
    for o, a in opts:

        if o == "-d":
            itrade_config.setDisconnected(True)

        if o == "-v" or o == "--verbose":
            itrade_config.verbose = True
            print 'Verbose mode : ON'

        if o == "-x":
            itrade_config.experimental = True

        if o == "-e":
            itrade_portfolio.cmdline_evaluatePortfolio()
            wx = False

        if o == "-i":
            if quote:
                if file:
                    itrade_import.cmdline_importQuoteFromFile(quote,file)
                else:
                    itrade_import.cmdline_importQuoteFromInternet(quote)
            else:
                matrix = itrade_matrix.createMatrix()
                if file:
                    itrade_import.cmdline_importMatrixFromFile(matrix,file)
                else:
                    itrade_import.cmdline_importMatrixFromInternet(matrix)
            wx = False

        if o == "-h" or o == "--help":
            usage()
            sys.exit()

        if o == "-o" or o == "--output":
            output = a

        if o == "-u" or o == "--user":
            itrade_config.dirUserData = a
            if not os.path.exists(itrade_config.dirUserData):
                print 'userdata folder %s not found !' % a
                sys.exit()

        if o  == "--nopsyco":
            nopsyco = True

        if o  == "--nowxversion":
            itrade_config.nowxversion = True

        if o == "-f" or o == "--file":
            file = a

        if o == "-l" or o == "--lang":
            lang = a
            itrade_config.lang = 255

        if o == "-t" or o == "--ticker":
            vticker = a

        if o == "-q" or o == "--quote":
            vquote = a

    # Import Psyco if available
    if not nopsyco:
        try:
            import psyco
            psyco.full()
            print 'Psyco is running'
        except ImportError:
            print 'Psyco is not running (library not found)'
    else:
        print 'Psyco is not running (forced by command line)'

    # load configuration
    itrade_config.loadConfig("itrade.py")
    if itrade_config.verbose:
        print "*** Proxy server:",itrade_config.proxyHostname, "- Proxy auth:",itrade_config.proxyAuthentication,"- Connection timeout:",itrade_config.connectionTimeout

    # load extensions
    itrade_ext.loadExtensions(itrade_config.fileExtData,itrade_config.dirExtData)

    # init modules
    itrade_quotes.initQuotesModule()
    itrade_portfolio.initPortfolioModule()

    # use the correct pack language
    if itrade_config.lang == 255:
        gMessage.setLang(lang)
        gMessage.load()

    # commands
    if vticker:
        quote = itrade_quotes.quotes.lookupTicker(vticker)
        if not quote:
            print 'ticker %s not found !' % vticker
            sys.exit()

    if vquote:
        quote = itrade_quotes.quotes.lookupKey(vquote)
        if not quote:
            print 'quote %s not found ! format is : <ISINorTICKER>.<EXCHANGE>.<PLACE>' % vquote
            sys.exit()

    if wx:
        import itrade_wxmain
        itrade_wxmain.start_iTradeWindow()

    if quote:
        portfolio = itrade_portfolio.loadPortfolio()
        quote.update()
        quote.compute()
        quote.printInfo()
Exemple #4
0
def main():
    try:
        opts, args = getopt.getopt(sys.argv[1:], "xeho:vt:iq:f:l:du:", ["verbose","help", "output=", "ticker=", "quote=","file=","lang=","user="******"nopsyco","nowxversion"])
    except getopt.GetoptError:
        # print help information and exit:
        usage()
        sys.exit(2)

    # default values
    output = None
    quote = None
    file = None
    wx = True
    nopsyco = False
    nowxversion = False

    vticker = None
    vquote  = None

    lang = gMessage.getAutoDetectedLang('us')
    for o, a in opts:

        if o == "-d":
            itrade_config.setDisconnected(True)

        if o == "-v" or o == "--verbose":
            itrade_config.verbose = True
            print 'Verbose mode : ON'

        if o == "-x":
            itrade_config.experimental = True

        if o == "-e":
            itrade_portfolio.cmdline_evaluatePortfolio()
            wx = False

        if o == "-i":
            if quote:
                if file:
                    itrade_import.cmdline_importQuoteFromFile(quote,file)
                else:
                    itrade_import.cmdline_importQuoteFromInternet(quote)
            else:
                matrix = itrade_matrix.createMatrix()
                if file:
                    itrade_import.cmdline_importMatrixFromFile(matrix,file)
                else:
                    itrade_import.cmdline_importMatrixFromInternet(matrix)
            wx = False

        if o == "-h" or o == "--help":
            usage()
            sys.exit()

        if o == "-o" or o == "--output":
            output = a

        if o == "-u" or o == "--user":
            itrade_config.dirUserData = a
            if not os.path.exists(itrade_config.dirUserData):
                print 'userdata folder %s not found !' % a
                sys.exit()

        if o  == "--nopsyco":
            nopsyco = True

        if o  == "--nowxversion":
            itrade_config.nowxversion = True

        if o == "-f" or o == "--file":
            file = a

        if o == "-l" or o == "--lang":
            lang = a
            itrade_config.lang = 255

        if o == "-t" or o == "--ticker":
            vticker = a

        if o == "-q" or o == "--quote":
            vquote = a

    # Import Psyco if available
    if not nopsyco:
        try:
            import psyco
            psyco.full()
            print 'Psyco is running'
        except ImportError:
            print 'Psyco is not running (library not found)'
    else:
        print 'Psyco is not running (forced by command line)'

    # load configuration
    itrade_config.loadConfig("itrade.py")
    if itrade_config.verbose:
        print "*** Proxy server:",itrade_config.proxyHostname, "- Proxy auth:",itrade_config.proxyAuthentication,"- Connection timeout:",itrade_config.connectionTimeout

    # load extensions
    itrade_ext.loadExtensions(itrade_config.fileExtData,itrade_config.dirExtData)

    # init modules
    itrade_quotes.initQuotesModule()
    itrade_portfolio.initPortfolioModule()

    # use the correct pack language
    if itrade_config.lang == 255:
        gMessage.setLang(lang)
        gMessage.load()

    # commands
    if vticker:
        quote = itrade_quotes.quotes.lookupTicker(vticker)
        if not quote:
            print 'ticker %s not found !' % vticker
            sys.exit()

    if vquote:
        quote = itrade_quotes.quotes.lookupKey(vquote)
        if not quote:
            print 'quote %s not found ! format is : <ISINorTICKER>.<EXCHANGE>.<PLACE>' % vquote
            sys.exit()

    if wx:
        import itrade_wxmain
        itrade_wxmain.start_iTradeWindow()

    if quote:
        portfolio = itrade_portfolio.loadPortfolio()
        quote.update()
        quote.compute()
        quote.printInfo()