sexta-feira, 1 de fevereiro de 2013

absorptions: The sound of the dialup, pictured

absorptions: The sound of the dialup, pictured: If you ever connected to the Internet before the 2000s, you probably remember that it made a peculiar sound. But despite becoming so familia...

sábado, 8 de setembro de 2012

BM&FBOVESPA - UMDF and Python

 import socket  
 import struct  
 import sys  
   
 from threading import Thread  
 from Queue import Queue  
   
 class UmdfStream:  
      def __init__(self, grp, port):  
           self.grp = grp  
           self.port = port  
           self.q = Queue()  
           self.t = Thread(target=self.worker)  
           self.t.daemon = True  
           self.buff = ''  
           self.t.start()  
   
      def connect( self ):  
           sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)  
           sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)  
           sock.bind(('', self.port))  
           mreq = struct.pack("4sl", socket.inet_aton(self.grp), socket.INADDR_ANY)  
           sock.setsockopt(socket.IPPROTO_IP, socket.IP_ADD_MEMBERSHIP, mreq)  
           while True:  
                 self.q.put( sock.recv(1500) )  
   
      def worker( self ):  
           needmore = False  
           while True:  
                if needmore:  
                     data = self.q.get()  
                     self.q.task_done()  
                     needmore = False  
   
                if self.buff == '':  
                     data = self.q.get()  
                     pkt_size = len( data )  
                     if pkt_size < 10:  
                          self.buff += data  
                     else:  
                          hdr_seq_num = struct.unpack('!i', data[0:4])[0]  
                          hdr_num_chucks = struct.unpack('!h', data[4:6])[0]  
                          hdr_cur_chuck = struct.unpack('!h', data[6:8])[0]  
   
                          print 'decoding msg seq:', hdr_seq_num, ' chuck: ', hdr_cur_chuck, '/', hdr_num_chucks  
   
                     self.q.task_done()  
   
   
   
 if __name__ == '__main__':  
      if len(sys.argv) < 3:  
           print 'Usage:', sys.argv[0], ' multicast ip, port'  
           sys.exit(1)  
   
      stream = UmdfStream( sys.argv[1], int(sys.argv[2]) )  
      stream.connect()  
   
Para usar: python umdf.py 233.252.8.57 10007 ( para ver as mensagens do canal de indice futuro chegando ) Este pedaço de codigo, auxilia identificar rapidamente se o sinal UMDF esta chegando ate a maquina ;)

segunda-feira, 7 de maio de 2012

Enviando single order no Apama


com.apama.oms.NewOrder norder := new com.apama.oms.NewOrder;
norder.orderId   := "test" + integer.getUnique().toString();
norder.type      := "LIMIT";
norder.quantity  := 100;

norder.symbol     := "BISA3";
// order details


com.apama.oms.OrderPublisherStateContainer npub := new com.apama.oms.OrderPublisherStateContainer;
com.apama.service.framework.ServiceInterface frwk;


frwk := framework.initialiseServiceInterface("apamafmk"," apamafmk ","",new dictionary<string,string>);


com.apama.oms.OrderPublisherStateContainer npub := new com.apama.oms.OrderPublisherStateContainer;
// useless stuff


npub.submit( frwk, norder, true);
// order sent !? lets mensure it ;)








domingo, 11 de setembro de 2011

Um cliente me solicitou que instalace o server FIX que fiz pra ele em java ( pra testar o QuifkFIX/J ), achei isto na net http://wrapper.tanukisoftware.com/doc/english/product-overview.html vou passar o domingao brincando com isto :D
Gostei da nova interface do blogger (:

quarta-feira, 19 de janeiro de 2011

gnustep-base instalado


// Hello.m
#import

@interface HelloWorld : NSObject {
// no instance variables
}
// methods
- (void)sayHello;
@end

@implementation HelloWorld
- (void)sayHello
{
NSLog(@"Hello, world, at %@", [NSCalendarDate calendarDate]);
}
@end

int main() {
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];

// my stuff
HelloWorld *hw = [[HelloWorld alloc] init];
[hw autorelease];

[hw sayHello];

[pool release];
return 0;
}

// GNUmakefile
include $(GNUSTEP_MAKEFILES)/common.make
TOOL_NAME = Hello
Hello_OBJC_FILES = Hello.m
include $(GNUSTEP_MAKEFILES)/tool.make

moia:bzero:~/objc> gmake
This is gnustep-make 2.0.8. Type 'make print-gnustep-make-help' for help.
Making all for tool Hello...
Compiling file Hello.m ...
Linking tool Hello ...

terça-feira, 18 de janeiro de 2011

fixlib

fixlib
======

fixlib provides a Pythonic interface to build FIX engines. FIX messages
(currently, only version 4.2 of the protocol is supported) are converted
to very readable Python dictionaries. An abstract store interface is used
to store messages and thereby provide the resend facilities required by the
protocol. An example store based on CouchDB and couchdb-python is provided.
fixlib uses the asyncore module from the standard library to efficiently
handle network communication.


sábado, 15 de janeiro de 2011

console mail

moia:bzero:~> cd /usr/pkgsrc/mail/ && make install
=> Registering installation for mutt-1.4.2.3nb3

segunda-feira, 10 de janeiro de 2011

netbsd STABLE

===> Summary of results:
build.sh command: ./build.sh -U distribution
build.sh started: Sun Jan 9 15:22:14 AMT 2011
NetBSD version: 4.0.1_PATCH
MACHINE: i386
MACHINE_ARCH: i386
Build platform: NetBSD 5.0.2 i386
HOST_SH: /bin/sh
No nonexistent/bin/nbmake, needs building.
Bootstrapping nbmake
TOOLDIR path: /usr/src/obj/tooldir.NetBSD-5.0.2-i386
DESTDIR path: /usr/src/obj/destdir.i386
RELEASEDIR path: /usr/src/obj/releasedir
Created /usr/src/obj/tooldir.NetBSD-5.0.2-i386/bin/nbmake
makewrapper: /usr/src/obj/tooldir.NetBSD-5.0.2-i386/bin/nbmake-i386
Updated /usr/src/obj/tooldir.NetBSD-5.0.2-i386/bin/nbmake-i386
Successful make distribution
build.sh ended: Sun Jan 9 17:45:37 AMT 2011

terça-feira, 28 de setembro de 2010

nunca misture signed e usigned in c++

porque ?


#include
int main (void)
{
long a = -1;
unsigned b = 1;
printf ("%d\n", a > b);
return 0;
}


Setting environment for using Microsoft Visual Studio 2008 x86 tools.

D:\devel\src\others> cl compare.cpp
D:\devel\src\others> compare
1
D:\devel\src\others>


e agora:

Setting environment for using Microsoft Visual Studio 2008 Beta2 x64 cross tools

D:\devel\src\others> cl compare.cpp
D:\devel\src\others> compare
0
D:\devel\src\others>
entao cuidado ;)

segunda-feira, 23 de agosto de 2010

Download, build, install, upgrade, and uninstall Python packages -- easily!

fica simples instalar pacotes python com esta ferramenta:

http://pypi.python.org/pypi/setuptools

e para instalar os pacotes que sao dependencia do twisted, exeucte na linha de comando:

C:\>C:\Python27\Scripts\easy_install.exe zope.interface-3.6.1-py2.6-win32.egg


C:\>C:\Python27\Scripts\easy_install.exe zope.interface-3.6.1-py2.6-win32.egg

Quite eazy ;)

[]s

quinta-feira, 19 de agosto de 2010

Twisted Windows IOCP

Não precisei mudar nada no meu projeto, so instalar os modulos abaixo:

Python for Windows extensions
http://sourceforge.net/projects/pywin32/

Python wrapper module around the OpenSSL library
http://pypi.python.org/pypi/pyOpenSSL


tentei chamar no codigo iocpreactor.install(), porem parece que o Twisted faz isto automaticamente.

quarta-feira, 18 de agosto de 2010

Simple Twisted connector

Estou come'cando a gostar deste python, fiz alguns testes com o twisted, estou bem acostumado com o ASIO. foi bem facil entender o funcionamento basico.

vejam o conector que fiz para inciar meus testes ;)

# Clebson Derivan ( cderivan@gmail.com )
#
fixTestBot - provides FIX protocol bussiness level test automation.

# twisted imports
import sys
from twisted.internet import reactor, protocol
from twisted.python import log

class Protocol(protocol.Protocol):
def connectionMade(self):
self.transport.write(
"Twisted server v000\r\n")
print "We are connected"

def dataReceived(self, raw):
print "msg received: ", raw

class Factory(protocol.ReconnectingClientFactory):

def buildProtocol(self, addr):
self.resetDelay()
return Protocol()

if __name__ == "__main__":

log.startLogging(sys.stdout)

f
= Factory()
reactor.connectTCP(
"127.0.0.1", 9000, f )
reactor.run()


e roda bonitinho, simples e rapido, vejam que ele incrementa automatico o tempo de recone'cao.


C:\devel\python\fixTestSDK>connector.py
2010-08-20 16:50:42-0300 [-] Log opened.
2010-08-20 16:50:42-0300 [-] Starting factory <__main__.factory>
2010-08-20 16:50:43-0300 [Uninitialized]
will retry in 2 seconds

2010-08-20 16:50:43-0300 [Uninitialized] Stopping factory <__main__.factory>
2010-08-20 16:50:45-0300 [-] Starting factory <__main__.factory>
2010-08-20 16:50:46-0300 [Uninitialized]
will retry in 9 seconds

2010-08-20 16:50:46-0300 [Uninitialized] Stopping factory <__main__.factory>
2010-08-20 16:50:55-0300 [-] Starting factory <__main__.factory>
2010-08-20 16:50:55-0300 [Uninitialized] We are connected

se quizer testar, usa o netcat

C:\Documents and Settings\bzero>nc -L -p 9000
Twisted server v000


Reading QuickFix Cfg file using python APIs.

Achei bem simples ( lembrando que estou aprendendo python ), pretendo automatizar, mais meus testes ;)

# Clebson Derivan ( cderivan@gmail.com )

import sys, os, ConfigParser
if __name__ == "__main__":

file
= sys.argv[1:]

print """Clebson Derivan ( cderivan@gmail.com )
cfgReader - open QuickFix Cfg file using python APIs.
"""

if file == []:
print "please provide QuickFix config file name:", "\r\n"
print " cfgReader.py example.cfg"
sys.exit(0)

print "Opening file:", file

config
= ConfigParser.RawConfigParser()
filesread
= config.read( os.path.expanduser( file ) )
if not filesread:
print "cant open file:", file, "\r\n"
sys.exit(0)

#dump file content
for section in config.sections():
print "section:", section
for i in config.items(section):
print i[0], " = ", i[1]

segunda-feira, 16 de agosto de 2010

gVim Windows e Python

Decidi escrever um pequeno artigo sobre o VIM para Windows como IDE para Python, comecei recentemente a estudar a linguagem e não encontrei nenhuma IDE que me atendesse, como eu tenho facilidade com o VIM resolvi instalar o ambiente em um notebook novo:

ler mais