This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"book": "trend_following", | |
"datetime": "20210101", | |
"total_equity": 1000, | |
"turnover": 1000000 | |
}, | |
{ | |
"book": "trend_following", | |
"datetime": "20210201", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Newtonsoft.Json; | |
using System; | |
using System.Collections.Generic; | |
using System.Net.WebSockets; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Security.Cryptography; | |
using System.Text; | |
public class AsymmetricEncryptionExample | |
{ | |
public static void Main(string[] args) | |
{ | |
try | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Net.Http; | |
using System.Threading.Tasks; | |
/* | |
OKX API | |
OKX REST API addresses: | |
REST: https://www.okx.com/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]"; |