Skip to content

Commit 078fb75

Browse files
authored
feat: Add Ulcer Index (#338)
1 parent 2b9ba9b commit 078fb75

12 files changed

+193
-145
lines changed

Client/package-lock.json

+107-107
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Client/package.json

+14-14
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
},
1010
"private": false,
1111
"dependencies": {
12-
"@angular/animations": "17.3.5",
13-
"@angular/cdk": "17.3.5",
14-
"@angular/common": "17.3.5",
15-
"@angular/compiler": "17.3.5",
16-
"@angular/core": "17.3.5",
17-
"@angular/forms": "17.3.5",
18-
"@angular/material": "17.3.5",
19-
"@angular/platform-browser": "17.3.5",
20-
"@angular/platform-browser-dynamic": "17.3.5",
21-
"@angular/router": "17.3.5",
12+
"@angular/animations": "17.3.6",
13+
"@angular/cdk": "17.3.6",
14+
"@angular/common": "17.3.6",
15+
"@angular/compiler": "17.3.6",
16+
"@angular/core": "17.3.6",
17+
"@angular/forms": "17.3.6",
18+
"@angular/material": "17.3.6",
19+
"@angular/platform-browser": "17.3.6",
20+
"@angular/platform-browser-dynamic": "17.3.6",
21+
"@angular/router": "17.3.6",
2222
"@ctrl/tinycolor": "4.1.0",
2323
"@ng-matero/extensions": "17.2.2",
2424
"chart.js": "4.4.2",
@@ -32,9 +32,9 @@
3232
"zone.js": "0.14.4"
3333
},
3434
"devDependencies": {
35-
"@angular-devkit/build-angular": "17.3.5",
36-
"@angular/cli": "17.3.5",
37-
"@angular/compiler-cli": "17.3.5",
35+
"@angular-devkit/build-angular": "17.3.6",
36+
"@angular/cli": "17.3.6",
37+
"@angular/compiler-cli": "17.3.6",
3838
"typescript": "5.4.5"
3939
}
40-
}
40+
}

Client/src/app/app.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<mat-toolbar class="noselect main-toolbar" color="default">
22
<h1 class="no-wrap">
3-
<a href="https://github.com/DaveSkender/Stock.Charts/">
3+
<a href="https://github.com/facioquo/stock-charts/">
44
stock chart
55
</a>
66
</h1>

Client/src/app/picker/pick-config.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ <h3>{{r.displayName}}</h3>
3838
<!-- line width -->
3939
<mat-form-field class="style-input">
4040
<mat-label>Line width</mat-label>
41-
<mat-select name="linewidth{{i}}" [(ngModel)]="r.lineWidth" [disabled]="r.lineType==='none'">
41+
<mat-select name="linewidth{{i}}" [(ngModel)]="r.lineWidth" [disabled]="userSpecifiedWidth(r.lineType)===false">
4242
<mat-option *ngFor="let width of lineWidths" [value]="width.value">
4343
{{width.name}}
4444
</mat-option>

Client/src/app/picker/pick-config.component.ts

+12-6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ interface LineWidth {
2323
interface LineType {
2424
name: string;
2525
value: string;
26+
userWidth: boolean; // user can specify width
2627
}
2728

2829
@Component({
@@ -58,15 +59,16 @@ export class PickConfigComponent {
5859
lineWidths: LineWidth[] = [
5960
{ name: "thin", value: 1 },
6061
{ name: "normal", value: 1.5 },
61-
{ name: "thick", value: 2 }
62+
{ name: "thick", value: 2 },
63+
{ name: "heavy", value: 3 }
6264
];
6365

6466
lineTypes: LineType[] = [
65-
{ name: "solid", value: "solid" },
66-
{ name: "dashes", value: "dash" },
67-
{ name: "dots", value: "dots" },
68-
{ name: "bar", value: "bar" },
69-
{ name: "none", value: "none" }
67+
{ name: "solid", value: "solid", userWidth: true },
68+
{ name: "dashes", value: "dash", userWidth: true },
69+
{ name: "dots", value: "dots", userWidth: true },
70+
{ name: "bar", value: "bar", userWidth: false },
71+
{ name: "none", value: "none", userWidth: false }
7072
];
7173

7274
constructor(
@@ -114,4 +116,8 @@ export class PickConfigComponent {
114116
picker.close();
115117
return color.toUpperCase();
116118
}
119+
120+
userSpecifiedWidth(lineValue: string): boolean {
121+
return this.lineTypes.find(x => x.value === lineValue)?.userWidth ?? true;
122+
}
117123
}

Client/src/assets/manifest.json

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "stock chart | Stock Indicators for .NET",
33
"short_name": "Stock Chart",
44
"description": "A stock chart to demonstrate the Stock Indicators for .NET NuGet package.",
5+
"id": "/",
56
"theme_color": "#212121",
67
"background_color": "#212121",
78
"icons": [

Client/src/styles/_themed-parts.scss

+1-5
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@
5757
&:active,
5858
&:hover,
5959
&:visited {
60-
-webkit-appearance: none;
61-
-moz-appearance: none;
62-
appearance: none;
63-
64-
color: inherit;
60+
color: mat.get-color-from-palette($accent, 600);
6561
}
6662

6763
&:hover {

Server/Functions/Functions.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</PropertyGroup>
99
<ItemGroup>
1010
<PackageReference Include="Alpaca.Markets" Version="7.0.6" />
11-
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
11+
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
1212
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Timer" Version="4.3.0" />
1313
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
1414
</ItemGroup>

Server/WebApi/Controllers/MainController.cs

+22-8
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@ public class MainController : ControllerBase
1212
internal static readonly int limitLast = 120;
1313

1414
[HttpGet]
15-
public string Get()
16-
{
17-
return "API is functioning nominally.";
18-
}
15+
public string Get() => "API is functioning nominally.";
1916

2017
[HttpGet("quotes")]
2118
public IActionResult GetQuotes()
@@ -25,10 +22,7 @@ public IActionResult GetQuotes()
2522
}
2623

2724
[HttpGet("indicators")]
28-
public IActionResult GetIndicators()
29-
{
30-
return Ok(Metadata.IndicatorList($"{Request.Scheme}://{Request.Host}"));
31-
}
25+
public IActionResult GetIndicators() => Ok(Metadata.IndicatorList($"{Request.Scheme}://{Request.Host}"));
3226

3327
//////////////////////////////////////////
3428
// INDICATORS (sorted alphabetically)
@@ -929,6 +923,26 @@ public IActionResult GetSuperTrend(
929923
}
930924
}
931925

926+
[HttpGet("ULCER")]
927+
public IActionResult GetUlcer(
928+
int lookbackPeriods)
929+
{
930+
try
931+
{
932+
IEnumerable<Quote> quotes = FetchQuotes.Get();
933+
934+
IEnumerable<UlcerIndexResult> results =
935+
quotes.GetUlcerIndex(lookbackPeriods)
936+
.TakeLast(limitLast);
937+
938+
return Ok(results);
939+
}
940+
catch (ArgumentOutOfRangeException rex)
941+
{
942+
return BadRequest(rex.Message);
943+
}
944+
}
945+
932946
[HttpGet("VORTEX")]
933947
public IActionResult GetVortex(
934948
int lookbackPeriods)

Server/WebApi/Services/Service.Metadata.cs

+31
Original file line numberDiff line numberDiff line change
@@ -2306,6 +2306,37 @@ public static IEnumerable<IndicatorList> IndicatorList(string baseUrl)
23062306
]
23072307
},
23082308

2309+
// Ulcer Index
2310+
new IndicatorList {
2311+
Name = "Ulcer Index (UI)",
2312+
Uiid = "ULCER",
2313+
LegendTemplate = "ULCER([P1])",
2314+
Endpoint = $"{baseUrl}/ULCER/",
2315+
Category = "price-characteristic",
2316+
ChartType = "oscillator",
2317+
Parameters =
2318+
[
2319+
new() {
2320+
DisplayName = "Lookback Periods",
2321+
ParamName = "lookbackPeriods",
2322+
DataType = "int",
2323+
DefaultValue = 14,
2324+
Minimum = 1,
2325+
Maximum = 250
2326+
}
2327+
],
2328+
Results = [
2329+
new() {
2330+
DisplayName = "Ulcer Index",
2331+
TooltipTemplate = "UI([P1])",
2332+
DataName = "ui",
2333+
DataType = "number",
2334+
LineType = "solid",
2335+
DefaultColor = standardBlue
2336+
}
2337+
]
2338+
},
2339+
23092340
// Vortex Indicator
23102341
new IndicatorList {
23112342
Name = "Vortex Indicator",

Server/WebApi/WebApi.csproj

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Title>charts.stockindicators.dev</Title>
55
<Description>A stock chart, demonstrating the Stock Indicators for .NET NuGet library</Description>
66
<Copyright>@2020 Dave Skender</Copyright>
7-
<RepositoryUrl>https://github.com/DaveSkender/Stock.Charts</RepositoryUrl>
7+
<RepositoryUrl>https://github.com/facioquo/stock-charts</RepositoryUrl>
88
<RepositoryType>git</RepositoryType>
99
<ApplicationIcon>favicon.ico</ApplicationIcon>
1010
<PackageIcon>favicon.ico</PackageIcon>

docs/CONTRIBUTING.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ After a Pull Request is reviewed, accepted, and merged to `main`, we may batch c
2929

3030
## Contact us
3131

32-
Contact us through the NuGet [Contact Owners](https://www.nuget.org/packages/Skender.Stock.Indicators) method, privately direct message [@daveskender](https://twitter.com/messages/compose?recipient_id=27475431) on Twitter, or [submit an Issue](https://github.com/DaveSkender/Stock.Charts/issues) with your question if it is publicly relevant.
32+
Contact us through the NuGet [Contact Owners](https://www.nuget.org/packages/Skender.Stock.Indicators) method, privately direct message [@daveskender](https://twitter.com/messages/compose?recipient_id=27475431) on Twitter, or [submit an Issue](https://github.com/facioquo/stock-charts/issues) with your question if it is publicly relevant.
3333

3434
Thanks,
3535
Dave Skender

0 commit comments

Comments
 (0)