Skip to content

Instantly share code, notes, and snippets.

View shaunsales's full-sized avatar
🛀
coding

Shaun Sales shaunsales

🛀
coding
View GitHub Profile
public sealed class Position
{
public string PositionId { get; init; } = string.Empty;
public string StrategyJobId { get; init; } = string.Empty;
public DateTime EntryTimestamp { get; init; }
public DateTime ExitTimestamp { get; init; }
using System;
using Confluent.Kafka;
using Fraction.Services.Messaging.Common.Consumers;
using Fraction.Services.Messaging.Common.Helpers;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using Fraction.Services.Common.Enums;
using Fraction.Services.Messaging.Common.Messages;
using Fraction.Services.Messaging.Common.Producers;
using System;
using Newtonsoft.Json;
using Confluent.Kafka;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Options;
using Fraction.Services.Messaging.Common.Helpers;
using Fraction.Services.Messaging.Common.Messages;
@shaunsales
shaunsales / APICalls.cs
Created February 8, 2019 16:44
Gateway Requests
var latestNews = await dispatcher.QueryAsync<GetLatestNews, GetLatestNewsResponse>(new GetLatestNews
{
QueryId = Environment.TickCount,
ItemCount = 6
});
var quoteTicker = await dispatcher.QueryAsync<GetQuoteTicker, GetQuoteTickerResponse>(new GetQuoteTicker
{
QueryId = Environment.TickCount,
ItemCount = 5
@shaunsales
shaunsales / PackInt32.cs
Last active January 8, 2019 14:43
Packing two Int32s into an single Int32
// 'ABC' as an int
var base26 = 731;
// '1234'
var base10 = 1234;
// Bitshift the base-26 int to left half, then OR the base-10
int result = (base26 << 16) | base10 & 0xFFFF;
@shaunsales
shaunsales / FastStringToInt.cs
Last active January 8, 2019 14:10
Fast String to Int Converter
// Our example symbol
var symbol = "ABC-1234";
// Get the last 4 digits of our symbol
var str = symbol.AsSpan(4, 4);
var base10 = 0;
for (i = 0; i < 4; i++)
{
@shaunsales
shaunsales / Base26ToBase10.cs
Last active January 8, 2019 14:07
Convert Base26 to Base10
// Our example symbol
var symbol = "ABC-1234";
// Use a lookup to avoid calling Math.Pow in a code hot path
int[] Base26Pow = { 1, 26, 676 };
// Get the first 3 digits of our symbol
var base26 = symbol.AsSpan(0, 3);
var base10 = 0;
using System;
using System.Text;
namespace MatchingEngine.Utils
{
internal static class SymbolConversion
{
/// <summary>
/// Converts a symbol matching the format AAA-1234 to an integer.
/// Stores the letter component in the most significant two bytes and the numeric component in the least significant two bytes.
using UnityEngine;
using System;
public class MonoSingleton<T> : MonoBehaviour where T : class
{
/// <summary>
/// Makes the object singleton not be destroyed automatically when loading a new scene.
/// </summary>
public bool DontDestroy;
@shaunsales
shaunsales / roadmap.md
Last active June 8, 2018 03:27
Dehash Roadmap

Dehash Platform Roadmap

Dehash is a platform dedicated to creating the best cryptocurrency data and research tools.

Q2 2018

  1. Living Home Screen A landing screen that summarises updates across coin markets, ICOs and crypto news feeds since you last checked
  2. Coin Markets An easy way for users to view a list of all current coins traded on the market by 24h volume
  3. Coin Detail Get detailed coin performance data such as trading charts, market data, security info, exchange availability, site links, developer info, regional data and network/mining data
  4. News Latest breaking news from multiple, reliable crypto news feeds
  5. ICOs Get access to live and upcoming ICOs with data on the offer size, and research lnks
  6. Exchanges See a detailed summary of all major crypto exchanges, and check the pricing section for arbitrage opportunities

Q3 2018