Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

arqLogger

This library is intended to be used by developers seeking to send logs generated by the strategy outside Arquants infrastructure to be analyze and process.

Installation

Use the package manager pip to install arqLogger.

pip install -U arqLogger

In the case you used it in an Arquant Strategy. You import the package directly in the strategy and you are good to go.

Usage

The library can be used to create the server and the client side of the connection.

Client

Simple Strategy

How to use arqLogger in an Arquant Strategy

from arquants import Strategy
from arquants import Order

import arqLogger

class ExampleStrategy(Strategy):

    def __init__(self):
        # Init websocket logger connection
        self.logger = arqLogger.ArquantLogger(
           url="ws://ip:port/", # URL to connect 
           strategy=self, # Reference to the strategy
           strategy_id="My_Strategy_1", # Unique ID of the strategy
           param_list=locals()) # parameter list used to run the strategy, this information is send in the init message. (local function send all the variable define in the scope)

        # Establish a connection with the server and send the initial message
        self.logger.connect()


    def next(self):
        # Example on how to log Market Data message received.
        # data_list: list of n instrument to be log
        # entry_list: list with n list (one per instrument) in which we indicate the entries we want to log
        # additional: dict with additional information
        self.logger.log_md_event(data_list=[self.data0, self.data1],
                                 entry_list=[['bid_px','bid_qty','bid_px_2','bid_qty_2'], ['bid_px','bid_qty']],
                                 additional={
                                     "other_data": 0,
                                     "another_data": "Important Info",
                                 })

        # Send buy order for instrument data0 
        order = self.buy(data=self.data0, price=3000, size=10, exectype=Order.Limit)

        # Example on how to log when we send a New Order to the market.
        # order: new order.
        # additional: dict with additional information
        self.logger.log_new_order_response(order=order,
                                           additional={
                                                "other_data": 0,
                                                "another_data": "Important Info",
                                           })


    def notify_order(self, order):
        # Example on how to log when the strategy received an Update on an order.
        self.logger.log_er_event(order=order,
                                 additional={
                                     "important_info": 555,
                                 })
        if order.status is Order.Accepted:
            # Cancelling order
            self.cancel(order)
            # Example on how to log when we cancel an order.
            self.logger.log_cancel_order_response(order=order, 
                                                  additional={
                                                        "important_info": 555,
                                                  })
        if order.status is Order.Partial:
            # Replacing order
            replaced_order = self.replace(size=order.size, price=3001, order=order)
            # Example on how to log when we replace an order.
            self.logger.log_replace_order_response(order=replaced_order, 
                                                   additional={
                                                        "important_info": 555,
                                                   })
        # Example on how to log messages related with the strategy.
        # data: dict with the data we want to send in the log
        amount = 10
        self.ws.log_strategy(data={"internal_log": "calculating new rate.", "internal_amount": amount})        

    def on_pause(self):
        # Example on how to log a pause event.
        # description: describe what the strategy do when this happend
        self.logger.log_pause_event(description="Se apreto pausa, cancelando ordenes")

    def on_error(self):
        # Example on how to log an error event.
        # description: describe what the strategy do when this happend
        self.logger.log_error_event(description="Ocurrio un error en la estrategia, cancelando ordenes")     

Server

Example on how to create a websocket server using arqLogger

Simple Logging Server

How to setup a simple websocket server that print in the stdout all message received.

import arqLogger

# Function to be call when a new message is received by the server
def on_new_log(log):
   print("Message received: {0}".format(log))


# start new Websocket Sever in localhost port 8001 and specify function to be call when new message arrived
arqLogger.start_websocket(8001, on_new_log)
Advance Logging Server

How to to create a server that logs all the messages received in a new file.

import logging
from datetime import datetime
from logging.handlers import RotatingFileHandler

import arqLogger

# create new logger
logger = logging.getLogger("Rotating Log")
logger.setLevel(logging.INFO)

# add a rotating handler
handler = RotatingFileHandler("log_file.log", maxBytes=1000000, backupCount=5)
logger.addHandler(handler)


def on_new_log(log):
    logger.info("%s - %s" % (datetime.now(), log))


# start new Websocket Sever in localhost port 8001 and specify function to be call when new message arrived
arqLogger.start_websocket(8001, on_new_log)

Author/Maintainer

Metadata

Release files for arqLogger 0.0.1b12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for arqLogger 0.0.1b12
File Size Uploaded Provenance
arqLogger-0.0.1b12.tar.gz 17.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for arqLogger 0.0.1b12
File Interpreter ABI Platform
arqLogger-0.0.1b12-py3-none-any.whl Python 3 none any Details

Total release size: 26.1 kB

Release files / arqLogger-0.0.1b12.tar.gz

Download URL arqLogger-0.0.1b12.tar.gz
Size 17.6 kB
Tags Source
SHA-256 checksum
How to use checksums
b3b173689b188bf6c6cdc532aa5f45538c852462e93d54837f31f80df4c8bd9c
BLAKE2b-256 checksum
How to use checksums
0e9c1a8d2f27bd84db77d5371aaa15c5fdbb3e94c8161c1e073b9b725763ed78
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9

Release files / arqLogger-0.0.1b12-py3-none-any.whl

Download URL arqLogger-0.0.1b12-py3-none-any.whl
Size 8.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ddc2a8e01add413c63b61d25625b04f0b7dda2517d75f57304a604f620966d6
BLAKE2b-256 checksum
How to use checksums
3d384234e05f4208fdd8d325c0b9c4a7ed8311f2d9ef60a323916fa399db4d4d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.1.0 requests-toolbelt/0.9.1 tqdm/4.47.0 CPython/3.6.9

Security for arqLogger 0.0.1b12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page