Skip to content

Instantly share code, notes, and snippets.

@normanlmfung
normanlmfung / json
Created March 30, 2024 08:29
trend_following_total_equity (This is for pandas syntax illustration)
[
{
"book": "trend_following",
"datetime": "20210101",
"total_equity": 1000,
"turnover": 1000000
},
{
"book": "trend_following",
"datetime": "20210201",
import pandas as pd
import numpy as np
from datetime import datetime
from tabulate import tabulate
# Illusttration 1. Load some dummy data
pd_total_equity = None
strategies = [ 'trend_following', 'statsarb', 'triarb' ]
strategies_total_equities = {}
for strategy in strategies:
var lazyString = new Lazy<string>(
() =>
{
// Here you can do some complex processing
// and then return a value.
Console.WriteLine("Inside lazy loader");
return "Lazy loading!";
});
Console.WriteLine($"Is value created: {lazyString.IsValueCreated}"); // false
using System;
using System.Collections.Generic;
using System.Text.RegularExpressions;
class Program
{
static void Main(string[] args)
{
// Example 1. Simple List
List<float> floatList = new List<float> { 1.1f, 2.2f, 3.3f, 4.4f, 5.5f };
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Net.WebSockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
/*
using System.Threading;
using System.Threading.Tasks;
using System.Net.Http;
/*
Processor Afffinity https://stackoverflow.com/questions/2510593/how-can-i-set-processor-affinity-to-a-thread-or-a-task-in-net
ConfigureAwait - When an asynchronous method awaits a Task directly, continuation usually occurs in the same thread that created the task, depending on the async context. This behavior can be costly in terms of performance and can result in a deadlock on the UI thread. To avoid these problems, call Task.ConfigureAwait(false).
https://learn.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.configureawait?view=net-8.0
What's SynchronizationContext?
using System;
using System.Collections.Concurrent;
using System.Threading;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
// Create a concurrent queue to store lambda expressions
using System;
using System.Security.Cryptography;
using System.Text;
public class AsymmetricEncryptionExample
{
public static void Main(string[] args)
{
try
{
using System;
using System.Net.Http;
using System.Threading.Tasks;
/*
OKX API
OKX REST API addresses:
REST: https://www.okx.com/
using System;
using System.Text.RegularExpressions;
class Program
{
static void Main()
{
// https://www.mikesdotnetting.com/article/46/c-regular-expressions-cheat-sheet
string emailAddress = "[email protected]";