-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
169 additions
and
18 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Highcharts from 'highcharts'; | ||
import { ReactNode } from 'react'; | ||
import { ProsperitySymbol } from '../../models.ts'; | ||
import { useStore } from '../../store.ts'; | ||
import { getAskColor, getBidColor } from '../../utils/colors.ts'; | ||
import { Chart } from './Chart.tsx'; | ||
|
||
export interface ConversionPriceChartProps { | ||
symbol: ProsperitySymbol; | ||
} | ||
|
||
export function ConversionPriceChart({ symbol }: ConversionPriceChartProps): ReactNode { | ||
const algorithm = useStore(state => state.algorithm)!; | ||
|
||
const bidPriceData = []; | ||
const askPriceData = []; | ||
|
||
for (const row of algorithm.data) { | ||
const observation = row.state.observations.conversionObservations[symbol]; | ||
if (observation === undefined) { | ||
continue; | ||
} | ||
|
||
bidPriceData.push([row.state.timestamp, observation.bidPrice]); | ||
askPriceData.push([row.state.timestamp, observation.askPrice]); | ||
} | ||
|
||
const options: Highcharts.Options = { | ||
yAxis: { | ||
opposite: true, | ||
allowDecimals: true, | ||
}, | ||
}; | ||
|
||
const series: Highcharts.SeriesOptionsType[] = [ | ||
{ type: 'line', name: 'Bid', color: getBidColor(1.0), marker: { symbol: 'triangle' }, data: bidPriceData }, | ||
{ type: 'line', name: 'Ask', color: getAskColor(1.0), marker: { symbol: 'triangle-down' }, data: askPriceData }, | ||
]; | ||
|
||
return <Chart title={`${symbol} - Conversion price`} options={options} series={series} />; | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Highcharts from 'highcharts'; | ||
import { ReactNode } from 'react'; | ||
import { ProsperitySymbol } from '../../models.ts'; | ||
import { useStore } from '../../store.ts'; | ||
import { Chart } from './Chart.tsx'; | ||
|
||
export interface EnvironmentChartProps { | ||
symbol: ProsperitySymbol; | ||
} | ||
|
||
export function EnvironmentChart({ symbol }: EnvironmentChartProps): ReactNode { | ||
const algorithm = useStore(state => state.algorithm)!; | ||
|
||
const sunlightData = []; | ||
const humidityData = []; | ||
|
||
for (const row of algorithm.data) { | ||
const observation = row.state.observations.conversionObservations[symbol]; | ||
if (observation === undefined) { | ||
continue; | ||
} | ||
|
||
sunlightData.push([row.state.timestamp, observation.sunlight]); | ||
humidityData.push([row.state.timestamp, observation.humidity]); | ||
} | ||
|
||
const series: Highcharts.SeriesOptionsType[] = [ | ||
{ type: 'line', name: 'Sunlight', marker: { symbol: 'square' }, yAxis: 0, data: sunlightData }, | ||
{ type: 'line', name: 'Humidity', marker: { symbol: 'circle' }, yAxis: 1, data: humidityData }, | ||
]; | ||
|
||
const options: Highcharts.Options = { | ||
yAxis: [{}, { opposite: true }], | ||
}; | ||
|
||
return <Chart title={`${symbol} - Environment`} options={options} series={series} />; | ||
} |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Highcharts from 'highcharts'; | ||
import { ReactNode } from 'react'; | ||
import { ProsperitySymbol } from '../../models.ts'; | ||
import { useStore } from '../../store.ts'; | ||
import { Chart } from './Chart.tsx'; | ||
|
||
export interface TransportChartProps { | ||
symbol: ProsperitySymbol; | ||
} | ||
|
||
export function TransportChart({ symbol }: TransportChartProps): ReactNode { | ||
const algorithm = useStore(state => state.algorithm)!; | ||
|
||
const transportFeesData = []; | ||
const importTariffData = []; | ||
const exportTariffData = []; | ||
|
||
for (const row of algorithm.data) { | ||
const observation = row.state.observations.conversionObservations[symbol]; | ||
if (observation === undefined) { | ||
continue; | ||
} | ||
|
||
transportFeesData.push([row.state.timestamp, observation.transportFees]); | ||
importTariffData.push([row.state.timestamp, observation.importTariff]); | ||
exportTariffData.push([row.state.timestamp, observation.exportTariff]); | ||
} | ||
|
||
const series: Highcharts.SeriesOptionsType[] = [ | ||
{ type: 'line', name: 'Transport fees', data: transportFeesData }, | ||
{ type: 'line', name: 'Import tariff', marker: { symbol: 'triangle' }, data: importTariffData }, | ||
{ type: 'line', name: 'Export tariff', marker: { symbol: 'triangle-down' }, data: exportTariffData }, | ||
]; | ||
|
||
return <Chart title={`${symbol} - Transport`} series={series} />; | ||
} |
This file contains 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