42 lines
1023 B
C#
42 lines
1023 B
C#
using System;
|
|
using sharp.trading.services;
|
|
using sharp.extensions;
|
|
using System.Net.Sockets;
|
|
namespace sharp.trading.cache
|
|
{
|
|
public class HistoryService : ITradingService
|
|
{
|
|
public HistoryService()
|
|
{
|
|
}
|
|
|
|
public void RunService()
|
|
{
|
|
Console.WriteLine("History Service runs");
|
|
|
|
Pair<string>[] marketPairs = TradingEnvironment.DefaultConnection.listMarkets();
|
|
|
|
foreach (Pair<string> pair in marketPairs){
|
|
try
|
|
{
|
|
Market market = TradingEnvironment.DefaultConnection.openMarket(pair);
|
|
Console.WriteLine("History Update: {0}-{1}",market.TradedSymbol,market.PayingSymbol);
|
|
HistoryCache.getCache(market).Update(market.getHistoricTrades());
|
|
Console.WriteLine("History Update: {0}-{1} finished.",market.TradedSymbol,market.PayingSymbol);
|
|
} catch (Exception e){
|
|
Console.WriteLine("History service could not update market data for {0}-{1}",pair.Item1,pair.Item2);
|
|
}
|
|
}
|
|
}
|
|
|
|
public int SchedulingIntervall()
|
|
{
|
|
return 120;
|
|
}
|
|
|
|
public void Shutdown()
|
|
{
|
|
}
|
|
}
|
|
}
|