Skip to content

Commit

Permalink
Add expected value as a percentage, improve logs.
Browse files Browse the repository at this point in the history
  • Loading branch information
nigelnindodev committed Oct 27, 2023
1 parent 84b7e60 commit 62084cf
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/core/analysis/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class BaseAnalyser {
protected getEventEvPercent(probabilityOfEvent: number, oddsForEvent: number): number {
const theoreticalStake = 10;
const evAsNumber = (this.getWinnings(theoreticalStake, oddsForEvent) * probabilityOfEvent) - (theoreticalStake * (1-probabilityOfEvent));
return evAsNumber; // TODO: Return as a percentage
return (evAsNumber / theoreticalStake) * 100; // TODO: Return as a percentage
}
/**
* Get two way game events that can be analyzed.
Expand Down
5 changes: 3 additions & 2 deletions src/core/analysis/three_way/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {logger} = getConfig();

export class ThreeWayAnalyzer extends BaseAnalyser {
public async getData() {
const gameEventsWithEv: {clubAWinEv: number, clubBWinEv: number, drawEv: number, event: ThreeWayGameEventEntity}[] = [];
const gameEventsWithEv: {clubAWinEv: number, clubBWinEv: number, drawEv: number, event: ThreeWayGameEventEntity, trueEvent: ThreeWayGameEventEntity}[] = [];

const getEventDataResult = await this.getThreeWayGameEventData();

Expand Down Expand Up @@ -34,7 +34,8 @@ export class ThreeWayAnalyzer extends BaseAnalyser {
clubAWinEv,
clubBWinEv,
drawEv,
event: gameEvent
event: gameEvent,
trueEvent: event
});
});
}
Expand Down
5 changes: 2 additions & 3 deletions src/datastores/postgres/queries/three_way_game_event/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,14 +60,13 @@ export const getMatchingThreeWayGameEventsTrigram = async (
dataSource: DataSource,
event: ThreeWayGameEventEntity
): Promise<ThreeWayGameEventEntity[] | null> => {
//@ts-ignore
const currentDate = moment().format();

const results = await dataSource.createQueryBuilder()
.select("three_way_game_event")
.from(ThreeWayGameEventEntity, "three_way_game_event")
//.where("estimated_start_time_utc > :currentDate", {currentDate: currentDate}) TODO: Add before final commit
.where("bet_provider_name != :betProviderName", {betProviderName: event.bet_provider_name})
.where("estimated_start_time_utc > :currentDate", {currentDate: currentDate})
.andWhere("bet_provider_name != :betProviderName", {betProviderName: event.bet_provider_name})
.andWhere("similarity(club_a, :clubAName) > 0.2", {clubAName: event.club_a})
.andWhere("similarity(club_b, :clubBName) > 0.2", {clubBName: event.club_b})
.getMany();
Expand Down
5 changes: 2 additions & 3 deletions src/datastores/postgres/queries/two_way_game_event/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,13 @@ export const getMatchingTwoWayGameEventsTrigram = async (
dataSource: DataSource,
event: TwoWayGameEventEntity
): Promise<TwoWayGameEventEntity[] | null> => {
//@ts-ignore
const currentDate = moment().format();

const results = await dataSource.createQueryBuilder()
.select("two_way_game_event")
.from(TwoWayGameEventEntity, "two_way_game_event")
//.where("estimated_start_time_utc > :currentDate", {currentDate: currentDate}) TODO: Add before final commit
.where("bet_provider_name != :betProviderName", {betProviderName: event.bet_provider_name})
.where("estimated_start_time_utc > :currentDate", {currentDate: currentDate})
.andWhere("bet_provider_name != :betProviderName", {betProviderName: event.bet_provider_name})
.andWhere("similarity(club_a, :clubAName) > 0.2", {clubAName: event.club_a})
.andWhere("similarity(club_b, :clubBName) > 0.2", {clubBName: event.club_b})
.getMany();
Expand Down
4 changes: 2 additions & 2 deletions src/testbed/testbed_1.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BetikaScrapper } from "../core/scrapping/betika";
import { OrbitScrapper } from "../core/scrapping/orbit";

const scrapper = new BetikaScrapper();
const scrapper = new OrbitScrapper();
scrapper.fetchData();
4 changes: 2 additions & 2 deletions src/testbed/testbed_2.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BetikaParser } from "../core/parsers/betika";
import { OrbitParser } from "../core/parsers/orbit";

const parser = new BetikaParser()
const parser = new OrbitParser()
parser.subscribeToChannels();
4 changes: 2 additions & 2 deletions src/testbed/testbed_3.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BetikaGameEventsProcessor } from "../core/game_events/betika";
import { OrbitGameEventsProcessor } from "../core/game_events/orbit";

const gameEventsProcessor = new BetikaGameEventsProcessor();
const gameEventsProcessor = new OrbitGameEventsProcessor();
gameEventsProcessor.initGameEventsListener();
4 changes: 2 additions & 2 deletions src/testbed/testbed_4.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ThreeWayAnalyzer } from "../core/analysis/three_way";
import { TwoWayAnalyser } from "../core/analysis/two_way";

const analyzer = new ThreeWayAnalyzer();
const analyzer = new TwoWayAnalyser();
analyzer.getData();

0 comments on commit 62084cf

Please sign in to comment.