-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
16 changed files
with
224 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { query } from '../../utils/axios-query'; | ||
import priceUpdater, { PriceFeed, PriceHistory } from '../price-updater'; | ||
|
||
interface CandleData { | ||
time: number; | ||
close: number; | ||
open: number; | ||
high: number; | ||
low: number; | ||
volume: number; | ||
} | ||
|
||
interface CandleApiResponse { | ||
bars: CandleData[]; | ||
} | ||
|
||
class XeggexApi implements PriceFeed { | ||
public name: string = 'Xeggex'; | ||
public currencies: string[] = ['USDT']; | ||
|
||
public url: string = 'https://api.xeggex.com/api/v2/ticker/FEC_USDT'; | ||
|
||
constructor() { | ||
} | ||
|
||
public async $fetchPrice(currency): Promise<number> { | ||
const response = await query(this.url); | ||
if (response && response['lastPrice']) { | ||
return parseFloat(response['last_price']); | ||
} else { | ||
return -1; | ||
} | ||
} | ||
|
||
public async $fetchRecentPrice(currencies: string[], type: 'hour' | 'day'): Promise<PriceHistory> { | ||
const priceHistory: PriceHistory = {}; | ||
|
||
for (const currency of currencies) { | ||
if (this.currencies.includes(currency) === false) { | ||
continue; | ||
} | ||
|
||
const url = `https://api.xeggex.com/api/v2/market/candles?symbol=FEC%2FUSDT&resolution=30&countBack=336&firstDataRequest=1`; | ||
const response = await query(url) as CandleApiResponse; | ||
|
||
if (response && response.bars) { | ||
for (const bar of response.bars) { | ||
const time = Math.round(bar.time / 1000); | ||
if (priceHistory[time] === undefined) { | ||
priceHistory[time] = priceUpdater.getEmptyPricesObj(); | ||
} | ||
priceHistory[time][currency] = bar.close; // Using the 'close' price | ||
} | ||
} | ||
} | ||
|
||
return priceHistory; | ||
} | ||
} | ||
|
||
export default XeggexApi; |
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
146 changes: 143 additions & 3 deletions
146
frontend/src/app/components/svg-images/svg-images.component.html
Large diffs are not rendered by default.
Oops, something went wrong.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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