diff --git a/src/YoloAbstractions/Config/YoloConfig.cs b/src/YoloAbstractions/Config/YoloConfig.cs index 2eabd17..4c73306 100644 --- a/src/YoloAbstractions/Config/YoloConfig.cs +++ b/src/YoloAbstractions/Config/YoloConfig.cs @@ -9,7 +9,6 @@ public class YoloConfig public decimal? NominalCash { get; init; } public AssetPermissions AssetPermissions { get; init; } = AssetPermissions.SpotAndPerp; public string BaseAsset { get; init; } - public RebalanceMode RebalanceMode { get; init; } = - RebalanceMode.Slow; + public RebalanceMode RebalanceMode { get; init; } = RebalanceMode.Slow; public decimal SpreadSplit { get; init; } = 0.5m; } \ No newline at end of file diff --git a/src/YoloAbstractions/Trade.cs b/src/YoloAbstractions/Trade.cs index c41f97d..e378525 100644 --- a/src/YoloAbstractions/Trade.cs +++ b/src/YoloAbstractions/Trade.cs @@ -7,4 +7,7 @@ public record Trade( AssetType AssetType, decimal Amount, decimal? LimitPrice = null, - DateTime? Expiry = null); \ No newline at end of file + DateTime? Expiry = null) +{ + public bool IsTradeable => Amount != 0; +} \ No newline at end of file diff --git a/src/YoloBroker.Ftx/Config/FtxConfig.cs b/src/YoloBroker.Ftx/Config/FtxConfig.cs index 905b963..3c77e87 100644 --- a/src/YoloBroker.Ftx/Config/FtxConfig.cs +++ b/src/YoloBroker.Ftx/Config/FtxConfig.cs @@ -5,5 +5,6 @@ public class FtxConfig public string ApiKey { get; init; } public string Secret { get; init; } public string BaseAddress { get; init; } + public bool? PostOnly { get; init; } public string? SubAccount { get; init; } } \ No newline at end of file diff --git a/src/YoloBroker.Ftx/FtxBroker.cs b/src/YoloBroker.Ftx/FtxBroker.cs index 7179fea..1d2c056 100644 --- a/src/YoloBroker.Ftx/FtxBroker.cs +++ b/src/YoloBroker.Ftx/FtxBroker.cs @@ -43,7 +43,11 @@ public FtxBroker(FtxConfig config) BaseAddress = config.BaseAddress, SubaccountName = config.SubAccount }); + + PostOnly = config.PostOnly; } + + private bool? PostOnly { get; } public void Dispose() { @@ -69,6 +73,7 @@ public async IAsyncEnumerable PlaceTradesAsync( orderType, quantity, trade.LimitPrice, + postOnly: PostOnly, ct: ct); yield return new TradeResult( diff --git a/src/YoloKonsole/appsettings.json b/src/YoloKonsole/appsettings.json index 0ee4ef0..94a87d4 100644 --- a/src/YoloKonsole/appsettings.json +++ b/src/YoloKonsole/appsettings.json @@ -18,6 +18,7 @@ "FTX": { "ApiKey": "", "Secret": "", + "PostOnly": true, "BaseAddress": "https://ftx.com/api", "SubAccount": "" } diff --git a/src/YoloTrades/LoggerExtensions.cs b/src/YoloTrades/LoggerExtensions.cs index abd3b39..56d8359 100644 --- a/src/YoloTrades/LoggerExtensions.cs +++ b/src/YoloTrades/LoggerExtensions.cs @@ -82,4 +82,14 @@ public static partial void WithinTradeBuffer( decimal currentWeight, decimal constrainedTargetWeight, decimal delta); + + [LoggerMessage( + EventId = TradeEventIds.DeltaTooSmall, + Level = LogLevel.Information, + Message = + "({Token}): no action - delta too small to trade (delta: {Delta:0.0000})")] + public static partial void DeltaTooSmall( + this ILogger logger, + string token, + decimal delta); } \ No newline at end of file diff --git a/src/YoloTrades/TradeFactory.cs b/src/YoloTrades/TradeFactory.cs index d3d8b42..a764533 100644 --- a/src/YoloTrades/TradeFactory.cs +++ b/src/YoloTrades/TradeFactory.cs @@ -137,7 +137,12 @@ IEnumerable RebalancePositions(Weight w) var currentProjectedPosition = projectedPositions[trade.AssetName]; var newProjectedPosition = currentProjectedPosition + trade; projectedPositions[trade.AssetName] = newProjectedPosition; - yield return trade; + if (trade.IsTradeable) + yield return trade; + else + { + _logger.DeltaTooSmall(token, remainingDelta); + } remainingDelta = remainingDeltaPostTrade; } } @@ -205,16 +210,18 @@ AssetType.Spot when weight + remainingDelta < 0 && var factor = isBuy ? SpreadSplit : 1 - SpreadSplit; var spread = market.Ask!.Value - market.Bid!.Value; var rawLimitPrice = market.Bid!.Value + spread * factor; - var limitPrice = Math.Floor(rawLimitPrice / market.PriceStep) * market.PriceStep; + var limitPriceSteps = rawLimitPrice / market.PriceStep; + var limitPrice = (isBuy ? Math.Floor(limitPriceSteps) : Math.Ceiling(limitPriceSteps)) * market.PriceStep; var trade = new Trade(market.Name, market.AssetType, size, limitPrice); - _logger.GeneratedTrade(token, delta, trade); + if (trade.IsTradeable) + _logger.GeneratedTrade(token, delta, trade); remainingDelta -= delta; yield return (trade, remainingDelta); - if (restart) + if (restart || remainingDelta == 0) { break; } diff --git a/src/YoloTrades/WellKnown.cs b/src/YoloTrades/WellKnown.cs index 89b119d..35c7b1e 100644 --- a/src/YoloTrades/WellKnown.cs +++ b/src/YoloTrades/WellKnown.cs @@ -8,6 +8,7 @@ public static class TradeEventIds internal const int WithinTradeBuffer = 110; internal const int GeneratedTrade = 111; internal const int MarketPositions = 112; + internal const int DeltaTooSmall = 113; internal const int NoMarkets = 151; internal const int MultiplePositions = 152; internal const int NoAsk = 152; diff --git a/test/YoloTrades.Test/Data/json/003_ExistingPositions/markets.json b/test/YoloTrades.Test/Data/json/003_ExistingPositions/markets.json new file mode 100644 index 0000000..e37dbf1 --- /dev/null +++ b/test/YoloTrades.Test/Data/json/003_ExistingPositions/markets.json @@ -0,0 +1,302 @@ +{ + "BCH": [ + { + "Name": "BCH-PERP", + "BaseAsset": "BCH", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.05, + "QuantityStep": 0.001, + "Ask": 434.35, + "Bid": 434.3, + "Last": 434.3, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "BCH-PERP-Future" + }, + { + "Name": "BCH/USD", + "BaseAsset": "BCH", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.025, + "QuantityStep": 0.001, + "Ask": 434.375, + "Bid": 434.25, + "Last": 434.275, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "BCH/USD-Spot" + } + ], + "BTC": [ + { + "Name": "BTC-PERP", + "BaseAsset": "BTC", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 1.0, + "QuantityStep": 0.0001, + "Ask": 46732.0, + "Bid": 46731.0, + "Last": 46731.0, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "BTC-PERP-Future" + }, + { + "Name": "BTC/USD", + "BaseAsset": "BTC", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 1.0, + "QuantityStep": 0.0001, + "Ask": 46735.0, + "Bid": 46734.0, + "Last": 46736.0, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "BTC/USD-Spot" + } + ], + "CRO": [ + { + "Name": "CRO-PERP", + "BaseAsset": "CRO", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.000025, + "QuantityStep": 10.0, + "Ask": 0.52645, + "Bid": 0.5264, + "Last": 0.5264, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "CRO-PERP-Future" + }, + { + "Name": "CRO/USD", + "BaseAsset": "CRO", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.000025, + "QuantityStep": 10.0, + "Ask": 0.527625, + "Bid": 0.526825, + "Last": 0.527075, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "CRO/USD-Spot" + } + ], + "DOGE": [ + { + "Name": "DOGE-PERP", + "BaseAsset": "DOGE", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 5E-7, + "QuantityStep": 1.0, + "Ask": 0.1725025, + "Bid": 0.172502, + "Last": 0.172502, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "DOGE-PERP-Future" + }, + { + "Name": "DOGE/USD", + "BaseAsset": "DOGE", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 5E-7, + "QuantityStep": 1.0, + "Ask": 0.172564, + "Bid": 0.1725425, + "Last": 0.172599, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "DOGE/USD-Spot" + } + ], + "ETH": [ + { + "Name": "ETH-PERP", + "BaseAsset": "ETH", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.1, + "QuantityStep": 0.001, + "Ask": 3942.9, + "Bid": 3942.8, + "Last": 3942.5, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "ETH-PERP-Future" + }, + { + "Name": "ETH/USD", + "BaseAsset": "ETH", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.1, + "QuantityStep": 0.001, + "Ask": 3942.2, + "Bid": 3942.1, + "Last": 3942.1, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "ETH/USD-Spot" + } + ], + "FTT": [ + { + "Name": "FTT-PERP", + "BaseAsset": "FTT", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.0005, + "QuantityStep": 0.1, + "Ask": 39.809, + "Bid": 39.8085, + "Last": 39.8155, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "FTT-PERP-Future" + }, + { + "Name": "FTT/USD", + "BaseAsset": "FTT", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.001, + "QuantityStep": 0.1, + "Ask": 39.808, + "Bid": 39.792, + "Last": 39.808, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "FTT/USD-Spot" + } + ], + "LINK": [ + { + "Name": "LINK-PERP", + "BaseAsset": "LINK", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.0005, + "QuantityStep": 0.1, + "Ask": 19.3755, + "Bid": 19.375, + "Last": 19.369, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "LINK-PERP-Future" + }, + { + "Name": "LINK/USD", + "BaseAsset": "LINK", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.0005, + "QuantityStep": 0.1, + "Ask": 19.3685, + "Bid": 19.363, + "Last": 19.363, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "LINK/USD-Spot" + } + ], + "LTC": [ + { + "Name": "LTC-PERP", + "BaseAsset": "LTC", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.01, + "QuantityStep": 0.01, + "Ask": 148.8, + "Bid": 148.79, + "Last": 148.8, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "LTC-PERP-Future" + }, + { + "Name": "LTC/USD", + "BaseAsset": "LTC", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.005, + "QuantityStep": 0.01, + "Ask": 148.805, + "Bid": 148.795, + "Last": 148.795, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "LTC/USD-Spot" + } + ], + "UNI": [ + { + "Name": "UNI-PERP", + "BaseAsset": "UNI", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.001, + "QuantityStep": 0.1, + "Ask": 15.823, + "Bid": 15.815, + "Last": 15.817, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "UNI-PERP-Future" + }, + { + "Name": "UNI/USD", + "BaseAsset": "UNI", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.001, + "QuantityStep": 0.1, + "Ask": 15.816, + "Bid": 15.809, + "Last": 15.829, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "UNI/USD-Spot" + } + ], + "XRP": [ + { + "Name": "XRP-PERP", + "BaseAsset": "XRP", + "QuoteAsset": null, + "AssetType": "Future", + "PriceStep": 0.000025, + "QuantityStep": 1.0, + "Ask": 0.82335, + "Bid": 0.823325, + "Last": 0.823475, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "XRP-PERP-Future" + }, + { + "Name": "XRP/USD", + "BaseAsset": "XRP", + "QuoteAsset": "USD", + "AssetType": "Spot", + "PriceStep": 0.000025, + "QuantityStep": 1.0, + "Ask": 0.8233, + "Bid": 0.823275, + "Last": 0.8234, + "Expiry": null, + "TimeStamp": "12/18/2021 18:52:52", + "Key": "XRP/USD-Spot" + } + ] +} \ No newline at end of file diff --git a/test/YoloTrades.Test/Data/json/003_ExistingPositions/positions.json b/test/YoloTrades.Test/Data/json/003_ExistingPositions/positions.json new file mode 100644 index 0000000..5fd0616 --- /dev/null +++ b/test/YoloTrades.Test/Data/json/003_ExistingPositions/positions.json @@ -0,0 +1,120 @@ +{ + "BTC": [ + { + "AssetName": "BTC-PERP", + "BaseAsset": "BTC", + "AssetType": "Future", + "Amount": 0.0 + }, + { + "AssetName": "BTC", + "BaseAsset": "BTC", + "AssetType": "Spot", + "Amount": 0.02 + } + ], + "ETH": [ + { + "AssetName": "ETH-PERP", + "BaseAsset": "ETH", + "AssetType": "Future", + "Amount": 0.005 + } + ], + "LINK": [ + { + "AssetName": "LINK-PERP", + "BaseAsset": "LINK", + "AssetType": "Future", + "Amount": 0.0 + }, + { + "AssetName": "LINK", + "BaseAsset": "LINK", + "AssetType": "Spot", + "Amount": -1.10049568 + } + ], + "DOGE": [ + { + "AssetName": "DOGE-PERP", + "BaseAsset": "DOGE", + "AssetType": "Future", + "Amount": 0.0 + }, + { + "AssetName": "DOGE", + "BaseAsset": "DOGE", + "AssetType": "Spot", + "Amount": -231.08172185 + } + ], + "UNI": [ + { + "AssetName": "UNI-PERP", + "BaseAsset": "UNI", + "AssetType": "Future", + "Amount": 0.0 + }, + { + "AssetName": "UNI", + "BaseAsset": "UNI", + "AssetType": "Spot", + "Amount": -3.20056165 + } + ], + "FTT": [ + { + "AssetName": "FTT-PERP", + "BaseAsset": "FTT", + "AssetType": "Future", + "Amount": 0.0 + }, + { + "AssetName": "FTT", + "BaseAsset": "FTT", + "AssetType": "Spot", + "Amount": 0.0 + } + ], + "CRO": [ + { + "AssetName": "CRO-PERP", + "BaseAsset": "CRO", + "AssetType": "Future", + "Amount": 50.0 + } + ], + "USD": [ + { + "AssetName": "USD", + "BaseAsset": "USD", + "AssetType": "Spot", + "Amount": 210.68488425 + } + ], + "BCH": [ + { + "AssetName": "BCH", + "BaseAsset": "BCH", + "AssetType": "Spot", + "Amount": -0.06106879 + } + ], + "LTC": [ + { + "AssetName": "LTC", + "BaseAsset": "LTC", + "AssetType": "Spot", + "Amount": -0.2102401 + } + ], + "XRP": [ + { + "AssetName": "XRP", + "BaseAsset": "XRP", + "AssetType": "Spot", + "Amount": -1.00047798 + } + ] +} \ No newline at end of file diff --git a/test/YoloTrades.Test/Data/json/003_ExistingPositions/weights.json b/test/YoloTrades.Test/Data/json/003_ExistingPositions/weights.json new file mode 100644 index 0000000..9a96c96 --- /dev/null +++ b/test/YoloTrades.Test/Data/json/003_ExistingPositions/weights.json @@ -0,0 +1,82 @@ +[ + { + "Price": 0.520925, + "ComboWeight": 0.0390933455044346, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": 0.108870967741935, + "Ticker": "CRO/USD", + "TrendFactor": -0.0306842767330662 + }, + { + "Price": 18.273, + "ComboWeight": -0.0820098034949625, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": -0.100806451612903, + "Ticker": "LINK/USD", + "TrendFactor": -0.0632131553770217 + }, + { + "Price": 0.796925, + "ComboWeight": -0.000216167005514821, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": 0.0685483870967743, + "Ticker": "XRP/USD", + "TrendFactor": -0.0689807211078039 + }, + { + "Price": 14.989, + "ComboWeight": -0.0743433377590842, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": -0.0685483870967741, + "Ticker": "UNI/USD", + "TrendFactor": -0.0801382884213944 + }, + { + "Price": 37.553, + "ComboWeight": -0.0896005771168851, + "Date": " 12/17/2021 00:00:00", + "MomentumFactor": -0.0967741935483871, + "Ticker": "FTT/USD", + "TrendFactor": -0.0824269606853831 + }, + { + "Price": 144.04, + "ComboWeight": -0.12488898210476, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": -0.185483870967742, + "Ticker": "LTC/USD", + "TrendFactor": -0.0642940932417782 + }, + { + "Price": 46156, + "ComboWeight": -0.0309871629722613, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": 5.7301833529E-17, + "Ticker": "BTC/USD", + "TrendFactor": -0.0619743259445226 + }, + { + "Price": 424.65, + "ComboWeight": -0.0647093597049423, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": -0.0483870967741935, + "Ticker": "BCH/USD", + "TrendFactor": -0.0810316226356911 + }, + { + "Price": 3875.8, + "ComboWeight": 0.0801186410013854, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": 0.205645161290323, + "Ticker": "ETH/USD", + "TrendFactor": -0.0454078792875519 + }, + { + "Price": 0.1685335, + "ComboWeight": 0.030171289844435, + "Date": "12/17/2021 00:00:00", + "MomentumFactor": 0.116935483870968, + "Ticker": "DOGE/USD", + "TrendFactor": -0.0565929041820976 + } +] \ No newline at end of file diff --git a/test/YoloTrades.Test/TradeFactoryTests.cs b/test/YoloTrades.Test/TradeFactoryTests.cs index efd9c2b..dc363cd 100644 --- a/test/YoloTrades.Test/TradeFactoryTests.cs +++ b/test/YoloTrades.Test/TradeFactoryTests.cs @@ -72,8 +72,11 @@ public void ShouldCalculateTradesFromCsv( [Theory] [InlineData("./Data/json/001")] + [InlineData("./Data/json/002_LongSpotAndPerp", AssetPermissions.LongSpotAndPerp)] + [InlineData("./Data/json/003_ExistingPositions")] public async Task ShouldCalculateTrades( string path, + AssetPermissions assetPermissions = AssetPermissions.All, string baseCurrency = "USD", decimal nominalCash = 10000, decimal tradeBuffer = 0.04m, @@ -83,6 +86,7 @@ public async Task ShouldCalculateTrades( var config = new YoloConfig { + AssetPermissions = assetPermissions, BaseAsset = baseCurrency, NominalCash = nominalCash, RebalanceMode = rebalanceMode, @@ -95,7 +99,9 @@ public async Task ShouldCalculateTrades( var trades = tradeFactory.CalculateTrades(weights, positions, markets); Assert.NotNull(trades); - trades.MatchSnapshot(); + + var directory = path[(path.LastIndexOf("/", StringComparison.InvariantCulture) + 1)..]; + trades.MatchSnapshot($"ShouldCalculateTrades_{directory}"); } private static diff --git a/test/YoloTrades.Test/YoloTrades.Test.csproj b/test/YoloTrades.Test/YoloTrades.Test.csproj index 598a791..2590a09 100644 --- a/test/YoloTrades.Test/YoloTrades.Test.csproj +++ b/test/YoloTrades.Test/YoloTrades.Test.csproj @@ -44,10 +44,33 @@ PreserveNewest - - - - + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + diff --git a/test/YoloTrades.Test/__snapshots__/ShouldCalculateTradesFromCsv_YOLOTradeHelperv420211212.csv.snap b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTradesFromCsv_YOLOTradeHelperv420211212.csv.snap index 845ba17..cc6ac6f 100644 --- a/test/YoloTrades.Test/__snapshots__/ShouldCalculateTradesFromCsv_YOLOTradeHelperv420211212.csv.snap +++ b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTradesFromCsv_YOLOTradeHelperv420211212.csv.snap @@ -4,62 +4,71 @@ "AssetType": "Spot", "Amount": -0.5986, "LimitPrice": 459.5500, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "BTC/USD", "AssetType": "Spot", "Amount": 0.0025, "LimitPrice": 49413.0000, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "CRO/USD", "AssetType": "Spot", "Amount": 947.4349, "LimitPrice": 0.5783, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "DOGE/USD", "AssetType": "Spot", "Amount": -4131.0624, - "LimitPrice": 0.1688, - "Expiry": null + "LimitPrice": 0.1689, + "Expiry": null, + "IsTradeable": true }, { "AssetName": "ETH/USD", "AssetType": "Spot", "Amount": 0.0949, "LimitPrice": 4091.2000, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "FTT/USD", "AssetType": "Spot", "Amount": -13.1617, "LimitPrice": 40.4420, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "LINK/USD", "AssetType": "Spot", "Amount": -30.3962, "LimitPrice": 19.9700, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "LTC/USD", "AssetType": "Spot", "Amount": -3.3773, "LimitPrice": 158.0900, - "Expiry": null + "Expiry": null, + "IsTradeable": true }, { "AssetName": "UNI/USD", "AssetType": "Spot", "Amount": -64.4732, "LimitPrice": 15.8900, - "Expiry": null + "Expiry": null, + "IsTradeable": true } ] diff --git a/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_001.snap b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_001.snap new file mode 100644 index 0000000..c86ddbd --- /dev/null +++ b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_001.snap @@ -0,0 +1,50 @@ +[ + { + "AssetName": "XRP/USD", + "AssetType": "Spot", + "Amount": -680.0, + "LimitPrice": 0.784975, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "LINK/USD", + "AssetType": "Spot", + "Amount": -44.6, + "LimitPrice": 19.4420, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "FTT-PERP", + "AssetType": "Future", + "Amount": -6.6, + "LimitPrice": 43.1870, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "CRO-PERP", + "AssetType": "Future", + "Amount": 1980.0, + "LimitPrice": 0.548750, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "DOGE/USD", + "AssetType": "Spot", + "Amount": -3774.0, + "LimitPrice": 0.1636025, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "ETH/USD", + "AssetType": "Spot", + "Amount": 0.106, + "LimitPrice": 3957.5, + "Expiry": null, + "IsTradeable": true + } +] diff --git a/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_002_LongSpotAndPerp.snap b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_002_LongSpotAndPerp.snap new file mode 100644 index 0000000..a99037b --- /dev/null +++ b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_002_LongSpotAndPerp.snap @@ -0,0 +1,66 @@ +[ + { + "AssetName": "FTT-PERP", + "AssetType": "Future", + "Amount": -10.4, + "LimitPrice": 47.6755, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "ETH-PERP", + "AssetType": "Future", + "Amount": 0.004, + "LimitPrice": 4054.0, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "LTC-PERP", + "AssetType": "Future", + "Amount": 0.29, + "LimitPrice": 192.42, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "DOGE-PERP", + "AssetType": "Future", + "Amount": -3195.0, + "LimitPrice": 0.2032005, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "CRO/USD", + "AssetType": "Spot", + "Amount": 1390.0, + "LimitPrice": 0.787100, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "BCH/USD", + "AssetType": "Spot", + "Amount": 0.218, + "LimitPrice": 558.700, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "UNI-PERP", + "AssetType": "Future", + "Amount": -29.4, + "LimitPrice": 19.283, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "LINK-PERP", + "AssetType": "Future", + "Amount": -20.2, + "LimitPrice": 23.9525, + "Expiry": null, + "IsTradeable": true + } +] diff --git a/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_003_ExistingPositions.snap b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_003_ExistingPositions.snap new file mode 100644 index 0000000..9bfbd5b --- /dev/null +++ b/test/YoloTrades.Test/__snapshots__/ShouldCalculateTrades_003_ExistingPositions.snap @@ -0,0 +1,58 @@ +[ + { + "AssetName": "LINK/USD", + "AssetType": "Spot", + "Amount": -20.6, + "LimitPrice": 19.3660, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "UNI/USD", + "AssetType": "Spot", + "Amount": -18.6, + "LimitPrice": 15.813, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "FTT-PERP", + "AssetType": "Future", + "Amount": -12.5, + "LimitPrice": 39.8090, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "LTC/USD", + "AssetType": "Spot", + "Amount": -5.50, + "LimitPrice": 148.800, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "BTC/USD", + "AssetType": "Spot", + "Amount": -0.0181, + "LimitPrice": 46735.0, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "BCH/USD", + "AssetType": "Spot", + "Amount": -0.508, + "LimitPrice": 434.325, + "Expiry": null, + "IsTradeable": true + }, + { + "AssetName": "ETH-PERP", + "AssetType": "Future", + "Amount": 0.096, + "LimitPrice": 3942.8, + "Expiry": null, + "IsTradeable": true + } +]