Skip to content

Commit 6faf7dd

Browse files
authored
Merge pull request #2 from Joseph-Matteo-Scorsone/databento-integration
Initial code for DataBento Implementation.
2 parents 7e66db5 + 8e5574c commit 6faf7dd

18 files changed

+2973
-0
lines changed

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Build & Test
2+
3+
on:
4+
push:
5+
branches: ['*']
6+
pull_request:
7+
branches: [master]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-24.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v2
15+
16+
- name: Liberate disk space
17+
uses: jlumbroso/free-disk-space@main
18+
with:
19+
tool-cache: true
20+
large-packages: false
21+
docker-images: false
22+
swap-storage: false
23+
24+
- name: Checkout Lean Same Branch
25+
id: lean-same-branch
26+
uses: actions/checkout@v2
27+
continue-on-error: true
28+
with:
29+
ref: ${{ github.ref }}
30+
repository: QuantConnect/Lean
31+
path: Lean
32+
33+
- name: Checkout Lean Master
34+
if: steps.lean-same-branch.outcome != 'success'
35+
uses: actions/checkout@v2
36+
with:
37+
repository: QuantConnect/Lean
38+
path: Lean
39+
40+
- name: Move Lean
41+
run: mv Lean ../Lean
42+
43+
- uses: addnab/docker-run-action@v3
44+
with:
45+
image: quantconnect/lean:foundation
46+
options: --workdir /__w/Lean.DataSource.SDK/Lean.DataSource.SDK -v /home/runner/work:/__w
47+
shell: bash
48+
run: |
49+
# BuildDataSource
50+
dotnet build ./QuantConnect.DataSource.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1 && \
51+
# BuildTests
52+
dotnet build ./tests/Tests.csproj /p:Configuration=Release /v:quiet /p:WarningLevel=1 && \
53+
# Run Tests
54+
dotnet test ./tests/bin/Release/net9.0/Tests.dll

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,16 @@ modules.order
5050
Module.symvers
5151
Mkfile.old
5252
dkms.conf
53+
54+
# Build results
55+
[Dd]ebug/
56+
[Dd]ebugPublic/
57+
[Rr]elease/
58+
[Rr]eleases/
59+
x64/
60+
x86/
61+
.vs/
62+
build/
63+
bld/
64+
[Bb]in/
65+
[Oo]bj/

Demonstration.cs

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3+
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
using QuantConnect.Algorithm;
18+
using QuantConnect.Data.Market;
19+
using QuantConnect.Interfaces;
20+
using QuantConnect;
21+
using QuantConnect.Data;
22+
using QuantConnect.Securities.Future;
23+
using QuantConnect.Util;
24+
using System;
25+
26+
namespace QuantConnect.Algorithm.CSharp
27+
{
28+
public class DatabentoFuturesTestAlgorithm : QCAlgorithm
29+
{
30+
private Future _es;
31+
32+
public override void Initialize()
33+
{
34+
Log("Algorithm Initialize");
35+
36+
SetStartDate(2025, 10, 1);
37+
SetEndDate(2025, 10, 16);
38+
SetCash(100000);
39+
40+
var exp = new DateTime(2025, 12, 19);
41+
var symbol = QuantConnect.Symbol.CreateFuture("ES", Market.CME, exp);
42+
_es = AddFutureContract(symbol, Resolution.Second, true, 1, true);
43+
}
44+
45+
public override void OnData(Slice slice)
46+
{
47+
if (!slice.HasData)
48+
{
49+
Log("Slice has no data");
50+
return;
51+
}
52+
53+
Log($"OnData: Slice has {slice.Count} data points");
54+
55+
// For Tick resolution, check Ticks collection
56+
if (slice.Ticks.ContainsKey(_es.Symbol))
57+
{
58+
var ticks = slice.Ticks[_es.Symbol];
59+
Log($"Received {ticks.Count} ticks for {_es.Symbol}");
60+
61+
foreach (var tick in ticks)
62+
{
63+
if (tick.TickType == TickType.Trade)
64+
{
65+
Log($"Trade Tick - Price: {tick.Price}, Quantity: {tick.Quantity}, Time: {tick.Time}");
66+
}
67+
else if (tick.TickType == TickType.Quote)
68+
{
69+
Log($"Quote Tick - Bid: {tick.BidPrice}x{tick.BidSize}, Ask: {tick.AskPrice}x{tick.AskSize}, Time: {tick.Time}");
70+
}
71+
}
72+
}
73+
74+
// These won't have data for Tick resolution
75+
if (slice.Bars.ContainsKey(_es.Symbol))
76+
{
77+
var bar = slice.Bars[_es.Symbol];
78+
Log($"Bar - O:{bar.Open} H:{bar.High} L:{bar.Low} C:{bar.Close} V:{bar.Volume}");
79+
}
80+
}
81+
}
82+
}

DemonstrationUniverse.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3+
* Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software
10+
* distributed under the License is distributed on an "AS IS" BASIS,
11+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
* See the License for the specific language governing permissions and
13+
* limitations under the License.
14+
*
15+
*/
16+
17+
using System.Linq;
18+
using QuantConnect.Data.UniverseSelection;
19+
using QuantConnect.DataSource;
20+
21+
namespace QuantConnect.Algorithm.CSharp
22+
{
23+
/// <summary>
24+
/// Example algorithm using the custom data type as a source of alpha
25+
/// </summary>
26+
public class CustomDataUniverse : QCAlgorithm
27+
{ }
28+
}

Lean.DataSource.DataBento.sln

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
Microsoft Visual Studio Solution File, Format Version 12.00
2+
# Visual Studio Version 17
3+
VisualStudioVersion = 17.5.2.0
4+
MinimumVisualStudioVersion = 10.0.40219.1
5+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuantConnect.DataBento", "QuantConnect.DataBento\QuantConnect.DataSource.DataBento.csproj", "{367AEEDC-F0B3-7F47-539D-10E5EC242C2A}"
6+
EndProject
7+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QuantConnect.DataBento.Tests", "QuantConnect.DataBento.Tests\QuantConnect.DataSource.DataBento.Tests.csproj", "{9CF47860-2CEA-F379-09D8-9AEF27965D12}"
8+
EndProject
9+
Global
10+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
11+
Debug|Any CPU = Debug|Any CPU
12+
Release|Any CPU = Release|Any CPU
13+
EndGlobalSection
14+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
15+
{367AEEDC-F0B3-7F47-539D-10E5EC242C2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
16+
{367AEEDC-F0B3-7F47-539D-10E5EC242C2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
17+
{367AEEDC-F0B3-7F47-539D-10E5EC242C2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
18+
{367AEEDC-F0B3-7F47-539D-10E5EC242C2A}.Release|Any CPU.Build.0 = Release|Any CPU
19+
{4B379C8F-16CE-1972-73E3-C14F6410D428}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
20+
{4B379C8F-16CE-1972-73E3-C14F6410D428}.Debug|Any CPU.Build.0 = Debug|Any CPU
21+
{4B379C8F-16CE-1972-73E3-C14F6410D428}.Release|Any CPU.ActiveCfg = Release|Any CPU
22+
{4B379C8F-16CE-1972-73E3-C14F6410D428}.Release|Any CPU.Build.0 = Release|Any CPU
23+
{9CF47860-2CEA-F379-09D8-9AEF27965D12}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
24+
{9CF47860-2CEA-F379-09D8-9AEF27965D12}.Debug|Any CPU.Build.0 = Debug|Any CPU
25+
{9CF47860-2CEA-F379-09D8-9AEF27965D12}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{9CF47860-2CEA-F379-09D8-9AEF27965D12}.Release|Any CPU.Build.0 = Release|Any CPU
27+
EndGlobalSection
28+
GlobalSection(SolutionProperties) = preSolution
29+
HideSolutionNode = FALSE
30+
EndGlobalSection
31+
GlobalSection(ExtensibilityGlobals) = postSolution
32+
SolutionGuid = {CE272A88-90FF-4452-B402-D3AD0D08FB15}
33+
EndGlobalSection
34+
EndGlobal

0 commit comments

Comments
 (0)