Test posting source code

wasin.w
wasin.w admin

I am testing post the source code here:

From Jupyter notebook

import lseg.data as ld
from lseg.data.content import historical_pricing
import pandas as pd
print(ld.__version__)
ld.open_session()
ld.get_data(
    universe=['/BTC='],
    fields=['BID','ASK']    
)

From Visual Studio 2022

Log.Level = NLog.LogLevel.Debug;
try
{
    // Create the platform session.
    using ISession session = Sessions.GetSession();

    // Open the session
    session.Open();

    // Retrieve tick pricing events.  Default: 20 rows of data.  Specified trades only and specific columns of data.
    var response = Events.Definition("BTC=")
                    .EventTypes(Events.EventType.trade)
                    .Fields("RTL", "EVENT_TYPE", "TRDPRC_1", "TRDVOL_1", "QUALIFIERS")
                    .GetData();
    Common.DisplayTable("Historical Trade events", response);

    // Retrieve tick events for a group of instruments..
    response = Events.Definition().Universe("/BTC=").GetData();
    Common.DisplayTable("Historical events for multiple instruments", response);
}
catch (Exception e)
{
    Console.WriteLine($"\n**************\nFailed to execute.");
    Console.WriteLine($"Exception: {e.GetType().Name} {e.Message}");
    if (e.InnerException is not null) Console.WriteLine(e.InnerException);
    Console.WriteLine("***************");
}

From IntelliJ IDEA

AppClient appClient = new AppClient();

consumer = EmaFactory.createOmmConsumer(EmaFactory.createOmmConsumerConfig() .host("localhost:14002").username("user"));

ElementList view = EmaFactory.createElementList();
OmmArray array = EmaFactory.createOmmArray();

array.fixedWidth(2);
array.add(EmaFactory.createOmmArrayEntry().intValue(22));
array.add(EmaFactory.createOmmArrayEntry().intValue(25)); view.add(EmaFactory.createElementEntry().uintValue(EmaRdm.ENAME_VIEW_TYPE, 1));
view.add(EmaFactory.createElementEntry().array(EmaRdm.ENAME_VIEW_DATA, array)); ReqMsg reqMsg = EmaFactory.createReqMsg();
reqMsg.domainType(EmaRdm.MMT_MARKET_PRICE)
.serviceName("ELEKTRON_DD")
.name("JPY=")
.payload(view)
.priority(1, 1)
.initialImage(true)
.interestAfterRefresh(true);
long handle = consumer.registerClient(reqMsg, appClient);

From Visual Studio Code

import WebSocket from "ws";

const ws = new WebSocket("ws://localhost:15000/WebSocket","tr_json2");

import { networkInterfaces } from "os";
const netInterfaces = networkInterfaces();
const [{ address }] = Object.values(netInterfaces).flatMap((netInterface) =>
netInterface!.filter((prop) => prop.family === "IPv4" && !prop.internal)
);

let ric: string = "/LSEG.L";
let snapshot: boolean = false;
const servicename: string = "ELEKTRON_DD";

ws.on("open", () => {
console.log("Establish a connection success");
loginWS();
});

ws.on("message", (message: string) => {

const parsedMsg = JSON.parse(message);
console.log(`Received message from server: ${JSON.stringify(parsedMsg, null, 2)}`);

for (var index = 0; index < parsedMsg.length; ++index)
processMessage(parsedMsg[index]);
});

From CodeBook

stream = rdp_stream.Definition(
service = None,
api = "streaming.quantitative-analytics.endpoints.financial-contracts",
universe = {
"instrumentType": "FxCross",
"instrumentDefinition": {
"instrumentTag": "USDAUD",
"fxCrossType": "FxSpot",
"fxCrossCode": "USDAUD"
}
},
parameters = None,
extended_params = {
"marketData": {
"fxSpots": [
{
"spotDefinition": {
"fxCrossCode": "AUDUSD",
"Source": "Composite"
}
}
]
}
},
view = ["InstrumentTag", "FxSpot_BidMidAsk", "ErrorCode", "Ccy1SpotDate", "Ccy2SpotDate"],
).get_stream()

Note:

  • From the code book, need to choose "codeblock" format and paste to keep the format.
  • If you paste before format "codeblock", all format are lost.