Hi,
I am trying to create an automated trading system and am fetching data from an API (interactive brokers) API. I need to store 30 nodes of tick data( Tick is a reference type struct I have created) and store it in a linked list. When i start the system, the list is empty, so I just use the AddFirst command (on the System::Collections::Generics::LinkedList) to store the data sequentially. When the length goes beyond 30 I want to add the node on top and remove it from below, keeping the length constant. My problem is irrespective of what node I am trying to access ( First or last) I see the same values.
#include "StdAfx.h"
#include "DataManager.h"
#include "Interface_1.h"
#include "Tick.h"
#include "Delegates.h"
#include "Math.h"
using namespace System::Collections::Generic;
DataManager::DataManager(Interface_1 ^Interface)
{
Data_interface = Interface;
m_PriceDataList = gcnew LinkedList <Tick ^>;
Data_interface->OnMyTickUpdateC += gcnew MyTickChangeHandler (this, &DataManager::UpdateDataArray);
mAV = 0;
mSTDEV = 0;
}
void DataManager::UpdateDataArray(Tick ^m_Tick)
{
if ( m_PriceDataList->Count<= 30)
{
m_PriceDataList->AddFirst(m_Tick);
double c = m_PriceDataList->First->Value->AskPrice;
double d = m_PriceDataList->Last->Value->AskPrice;
}
else
{
m_PriceDataList->AddFirst(m_Tick);
m_PriceDataList->RemoveLast();
double a = m_PriceDataList->First->Value->AskPrice;
double b = m_PriceDataList->Last->Value->AskPrice;
this->OnStackFull(m_PriceDataList);
}
}
I am newbie and have spent more than a couple of days trying to figure this out. Any help would be greatly appreciated.\
Thank you,
Ashish Menghani