Skip to content

Commit

Permalink
Fix: Regression with newly added Trades not getting tickeId assigned …
Browse files Browse the repository at this point in the history
…thereby not getting streaming market prices immediately.
  • Loading branch information
PaulSquires committed Sep 27, 2023
1 parent 49936c0 commit 2c6bf12
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 7 deletions.
4 changes: 3 additions & 1 deletion IB-Tracker/src/ActiveTrades/ActiveTrades.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ void ActiveTrades_ShowActiveTrades(const bool bForceReload)

// If tickerId already exists for our trade then use that one otherwise assign new tickerId.
int next_ticker_id = (trade->tickerId > 0) ? trade->tickerId : tickerId++;
trade->tickerId = next_ticker_id;
ListBoxData_OpenPosition(hListBox, trade, next_ticker_id);
}
}
Expand All @@ -196,7 +197,8 @@ void ActiveTrades_ShowActiveTrades(const bool bForceReload)
ListBoxData_NoTradesExistMessage(hListBox);
ListBoxData_ResizeColumnWidths(hListBox, TableType::active_trades, -1);
AfxRedrawWindow(hListBox);
TradeHistory_ShowTradesHistoryTable(nullptr);
auto t = std::make_shared<Trade>();
TradeHistory_ShowTradesHistoryTable(t);
}


Expand Down
2 changes: 1 addition & 1 deletion IB-Tracker/src/Config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SOFTWARE.

#pragma once

constexpr std::wstring version = L"2.5.0";
constexpr std::wstring version = L"2.5.1";

bool SaveConfig();
bool LoadConfig();
Expand Down
2 changes: 1 addition & 1 deletion IB-Tracker/src/TradeHistory/TradeHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void TradeHistory_OnSize(HWND hwnd, UINT state, int cx, int cy);
// ========================================================================================
// Populate the History ListBox with the current active/open trades
// ========================================================================================
void TradeHistory_ShowTradesHistoryTable(const std::shared_ptr<Trade>& trade)
void TradeHistory_ShowTradesHistoryTable(std::shared_ptr<Trade>& trade)
{
HWND hListBox = GetDlgItem(HWND_TRADEHISTORY, IDC_HISTORY_LISTBOX);
HWND hCustomVScrollBar = GetDlgItem(HWND_TRADEHISTORY, IDC_HISTORY_CUSTOMVSCROLLBAR);
Expand Down
2 changes: 1 addition & 1 deletion IB-Tracker/src/TradeHistory/TradeHistory.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,5 @@ constexpr int HISTORY_LISTBOX_ROWHEIGHT = 20;
constexpr int TICKER_TOTALS_LISTBOX_ROWHEIGHT = 16;
constexpr int TRADEHISTORY_MARGIN = 24;

void TradeHistory_ShowTradesHistoryTable(const std::shared_ptr<Trade>& trade);
void TradeHistory_ShowTradesHistoryTable(std::shared_ptr<Trade>& trade);

2 changes: 1 addition & 1 deletion IB-Tracker/src/Utilities/ListBoxData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ void ListBoxData_TradeROI(HWND hListBox, const std::shared_ptr<Trade>& trade, Ti
// ========================================================================================
// Create the display data for an Open Position that displays in Trades & History tables.
// ========================================================================================
void ListBoxData_OpenPosition(HWND hListBox, const std::shared_ptr<Trade>& trade, TickerId tickerId)
void ListBoxData_OpenPosition(HWND hListBox, std::shared_ptr<Trade>& trade, TickerId tickerId)
{
ListBoxData* ld = new ListBoxData;

Expand Down
6 changes: 4 additions & 2 deletions IB-Tracker/src/Utilities/ListBoxData.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ class ListBoxData {
if (tickId != -1) line_type = LineType::ticker_line;
tickerId = tickId;
trade = tradeptr;
if (trade != nullptr) trade->tickerId = tickerId;
if (trade != nullptr && line_type == LineType::ticker_line) {
trade->tickerId = tickerId;
}

col[index].text = text;
col[index].HAlignment = HAlignment;
Expand Down Expand Up @@ -126,7 +128,7 @@ bool ListBoxData_ResizeColumnWidths(HWND hListBox, TableType table_type, int ind
void ListBoxData_DestroyItemData(HWND hListBox);
void ListBoxData_RequestMarketData(HWND hListBox);
void ListBoxData_NoTradesExistMessage(HWND hListBox);
void ListBoxData_OpenPosition(HWND hListBox, const std::shared_ptr<Trade>& trade, TickerId tickerId);
void ListBoxData_OpenPosition(HWND hListBox, std::shared_ptr<Trade>& trade, TickerId tickerId);
void ListBoxData_TradeROI(HWND hListBox, const std::shared_ptr<Trade>& trade, TickerId tickerId);
void ListBoxData_HistoryHeader(
HWND hListBox, const std::shared_ptr<Trade>& trade, const std::shared_ptr<Transaction>& trans);
Expand Down

0 comments on commit 2c6bf12

Please sign in to comment.